Class SegmentInfo
- java.lang.Object
-
- org.apache.lucene.index.SegmentInfo
-
public final class SegmentInfo extends java.lang.ObjectInformation about a segment such as it's name, directory, and files related to the segment.
-
-
Field Summary
Fields Modifier and Type Field Description DirectorydirWhere this segment resides.java.lang.StringnameUnique segment name in the directory.static intNOUsed by some member fields to mean not present (e.g., norms, deletions).static intYESUsed by some member fields to mean present (e.g., norms, deletions).
-
Constructor Summary
Constructors Constructor Description SegmentInfo(Directory dir, java.lang.String version, java.lang.String name, int docCount, boolean isCompoundFile, Codec codec, java.util.Map<java.lang.String,java.lang.String> diagnostics)Construct a new complete SegmentInfo instance from input.SegmentInfo(Directory dir, java.lang.String version, java.lang.String name, int docCount, boolean isCompoundFile, Codec codec, java.util.Map<java.lang.String,java.lang.String> diagnostics, java.util.Map<java.lang.String,java.lang.String> attributes)Construct a new complete SegmentInfo instance from input.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddFile(java.lang.String file)Add this file to the set of files written for this segment.voidaddFiles(java.util.Collection<java.lang.String> files)Add these files to the set of files written for this segment.java.util.Map<java.lang.String,java.lang.String>attributes()Deprecated.no longer supportedbooleanequals(java.lang.Object obj)We consider another SegmentInfo instance equal if it has the same dir and same name.java.util.Set<java.lang.String>files()Return all files referenced by this SegmentInfo.java.lang.StringgetAttribute(java.lang.String key)Deprecated.no longer supportedCodecgetCodec()ReturnCodecthat wrote this segment.java.util.Map<java.lang.String,java.lang.String>getDiagnostics()Returns diagnostics saved into the segment when it was written.intgetDocCount()Returns number of documents in this segment (deletions are not taken into account).booleangetUseCompoundFile()Returns true if this segment is stored as a compound file; else, false.java.lang.StringgetVersion()Returns the version of the code which wrote the segment.inthashCode()java.lang.StringputAttribute(java.lang.String key, java.lang.String value)Deprecated.no longer supportedvoidsetCodec(Codec codec)Can only be called once.voidsetFiles(java.util.Set<java.lang.String> files)Sets the files written for this segment.voidsetVersion(java.lang.String version)Used by DefaultSegmentInfosReader to upgrade a 3.0 segment to record its version is "3.0".java.lang.StringtoString()java.lang.StringtoString(Directory dir, int delCount)Used for debugging.
-
-
-
Field Detail
-
NO
public static final int NO
Used by some member fields to mean not present (e.g., norms, deletions).- See Also:
- Constant Field Values
-
YES
public static final int YES
Used by some member fields to mean present (e.g., norms, deletions).- See Also:
- Constant Field Values
-
name
public final java.lang.String name
Unique segment name in the directory.
-
dir
public final Directory dir
Where this segment resides.
-
-
Constructor Detail
-
SegmentInfo
public SegmentInfo(Directory dir, java.lang.String version, java.lang.String name, int docCount, boolean isCompoundFile, Codec codec, java.util.Map<java.lang.String,java.lang.String> diagnostics)
Construct a new complete SegmentInfo instance from input.Note: this is public only to allow access from the codecs package.
-
SegmentInfo
public SegmentInfo(Directory dir, java.lang.String version, java.lang.String name, int docCount, boolean isCompoundFile, Codec codec, java.util.Map<java.lang.String,java.lang.String> diagnostics, java.util.Map<java.lang.String,java.lang.String> attributes)
Construct a new complete SegmentInfo instance from input.Note: this is public only to allow access from the codecs package.
-
-
Method Detail
-
getDiagnostics
public java.util.Map<java.lang.String,java.lang.String> getDiagnostics()
Returns diagnostics saved into the segment when it was written.
-
getUseCompoundFile
public boolean getUseCompoundFile()
Returns true if this segment is stored as a compound file; else, false.
-
setCodec
public void setCodec(Codec codec)
Can only be called once.
-
getDocCount
public int getDocCount()
Returns number of documents in this segment (deletions are not taken into account).
-
files
public java.util.Set<java.lang.String> files()
Return all files referenced by this SegmentInfo.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toString
public java.lang.String toString(Directory dir, int delCount)
Used for debugging. Format may suddenly change.Current format looks like
_a(3.1):c45/4, 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 beCif not compound); it has 45 documents; it has 4 deletions (this part is left off when there are no deletions).
-
equals
public boolean equals(java.lang.Object obj)
We consider another SegmentInfo instance equal if it has the same dir and same name.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setVersion
public void setVersion(java.lang.String version)
Used by DefaultSegmentInfosReader to upgrade a 3.0 segment to record its version is "3.0". This method can be removed when we're not required to support 3x indexes anymore, e.g. in 5.0.NOTE: this method is used for internal purposes only - you should not modify the version of a SegmentInfo, or it may result in unexpected exceptions thrown when you attempt to open the index.
-
getVersion
public java.lang.String getVersion()
Returns the version of the code which wrote the segment.
-
setFiles
public void setFiles(java.util.Set<java.lang.String> files)
Sets the files written for this segment.
-
addFiles
public void addFiles(java.util.Collection<java.lang.String> files)
Add these files to the set of files written for this segment.
-
addFile
public void addFile(java.lang.String file)
Add this file to the set of files written for this segment.
-
getAttribute
@Deprecated public java.lang.String getAttribute(java.lang.String key)
Deprecated.no longer supportedGet a codec attribute value, or null if it does not exist
-
putAttribute
@Deprecated public java.lang.String putAttribute(java.lang.String key, java.lang.String value)Deprecated.no longer supportedPuts 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.
-
attributes
@Deprecated public java.util.Map<java.lang.String,java.lang.String> attributes()
Deprecated.no longer supportedReturns the internal codec attributes map.- Returns:
- internal codec attributes map. May be null if no mappings exist.
-
-