Class SegmentInfo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Codec
final Directory
Where this segment resides.private final byte[]
Id that uniquely identifies this segment.private final Sort
private boolean
private int
(package private) Version
final String
Unique segment name in the directory.static final int
Used by some member fields to mean not present (e.g., norms, deletions).private final Version
static final int
Used by some member fields to mean present (e.g., norms, deletions). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDiagnostics
(Map<String, String> diagnostics) Adds or modifies this segment's diagnostics.void
Add this file to the set of files written for this segment.void
addFiles
(Collection<String> files) Add these files to the set of files written for this segment.private void
checkFileNames
(Collection<String> files) boolean
We consider another SegmentInfo instance equal if it has the same dir and same name.files()
Return all files referenced by this SegmentInfo.getAttribute
(String key) Get a codec attribute value, or null if it does not existReturns the internal codec attributes map.getCodec()
ReturnCodec
that wrote this segment.Returns diagnostics saved into the segment when it was written.byte[]
getId()
Return the id that uniquely identifies this segment.Return the sort order of this segment, or null if the index has no sort.Return the minimum Lucene version that contributed documents to this segment, ornull
if it is unknown.boolean
Returns true if this segment is stored as a compound file; else, false.Returns the version of the code which wrote the segment.int
hashCode()
int
maxDoc()
Returns number of documents in this segment (deletions are not taken into account).(package private) String
namedForThisSegment
(String file) strips any segment name from the file, naming it with this segment this is because "segment names" can change, e.g.putAttribute
(String key, String value) Puts a codec attribute value.void
Can only be called once.(package private) void
setDiagnostics
(Map<String, String> diagnostics) void
setFiles
(Collection<String> files) Sets the files written for this segment.(package private) void
setMaxDoc
(int maxDoc) (package private) void
setUseCompoundFile
(boolean isCompoundFile) Mark whether this segment is stored as a compound file.toString()
toString
(int delCount) Used for debugging.
-
Field Details
-
NO
public static final int NOUsed by some member fields to mean not present (e.g., norms, deletions).- See Also:
-
YES
public static final int YESUsed by some member fields to mean present (e.g., norms, deletions).- See Also:
-
name
Unique segment name in the directory. -
maxDoc
private int maxDoc -
dir
Where this segment resides. -
isCompoundFile
private boolean isCompoundFile -
id
private final byte[] idId that uniquely identifies this segment. -
codec
-
diagnostics
-
attributes
-
indexSort
-
version
-
minVersion
Version minVersion -
setFiles
-
-
Constructor Details
-
SegmentInfo
public SegmentInfo(Directory dir, Version version, Version minVersion, String name, int maxDoc, boolean isCompoundFile, Codec codec, Map<String, String> diagnostics, byte[] id, Map<String, String> attributes, Sort indexSort) Construct a new complete SegmentInfo instance from input.Note: this is public only to allow access from the codecs package.
-
-
Method Details
-
setDiagnostics
-
addDiagnostics
Adds or modifies this segment's diagnostics.Entries in the given map whose keys are not present in the current diagnostics are added. Otherwise, existing entries are modified with the given map's value.
- Parameters:
diagnostics
- the additional diagnostics
-
getDiagnostics
Returns diagnostics saved into the segment when it was written. The map is immutable. -
setUseCompoundFile
void setUseCompoundFile(boolean isCompoundFile) Mark whether this segment is stored as a compound file.- Parameters:
isCompoundFile
- true if this is a compound file; else, false
-
getUseCompoundFile
public boolean getUseCompoundFile()Returns true if this segment is stored as a compound file; else, false. -
setCodec
Can only be called once. -
getCodec
ReturnCodec
that wrote this segment. -
maxDoc
public int maxDoc()Returns number of documents in this segment (deletions are not taken into account). -
setMaxDoc
void setMaxDoc(int maxDoc) -
files
Return all files referenced by this SegmentInfo. -
toString
-
toString
Used for debugging. Format may suddenly change.Current format looks like
_a(3.1):c45/4:[sorter=<long: "timestamp">!]
, which means the segment's name is_a
; it was created with Lucene 3.1 (or '?' if it's unknown); it's using compound file format (would beC
if not compound); it has 45 documents; it has 4 deletions (this part is left off when there are no deletions); it is sorted by the timestamp field in descending order (this part is omitted for unsorted segments). -
equals
We consider another SegmentInfo instance equal if it has the same dir and same name. -
hashCode
public int hashCode() -
getVersion
Returns the version of the code which wrote the segment. -
getMinVersion
Return the minimum Lucene version that contributed documents to this segment, ornull
if it is unknown. -
getId
public byte[] getId()Return the id that uniquely identifies this segment. -
setFiles
Sets the files written for this segment. -
addFiles
Add these files to the set of files written for this segment. -
addFile
Add this file to the set of files written for this segment. -
checkFileNames
-
namedForThisSegment
strips any segment name from the file, naming it with this segment this is because "segment names" can change, e.g. by addIndexes(Dir) -
getAttribute
Get a codec attribute value, or null if it does not exist -
putAttribute
Puts a codec attribute value.This is a key-value mapping for the field that the codec can use to store additional metadata, and will be available to the codec when reading the segment via
getAttribute(String)
If a value already exists for the field, it will be replaced with the new value. This method make a copy on write for every attribute change.
-
getAttributes
Returns the internal codec attributes map.- Returns:
- internal codec attributes map.
-
getIndexSort
Return the sort order of this segment, or null if the index has no sort.
-