Class SegmentInfo

  • public final class SegmentInfo
    extends Object
    Information about a segment such as its name, directory, and files related to the segment.
    • 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 String name
        Unique segment name in the directory.
      • dir

        public final Directory dir
        Where this segment resides.
    • Constructor Detail

    • Method Detail

      • getDiagnostics

        public Map<String,StringgetDiagnostics()
        Returns diagnostics saved into the segment when it was written. The map is immutable.
      • 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.
      • maxDoc

        public int maxDoc()
        Returns number of documents in this segment (deletions are not taken into account).
      • files

        public Set<Stringfiles()
        Return all files referenced by this SegmentInfo.
      • toString

        public String toString(int delCount)
        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 be C 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

        public boolean equals(Object obj)
        We consider another SegmentInfo instance equal if it has the same dir and same name.
        equals in class Object
      • getVersion

        public Version getVersion()
        Returns the version of the code which wrote the segment.
      • getId

        public byte[] getId()
        Return the id that uniquely identifies this segment.
      • addFiles

        public void addFiles(Collection<String> files)
        Add these files to the set of files written for this segment.
      • addFile

        public void addFile(String file)
        Add this file to the set of files written for this segment.
      • putAttribute

        public String putAttribute(String key,
                                   String value)
        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.

      • getAttributes

        public Map<String,StringgetAttributes()
        Returns the internal codec attributes map.
        internal codec attributes map.
      • getIndexSort

        public Sort getIndexSort()
        Return the sort order of this segment, or null if the index has no sort.