org.apache.lucene.index

## Class SegmentInfoPerCommit

- java.lang.Object
- - org.apache.lucene.index.SegmentInfoPerCommit

    public class SegmentInfoPerCommit
    extends Object

Embeds a [read-only] SegmentInfo and adds per-commit fields.

WARNING: This API is experimental and might change in incompatible ways in the next release.

### Field Summary

Fields
`SegmentInfo` `info` The `SegmentInfo` that we wrap.

### Constructor Summary

Constructors
Constructor and Description
`SegmentInfoPerCommit(SegmentInfo info, int delCount, long delGen)` Sole constructor.

### Method Summary

Methods
`SegmentInfoPerCommit` `clone()`
`Collection<String>` `files()` Returns all files in use by this segment.
`int` `getDelCount()` Returns the number of deleted docs in the segment.
`long` `getDelGen()` Returns generation number of the live docs file or -1 if there are no deletes yet.
`long` `getNextDelGen()` Returns the next available generation number of the live docs file.
`boolean` `hasDeletions()` Returns true if there are any deletions for the segment at this commit.
`void` `setDelGen(long delGen)` Sets the generation number of the live docs file.
`long` `sizeInBytes()` Returns total size in bytes of all files for this segment.
`String` `toString()`
`String` `toString(Directory dir, int pendingDelCount)` Returns a description of this segment.

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### info

    public final SegmentInfo info

The `SegmentInfo` that we wrap.

### Constructor Detail

#### SegmentInfoPerCommit

    public SegmentInfoPerCommit(SegmentInfo info,
                        int delCount,
                        long delGen)

Sole constructor.

Parameters:
  `info` - `SegmentInfo` that we wrap
  `delCount` - number of deleted documents in this segment
  `delGen` - deletion generation number (used to name deletion files)

### Method Detail

#### sizeInBytes

    public long sizeInBytes()
                     throws IOException

Returns total size in bytes of all files for this segment.

NOTE: This value is not correct for 3.0 segments that have shared docstores. To get the correct value, upgrade!

Throws:
  `IOException`

#### files

    public Collection<String> files()
                             throws IOException

Returns all files in use by this segment.

Throws:
  `IOException`

#### setDelGen

    public void setDelGen(long delGen)

Sets the generation number of the live docs file.

See Also:
  `getDelGen()`

#### hasDeletions

    public boolean hasDeletions()

Returns true if there are any deletions for the segment at this commit.

#### getNextDelGen

    public long getNextDelGen()

Returns the next available generation number of the live docs file.

#### getDelGen

    public long getDelGen()

Returns generation number of the live docs file or -1 if there are no deletes yet.

#### getDelCount

    public int getDelCount()

Returns the number of deleted docs in the segment.

#### toString

    public String toString(Directory dir,
                  int pendingDelCount)

Returns a description of this segment.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### clone

    public SegmentInfoPerCommit clone()

Overrides:
  `clone` in class `Object`