public final class

SegmentInfos

extends Vector<E>
java.lang.Object
   ↳ java.util.AbstractCollection<E>
     ↳ java.util.AbstractList<E>
       ↳ java.util.Vector<E>
         ↳ org.apache.lucene.index.SegmentInfos

Class Overview

A collection of segmentInfo objects with methods for operating on those segments in relation to the file system.

NOTE: This API is new and still experimental (subject to change suddenly in the next release)

Summary

Nested Classes
class SegmentInfos.FindSegmentsFile Utility class for executing code that needs to do something with the current segments file. 
Constants
int FORMAT The file format version, a negative number.
int FORMAT_CHECKSUM This format adds a checksum at the end of the file to ensure all bytes were successfully written.
int FORMAT_DEL_COUNT This format adds the deletion count for each segment.
int FORMAT_DIAGNOSTICS This format adds optional per-segment String diagnostics storage, and switches userData to Map
int FORMAT_HAS_PROX This format adds the boolean hasProx to record if any fields in the segment store prox information (ie, have omitTermFreqAndPositions==false)
int FORMAT_LOCKLESS This format adds details used for lockless commits.
int FORMAT_SHARED_DOC_STORE This format allows multiple segments to share a single vectors and stored fields file.
int FORMAT_SINGLE_NORM_FILE This format adds a "hasSingleNormFile" flag into each segment info.
int FORMAT_USER_DATA This format adds optional commit userData (String) storage.
Fields
public int counter
[Expand]
Inherited Fields
From class java.util.Vector
From class java.util.AbstractList
Public Constructors
SegmentInfos()
Public Methods
Object clone()
Returns a copy of this instance, also copying each SegmentInfo.
Collection<String> files(Directory dir, boolean includeSegmentsFile)
Returns all file names referenced by SegmentInfo instances matching the provided Directory (ie files associated with any "external" segments are skipped).
static long generationFromSegmentsFileName(String fileName)
Parse the generation off the segments file name and return it.
static String getCurrentSegmentFileName(Directory directory)
Get the filename of the current segments_N file in the directory.
static String getCurrentSegmentFileName(String[] files)
Get the filename of the current segments_N file from a list of files.
String getCurrentSegmentFileName()
Get the segments_N filename in use by this segment infos.
static long getCurrentSegmentGeneration(Directory directory)
Get the generation (N) of the current segments_N file in the directory.
static long getCurrentSegmentGeneration(String[] files)
Get the generation (N) of the current segments_N file from a list of files.
static int getDefaultGenFileRetryCount()
static int getDefaultGenFileRetryPauseMsec()
static int getDefaultGenLookahedCount()
long getGeneration()
static PrintStream getInfoStream()
long getLastGeneration()
String getNextSegmentFileName()
Get the next segments_N filename that will be written.
Map<StringString> getUserData()
long getVersion()
version number when this SegmentInfos was generated.
boolean hasExternalSegments(Directory dir)
final SegmentInfo info(int i)
SegmentInfos range(int first, int last)
Returns a new SegmentInfos containing the SegmentInfo instances in the specified range first (inclusive) to last (exclusive), so total number of segments returned is last-first.
final void read(Directory directory, String segmentFileName)
Read a particular segmentFileName.
final void read(Directory directory)
This version of read uses the retry logic (for lock-less commits) to find the right segments file to load.
static Map<StringString> readCurrentUserData(Directory directory)
Returns userData from latest segments file
static long readCurrentVersion(Directory directory)
Current version number from segments file.
synchronized String segString(Directory directory)
static void setDefaultGenFileRetryCount(int count)
Advanced: set how many times to try loading the segments.gen file contents to determine current segment generation.
static void setDefaultGenFileRetryPauseMsec(int msec)
Advanced: set how many milliseconds to pause in between attempts to load the segments.gen file.
static void setDefaultGenLookaheadCount(int count)
Advanced: set how many times to try incrementing the gen when loading the segments file.
static void setInfoStream(PrintStream infoStream)
If non-null, information about retries when loading the segments file will be printed to this.
[Expand]
Inherited Methods
From class java.util.Vector
From class java.util.AbstractList
From class java.util.AbstractCollection
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface java.util.List

Constants

public static final int FORMAT

The file format version, a negative number.

Constant Value: -1 (0xffffffff)

public static final int FORMAT_CHECKSUM

This format adds a checksum at the end of the file to ensure all bytes were successfully written.

Constant Value: -5 (0xfffffffb)

public static final int FORMAT_DEL_COUNT

This format adds the deletion count for each segment. This way IndexWriter can efficiently report numDocs().

Constant Value: -6 (0xfffffffa)

public static final int FORMAT_DIAGNOSTICS

