Class CompressingTermVectorsWriter
- java.lang.Object
-
- org.apache.lucene.codecs.TermVectorsWriter
-
- org.apache.lucene.codecs.compressing.CompressingTermVectorsWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class CompressingTermVectorsWriter extends TermVectorsWriter
-
-
Constructor Summary
Constructors Constructor Description CompressingTermVectorsWriter(Directory directory, SegmentInfo si, java.lang.String segmentSuffix, IOContext context, java.lang.String formatName, CompressionMode compressionMode, int chunkSize)
Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Aborts writing entirely, implementation should remove any partially-written files, etc.void
addPosition(int position, int startOffset, int endOffset, BytesRef payload)
Adds a term position and offsetsvoid
addProx(int numProx, DataInput positions, DataInput offsets)
Called by IndexWriter when writing new segments.void
close()
void
finish(FieldInfos fis, int numDocs)
Called beforeTermVectorsWriter.close()
, passing in the number of documents that were written.void
finishDocument()
Called after a doc and all its fields have been added.void
finishField()
Called after a field and all its terms have been added.java.util.Comparator<BytesRef>
getComparator()
Return the BytesRef Comparator used to sort terms before feeding to this API.int
merge(MergeState mergeState)
Merges in the term vectors from the readers inmergeState
.void
startDocument(int numVectorFields)
Called before writing the term vectors of the document.void
startField(FieldInfo info, int numTerms, boolean positions, boolean offsets, boolean payloads)
Called before writing the terms of the field.void
startTerm(BytesRef term, int freq)
Adds a term and its term frequencyfreq
.-
Methods inherited from class org.apache.lucene.codecs.TermVectorsWriter
finishTerm
-
-
-
-
Constructor Detail
-
CompressingTermVectorsWriter
public CompressingTermVectorsWriter(Directory directory, SegmentInfo si, java.lang.String segmentSuffix, IOContext context, java.lang.String formatName, CompressionMode compressionMode, int chunkSize) throws java.io.IOException
Sole constructor.- Throws:
java.io.IOException
-
-
Method Detail
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in classTermVectorsWriter
- Throws:
java.io.IOException
-
abort
public void abort()
Description copied from class:TermVectorsWriter
Aborts writing entirely, implementation should remove any partially-written files, etc.- Specified by:
abort
in classTermVectorsWriter
-
startDocument
public void startDocument(int numVectorFields) throws java.io.IOException
Description copied from class:TermVectorsWriter
Called before writing the term vectors of the document.TermVectorsWriter.startField(FieldInfo, int, boolean, boolean, boolean)
will be callednumVectorFields
times. Note that if term vectors are enabled, this is called even if the document has no vector fields, in this casenumVectorFields
will be zero.- Specified by:
startDocument
in classTermVectorsWriter
- Throws:
java.io.IOException
-
finishDocument
public void finishDocument() throws java.io.IOException
Description copied from class:TermVectorsWriter
Called after a doc and all its fields have been added.- Overrides:
finishDocument
in classTermVectorsWriter
- Throws:
java.io.IOException
-
startField
public void startField(FieldInfo info, int numTerms, boolean positions, boolean offsets, boolean payloads) throws java.io.IOException
Description copied from class:TermVectorsWriter
Called before writing the terms of the field.TermVectorsWriter.startTerm(BytesRef, int)
will be callednumTerms
times.- Specified by:
startField
in classTermVectorsWriter
- Throws:
java.io.IOException
-
finishField
public void finishField() throws java.io.IOException
Description copied from class:TermVectorsWriter
Called after a field and all its terms have been added.- Overrides:
finishField
in classTermVectorsWriter
- Throws:
java.io.IOException
-
startTerm
public void startTerm(BytesRef term, int freq) throws java.io.IOException
Description copied from class:TermVectorsWriter
Adds a term and its term frequencyfreq
. If this field has positions and/or offsets enabled, thenTermVectorsWriter.addPosition(int, int, int, BytesRef)
will be calledfreq
times respectively.- Specified by:
startTerm
in classTermVectorsWriter
- Throws:
java.io.IOException
-
addPosition
public void addPosition(int position, int startOffset, int endOffset, BytesRef payload) throws java.io.IOException
Description copied from class:TermVectorsWriter
Adds a term position and offsets- Specified by:
addPosition
in classTermVectorsWriter
- Throws:
java.io.IOException
-
finish
public void finish(FieldInfos fis, int numDocs) throws java.io.IOException
Description copied from class:TermVectorsWriter
Called beforeTermVectorsWriter.close()
, passing in the number of documents that were written. Note that this is intentionally redundant (equivalent to the number of calls toTermVectorsWriter.startDocument(int)
, but a Codec should check that this is the case to detect the JRE bug described in LUCENE-1282.- Specified by:
finish
in classTermVectorsWriter
- Throws:
java.io.IOException
-
getComparator
public java.util.Comparator<BytesRef> getComparator()
Description copied from class:TermVectorsWriter
Return the BytesRef Comparator used to sort terms before feeding to this API.- Specified by:
getComparator
in classTermVectorsWriter
-
addProx
public void addProx(int numProx, DataInput positions, DataInput offsets) throws java.io.IOException
Description copied from class:TermVectorsWriter
Called by IndexWriter when writing new segments.This is an expert API that allows the codec to consume positions and offsets directly from the indexer.
The default implementation calls
TermVectorsWriter.addPosition(int, int, int, BytesRef)
, but subclasses can override this if they want to efficiently write all the positions, then all the offsets, for example.NOTE: This API is extremely expert and subject to change or removal!!!
- Overrides:
addProx
in classTermVectorsWriter
- Throws:
java.io.IOException
-
merge
public int merge(MergeState mergeState) throws java.io.IOException
Description copied from class:TermVectorsWriter
Merges in the term vectors from the readers inmergeState
. The default implementation skips over deleted documents, and usesTermVectorsWriter.startDocument(int)
,TermVectorsWriter.startField(FieldInfo, int, boolean, boolean, boolean)
,TermVectorsWriter.startTerm(BytesRef, int)
,TermVectorsWriter.addPosition(int, int, int, BytesRef)
, andTermVectorsWriter.finish(FieldInfos, int)
, returning the number of documents that were written. Implementations can override this method for more sophisticated merging (bulk-byte copying, etc).- Overrides:
merge
in classTermVectorsWriter
- Throws:
java.io.IOException
-
-