org.apache.lucene.index
Class SegmentInfos

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.Vector
              extended byorg.apache.lucene.index.SegmentInfos
All Implemented Interfaces:
Cloneable, Collection, List, RandomAccess, Serializable

public final class SegmentInfos
extends Vector

See Also:
Serialized Form

Nested Class Summary
static class SegmentInfos.FindSegmentsFile
          Utility class for executing code that needs to do something with the current segments file.
 
Field Summary
 int counter
           
static int FORMAT
          The file format version, a negative number.
static int FORMAT_LOCKLESS
          This format adds details used for lockless commits.
static int FORMAT_SINGLE_NORM_FILE
          This is the current file format written.
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SegmentInfos()
           
 
Method Summary
 Object clone()
          Returns a copy of this instance, also copying each SegmentInfo.
 String getCurrentSegmentFileName()
          Get the segments_N filename in use by this segment infos.
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.
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()
           
static PrintStream getInfoStream()
           
 String getNextSegmentFileName()
          Get the next segments_N filename that will be written.
 long getVersion()
          version number when this SegmentInfos was generated.
 org.apache.lucene.index.SegmentInfo info(int i)
           
 void read(Directory directory)
          This version of read uses the retry logic (for lock-less commits) to find the right segments file to load.
 void read(Directory directory, String segmentFileName)
          Read a particular segmentFileName.
static long readCurrentVersion(Directory directory)
          Current version number from segments file.
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.
 void write(Directory directory)
           
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

FORMAT

public static final int FORMAT
The file format version, a negative number.

See Also:
Constant Field Values

FORMAT_LOCKLESS

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.

See Also:
Constant Field Values

FORMAT_SINGLE_NORM_FILE

public static final int FORMAT_SINGLE_NORM_FILE
This is the current file format written. It adds a "hasSingleNormFile" flag into each segment info. See LUCENE-756 for details.

See Also:
Constant Field Values

counter

public int counter
Constructor Detail

SegmentInfos

public SegmentInfos()
Method Detail

info

public final org.apache.lucene.index.SegmentInfo info(int i)

getCurrentSegmentGeneration

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

getCurrentSegmentGeneration

public static long getCurrentSegmentGeneration(Directory directory)
                                        throws IOException
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

getCurrentSegmentFileName

public static String getCurrentSegmentFileName(String[] files)
                                        throws IOException
Get the filename of the current segments_N file from a list of files.

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

getCurrentSegmentFileName

public static String getCurrentSegmentFileName(Directory directory)
                                        throws IOException
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

getCurrentSegmentFileName

public String getCurrentSegmentFileName()
Get the segments_N filename in use by this segment infos.


getNextSegmentFileName

public String getNextSegmentFileName()
Get the next segments_N filename that will be written.


read

public final void read(Directory directory,
                       String segmentFileName)
                throws IOException
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:
IOException

read

public final void read(Directory directory)
                throws IOException
This version of read uses the retry logic (for lock-less commits) to find the right segments file to load.

Throws:
IOException

write

public final void write(Directory directory)
                 throws IOException
Throws:
IOException

clone

public Object clone()
Returns a copy of this instance, also copying each SegmentInfo.


getVersion

public long getVersion()
version number when this SegmentInfos was generated.


readCurrentVersion

public static long readCurrentVersion(Directory directory)
                               throws IOException
Current version number from segments file.

Throws:
IOException

setInfoStream

public static void setInfoStream(PrintStream infoStream)
If non-null, information about retries when loading the segments file will be printed to this.


setDefaultGenFileRetryCount

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.


getDefaultGenFileRetryCount

public static int getDefaultGenFileRetryCount()
See Also:
setDefaultGenFileRetryCount(int)

setDefaultGenFileRetryPauseMsec

public static void setDefaultGenFileRetryPauseMsec(int msec)
Advanced: set how many milliseconds to pause in between attempts to load the segments.gen file.


getDefaultGenFileRetryPauseMsec

public static int getDefaultGenFileRetryPauseMsec()
See Also:
setDefaultGenFileRetryPauseMsec(int)

setDefaultGenLookaheadCount

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.


getDefaultGenLookahedCount

public static int getDefaultGenLookahedCount()
See Also:
setDefaultGenLookaheadCount(int)

getInfoStream

public static PrintStream getInfoStream()
See Also:
setInfoStream(java.io.PrintStream)


Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.