Class VersionBlockTreeTermsWriter
- java.lang.Object
-
- org.apache.lucene.codecs.FieldsConsumer
-
- org.apache.lucene.codecs.idversion.VersionBlockTreeTermsWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class VersionBlockTreeTermsWriter extends FieldsConsumer
This is just likeBlockTreeTermsWriter, except it also stores a version per term, and adds a method to its TermsEnum implementation to seekExact only if the version is >= the specified version. The version is added to the terms index to avoid seeking if no term in the block has a high enough version. The term blocks file is .tiv and the terms index extension is .tipv.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classVersionBlockTreeTermsWriter.FieldMetaDataprivate static classVersionBlockTreeTermsWriter.PendingBlockprivate static classVersionBlockTreeTermsWriter.PendingEntryprivate static classVersionBlockTreeTermsWriter.PendingTerm(package private) classVersionBlockTreeTermsWriter.TermsWriter
-
Field Summary
Fields Modifier and Type Field Description private booleanclosedstatic intDEFAULT_MAX_BLOCK_SIZESuggested default value for themaxItemsInBlockparameter toVersionBlockTreeTermsWriter(SegmentWriteState,PostingsWriterBase,int,int).static intDEFAULT_MIN_BLOCK_SIZESuggested default value for theminItemsInBlockparameter toVersionBlockTreeTermsWriter(SegmentWriteState,PostingsWriterBase,int,int).(package private) FieldInfosfieldInfosprivate java.util.List<VersionBlockTreeTermsWriter.FieldMetaData>fields(package private) static PairOutputs<BytesRef,java.lang.Long>FST_OUTPUTSprivate IndexOutputindexOut(package private) intmaxDoc(package private) intmaxItemsInBlock(package private) intminItemsInBlock(package private) static PairOutputs.Pair<BytesRef,java.lang.Long>NO_OUTPUTprivate IndexOutputout(package private) static intOUTPUT_FLAG_HAS_TERMS(package private) static intOUTPUT_FLAG_IS_FLOOR(package private) static intOUTPUT_FLAGS_MASK(package private) static intOUTPUT_FLAGS_NUM_BITS(package private) PostingsWriterBasepostingsWriterprivate RAMOutputStreamscratchBytesprivate IntsRefBuilderscratchIntsRefprivate java.lang.Stringsegment(package private) static java.lang.StringTERMS_CODEC_NAME(package private) static java.lang.StringTERMS_EXTENSIONExtension of terms file(package private) static java.lang.StringTERMS_INDEX_CODEC_NAME(package private) static java.lang.StringTERMS_INDEX_EXTENSIONExtension of terms index filestatic intVERSION_CURRENTCurrent terms format.static intVERSION_STARTInitial terms format.
-
Constructor Summary
Constructors Constructor Description VersionBlockTreeTermsWriter(SegmentWriteState state, PostingsWriterBase postingsWriter, int minItemsInBlock, int maxItemsInBlock)Create a new writer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.StringbrToString(byte[] b)(package private) static java.lang.StringbrToString(BytesRef b)voidclose()(package private) static longencodeOutput(long fp, boolean hasTerms, boolean isFloor)voidwrite(Fields fields, NormsProducer norms)Write all fields, terms and postings.private static voidwriteBytesRef(IndexOutput out, BytesRef bytes)private voidwriteIndexTrailer(IndexOutput indexOut, long dirStart)Writes the index file trailer.private voidwriteTrailer(IndexOutput out, long dirStart)Writes the terms file trailer.-
Methods inherited from class org.apache.lucene.codecs.FieldsConsumer
merge
-
-
-
-
Field Detail
-
FST_OUTPUTS
static final PairOutputs<BytesRef,java.lang.Long> FST_OUTPUTS
-
NO_OUTPUT
static final PairOutputs.Pair<BytesRef,java.lang.Long> NO_OUTPUT
-
DEFAULT_MIN_BLOCK_SIZE
public static final int DEFAULT_MIN_BLOCK_SIZE
Suggested default value for theminItemsInBlockparameter toVersionBlockTreeTermsWriter(SegmentWriteState,PostingsWriterBase,int,int).- See Also:
- Constant Field Values
-
DEFAULT_MAX_BLOCK_SIZE
public static final int DEFAULT_MAX_BLOCK_SIZE
Suggested default value for themaxItemsInBlockparameter toVersionBlockTreeTermsWriter(SegmentWriteState,PostingsWriterBase,int,int).- See Also:
- Constant Field Values
-
OUTPUT_FLAGS_NUM_BITS
static final int OUTPUT_FLAGS_NUM_BITS
- See Also:
- Constant Field Values
-
OUTPUT_FLAGS_MASK
static final int OUTPUT_FLAGS_MASK
- See Also:
- Constant Field Values
-
OUTPUT_FLAG_IS_FLOOR
static final int OUTPUT_FLAG_IS_FLOOR
- See Also:
- Constant Field Values
-
OUTPUT_FLAG_HAS_TERMS
static final int OUTPUT_FLAG_HAS_TERMS
- See Also:
- Constant Field Values
-
TERMS_EXTENSION
static final java.lang.String TERMS_EXTENSION
Extension of terms file- See Also:
- Constant Field Values
-
TERMS_CODEC_NAME
static final java.lang.String TERMS_CODEC_NAME
- See Also:
- Constant Field Values
-
VERSION_START
public static final int VERSION_START
Initial terms format.- See Also:
- Constant Field Values
-
VERSION_CURRENT
public static final int VERSION_CURRENT
Current terms format.- See Also:
- Constant Field Values
-
TERMS_INDEX_EXTENSION
static final java.lang.String TERMS_INDEX_EXTENSION
Extension of terms index file- See Also:
- Constant Field Values
-
TERMS_INDEX_CODEC_NAME
static final java.lang.String TERMS_INDEX_CODEC_NAME
- See Also:
- Constant Field Values
-
out
private final IndexOutput out
-
indexOut
private final IndexOutput indexOut
-
maxDoc
final int maxDoc
-
minItemsInBlock
final int minItemsInBlock
-
maxItemsInBlock
final int maxItemsInBlock
-
postingsWriter
final PostingsWriterBase postingsWriter
-
fieldInfos
final FieldInfos fieldInfos
-
fields
private final java.util.List<VersionBlockTreeTermsWriter.FieldMetaData> fields
-
segment
private final java.lang.String segment
-
scratchBytes
private final RAMOutputStream scratchBytes
-
scratchIntsRef
private final IntsRefBuilder scratchIntsRef
-
closed
private boolean closed
-
-
Constructor Detail
-
VersionBlockTreeTermsWriter
public VersionBlockTreeTermsWriter(SegmentWriteState state, PostingsWriterBase postingsWriter, int minItemsInBlock, int maxItemsInBlock) throws java.io.IOException
Create a new writer. The number of items (terms or sub-blocks) per block will aim to be between minItemsPerBlock and maxItemsPerBlock, though in some cases the blocks may be smaller than the min.- Throws:
java.io.IOException
-
-
Method Detail
-
writeTrailer
private void writeTrailer(IndexOutput out, long dirStart) throws java.io.IOException
Writes the terms file trailer.- Throws:
java.io.IOException
-
writeIndexTrailer
private void writeIndexTrailer(IndexOutput indexOut, long dirStart) throws java.io.IOException
Writes the index file trailer.- Throws:
java.io.IOException
-
write
public void write(Fields fields, NormsProducer norms) throws java.io.IOException
Description copied from class:FieldsConsumerWrite all fields, terms and postings. This the "pull" API, allowing you to iterate more than once over the postings, somewhat analogous to using a DOM API to traverse an XML tree.Notes:
- You must compute index statistics, including each Term's docFreq and totalTermFreq, as well as the summary sumTotalTermFreq, sumTotalDocFreq and docCount.
- You must skip terms that have no docs and fields that have no terms, even though the provided Fields API will expose them; this typically requires lazily writing the field or term until you've actually seen the first term or document.
- The provided Fields instance is limited: you cannot call any methods that return statistics/counts; you cannot pass a non-null live docs when pulling docs/positions enums.
- Specified by:
writein classFieldsConsumer- Throws:
java.io.IOException
-
encodeOutput
static long encodeOutput(long fp, boolean hasTerms, boolean isFloor)
-
brToString
static java.lang.String brToString(BytesRef b)
-
brToString
static java.lang.String brToString(byte[] b)
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classFieldsConsumer- Throws:
java.io.IOException
-
writeBytesRef
private static void writeBytesRef(IndexOutput out, BytesRef bytes) throws java.io.IOException
- Throws:
java.io.IOException
-
-