This format adds optional per-segment String diagnostics storage, and switches userData to Map

Constant Value: -9 (0xfffffff7)

public static final int FORMAT_HAS_PROX

This format adds the boolean hasProx to record if any fields in the segment store prox information (ie, have omitTermFreqAndPositions==false)

Constant Value: -7 (0xfffffff9)

public static final int FORMAT_LOCKLESS

This format adds details used for lockless commits. It differs slightly from the previous format in that file names are never re-used (write once). Instead, each file is written to the next generation. For example, segments_1, segments_2, etc. This allows us to not use a commit lock. See file formats for details.

Constant Value: -2 (0xfffffffe)

public static final int FORMAT_SHARED_DOC_STORE

This format allows multiple segments to share a single vectors and stored fields file.

Constant Value: -4 (0xfffffffc)

public static final int FORMAT_SINGLE_NORM_FILE

This format adds a "hasSingleNormFile" flag into each segment info. See LUCENE-756 for details.

Constant Value: -3 (0xfffffffd)

public static final int FORMAT_USER_DATA

This format adds optional commit userData (String) storage.

Constant Value: -8 (0xfffffff8)

Fields

public int counter

Public Constructors

public SegmentInfos ()

Public Methods

public Object clone ()

Returns a copy of this instance, also copying each SegmentInfo.

public Collection<String> files (Directory dir, boolean includeSegmentsFile)

Returns all file names referenced by SegmentInfo instances matching the provided Directory (ie files associated with any "external" segments are skipped). The returned collection is recomputed on each invocation.

Throws
IOException

public static long generationFromSegmentsFileName (String fileName)

Parse the generation off the segments file name and return it.

public static String getCurrentSegmentFileName (Directory directory)

Get the filename of the current segments_N file in the directory.

Parameters
directory -- directory to search for the latest segments_N file
Throws
IOException

public static String getCurrentSegmentFileName (String[] files)

Get the filename of the current segments_N file from a list of files.

Parameters
files -- array of file names to check
Throws
IOException

public String getCurrentSegmentFileName ()

Get the segments_N filename in use by this segment infos.

public static long getCurrentSegmentGeneration (Directory directory)

Get the generation (N) of the current segments_N file in the directory.

Parameters
directory -- directory to search for the latest segments_N file
Throws
IOException

public static long getCurrentSegmentGeneration (String[] files)

Get the generation (N) of the current segments_N file from a list of files.

Parameters
files -- array of file names to check

public static int getDefaultGenFileRetryCount ()

public static int getDefaultGenFileRetryPauseMsec ()

public static int getDefaultGenLookahedCount ()

public long getGeneration ()

public static PrintStream getInfoStream ()

public long getLastGeneration ()

public String getNextSegmentFileName ()

Get the next segments_N filename that will be written.

public Map<StringString> getUserData ()

public long getVersion ()

version number when this SegmentInfos was generated.

public boolean hasExternalSegments (Directory dir)

public final SegmentInfo info (int i)

public SegmentInfos range (int first, int last)

Returns a new SegmentInfos containing the SegmentInfo instances in the specified range first (inclusive) to last (exclusive), so total number of segments returned is last-first.

public final void read (Directory directory, String segmentFileName)

Read a particular segmentFileName. Note that this may throw an IOException if a commit is in process.

Parameters
directory -- directory containing the segments file
segmentFileName -- segment file to load
Throws
CorruptIndexException if the index is corrupt
IOException if there is a low-level IO error

public final void read (Directory directory)

This version of read uses the retry logic (for lock-less commits) to find the right segments file to load.

Throws
CorruptIndexException if the index is corrupt
IOException if there is a low-level IO error

public static Map<StringString> readCurrentUserData (Directory directory)

Returns userData from latest segments file

Throws
CorruptIndexException if the index is corrupt
IOException if there is a low-level IO error

public static long readCurrentVersion (Directory directory)

Current version number from segments file.

Throws
CorruptIndexException if the index is corrupt
IOException if there is a low-level IO error

public synchronized String segString (Directory directory)

public static void setDefaultGenFileRetryCount (int count)

Advanced: set how many times to try loading the segments.gen file contents to determine current segment generation. This file is only referenced when the primary method (listing the directory) fails.

public static void setDefaultGenFileRetryPauseMsec (int msec)

Advanced: set how many milliseconds to pause in between attempts to load the segments.gen file.

public static void setDefaultGenLookaheadCount (int count)

Advanced: set how many times to try incrementing the gen when loading the segments file. This only runs if the primary (listing directory) and secondary (opening segments.gen file) methods fail to find the segments file.

public static void setInfoStream (PrintStream infoStream)

If non-null, information about retries when loading the segments file will be printed to this.