org.apache.lucene.index
Class SegmentInfos
Vector
org.apache.lucene.index.SegmentInfos
public final class SegmentInfos
extends Vector
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
FORMAT
public static final int FORMAT
The file format version, a negative number.
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.
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.
counter
public int counter
clone
public Object clone()
Returns a copy of this instance, also copying each
SegmentInfo.
getCurrentSegmentFileName
public String getCurrentSegmentFileName()
Get the segments_N filename in use by this segment infos.
getCurrentSegmentFileName
public static String getCurrentSegmentFileName(String[] files)
throws IOException
Get the filename of the current segments_N file
from a list of files.
files
- -- array of file names to check
getCurrentSegmentFileName
public static String getCurrentSegmentFileName(Directory directory)
throws IOException
Get the filename of the current segments_N file
in the directory.
directory
- -- directory to search for the latest segments_N file
getCurrentSegmentGeneration
public static long getCurrentSegmentGeneration(String[] files)
Get the generation (N) of the current segments_N file
from a list of files.
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.
directory
- -- directory to search for the latest segments_N file
getDefaultGenFileRetryCount
public static int getDefaultGenFileRetryCount()
getDefaultGenFileRetryPauseMsec
public static int getDefaultGenFileRetryPauseMsec()
getDefaultGenLookahedCount
public static int getDefaultGenLookahedCount()
getInfoStream
public static PrintStream getInfoStream()
getNextSegmentFileName
public String getNextSegmentFileName()
Get the next segments_N filename that will be written.
getVersion
public long getVersion()
version number when this SegmentInfos was generated.
info
public final org.apache.lucene.index.SegmentInfo info(int i)
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.
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.
directory
- -- directory containing the segments filesegmentFileName
- -- segment file to load
readCurrentVersion
public static long readCurrentVersion(Directory directory)
throws IOException
Current version number from segments file.
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.
setDefaultGenFileRetryPauseMsec
public static void setDefaultGenFileRetryPauseMsec(int msec)
Advanced: set how many milliseconds to pause in between
attempts to load the segments.gen file.
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.
setInfoStream
public static void setInfoStream(PrintStream infoStream)
If non-null, information about retries when loading
the segments file will be printed to this.
write
public final void write(Directory directory)
throws IOException
Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.