Save This Page
Home » lucene-3.0.1-src » org.apache » lucene » index » [javadoc | source]
org.apache.lucene.index
public final class: SegmentInfos [javadoc | source]
java.lang.Object
   java.util.AbstractCollection
      java.util.AbstractList
         java.util.Vector<SegmentInfo>
            org.apache.lucene.index.SegmentInfos

All Implemented Interfaces:
    List, Serializable, RandomAccess, Cloneable, Collection

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)

Nested Class Summary:
abstract public static class  SegmentInfos.FindSegmentsFile  Utility class for executing code that needs to do something with the current segments file. This is necessary with lock-less commits because from the time you locate the current segments file name, until you actually open it, read its contents, or check modified time, etc., it could have been deleted due to a writer commit finishing. 
Field Summary
public static final  int FORMAT    The file format version, a negative number. 
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. 
public static final  int FORMAT_SINGLE_NORM_FILE    This format adds a "hasSingleNormFile" flag into each segment info. See LUCENE-756 for details. 
public static final  int FORMAT_SHARED_DOC_STORE    This format allows multiple segments to share a single vectors and stored fields file. 
public static final  int FORMAT_CHECKSUM    This format adds a checksum at the end of the file to ensure all bytes were successfully written. 
public static final  int FORMAT_DEL_COUNT    This format adds the deletion count for each segment. This way IndexWriter can efficiently report numDocs(). 
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) 
public static final  int FORMAT_USER_DATA    This format adds optional commit userData (String) storage. 
public static final  int FORMAT_DIAGNOSTICS    This format adds optional per-segment String diagnostics storage, and switches userData to Map 
static final  int CURRENT_FORMAT     
public  int counter     
 ChecksumIndexOutput pendingSegnOutput     
Fields inherited from java.util.Vector:
elementData,  elementCount,  capacityIncrement
Fields inherited from java.util.AbstractList:
modCount
Method from org.apache.lucene.index.SegmentInfos Summary:
clone,   commit,   files,   finishCommit,   generationFromSegmentsFileName,   getCurrentSegmentFileName,   getCurrentSegmentFileName,   getCurrentSegmentFileName,   getCurrentSegmentGeneration,   getCurrentSegmentGeneration,   getDefaultGenFileRetryCount,   getDefaultGenFileRetryPauseMsec,   getDefaultGenLookahedCount,   getGeneration,   getInfoStream,   getLastGeneration,   getNextSegmentFileName,   getUserData,   getVersion,   hasExternalSegments,   info,   prepareCommit,   range,   read,   read,   readCurrentUserData,   readCurrentVersion,   replace,   rollbackCommit,   segString,   setDefaultGenFileRetryCount,   setDefaultGenFileRetryPauseMsec,   setDefaultGenLookaheadCount,   setInfoStream,   setUserData,   updateGeneration
Methods from java.util.Vector:
add,   add,   addAll,   addAll,   addElement,   capacity,   clear,   clone,   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 from java.util.AbstractList:
add,   add,   addAll,   clear,   equals,   get,   hashCode,   indexOf,   iterator,   lastIndexOf,   listIterator,   listIterator,   remove,   removeRange,   set,   subList
Methods from java.util.AbstractCollection:
add,   addAll,   clear,   contains,   containsAll,   isEmpty,   iterator,   remove,   removeAll,   retainAll,   size,   toArray,   toArray,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.lucene.index.SegmentInfos Detail:
 public Object clone() 
    Returns a copy of this instance, also copying each SegmentInfo.
 final  void commit(Directory dir) throws IOException 
    Writes & syncs to the Directory dir, taking care to remove the segments file on exception
 public Collection<String> files(Directory dir,
    boolean includeSegmentsFile) throws IOException 
    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.
 final  void finishCommit(Directory dir) throws IOException 
 public static long generationFromSegmentsFileName(String fileName) 
    Parse the generation off the segments file name and return it.
 public String getCurrentSegmentFileName() 
    Get the segments_N filename in use by this segment infos.
 public static String getCurrentSegmentFileName(String[] files) throws IOException 
    Get the filename of the current segments_N file from a list of files.
 public static String getCurrentSegmentFileName(Directory directory) throws IOException 
    Get the filename of the current segments_N file in the directory.
 public static long getCurrentSegmentGeneration(String[] files) 
    Get the generation (N) of the current segments_N file from a list of files.
 public static long getCurrentSegmentGeneration(Directory directory) throws IOException 
    Get the generation (N) of the current segments_N file in the directory.
 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<String, String> getUserData() 
 public long getVersion() 
    version number when this SegmentInfos was generated.
 public boolean hasExternalSegments(Directory dir) 
 public final SegmentInfo info(int i) 
 final  void prepareCommit(Directory dir) throws IOException 
    Call this to start a commit. This writes the new segments file, but writes an invalid checksum at the end, so that it is not visible to readers. Once this is called you must call #finishCommit to complete the commit or #rollbackCommit to abort it.
 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) throws CorruptIndexException, IOException 
    This version of read uses the retry logic (for lock-less commits) to find the right segments file to load.
 public final  void read(Directory directory,
    String segmentFileName) throws CorruptIndexException, IOException 
    Read a particular segmentFileName. Note that this may throw an IOException if a commit is in process.
 public static Map<String, String> readCurrentUserData(Directory directory) throws CorruptIndexException, IOException 
    Returns userData from latest segments file
 public static long readCurrentVersion(Directory directory) throws CorruptIndexException, IOException 
    Current version number from segments file.
  void replace(SegmentInfos other) 
    Replaces all segments in this instance, but keeps generation, version, counter so that future commits remain write once.
 final  void rollbackCommit(Directory dir) throws IOException 
 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.
  void setUserData(Map<String, String> data) 
  void updateGeneration(SegmentInfos other)