public abstract class TermVectorsWriter extends Object implements Closeable
startDocument(int)
is called,
informing the Codec how many fields will be written.
startField(FieldInfo, int, boolean, boolean, boolean)
is called for
each field in the document, informing the codec how many terms
will be written for that field, and whether or not positions,
offsets, or payloads are enabled.
startTerm(BytesRef, int)
is called
for each term.
addPosition(int, int, int, BytesRef)
will be called for each term
occurrence.
finish(FieldInfos, int)
is called for verification/sanity-checks.
close()
)
Modifier | Constructor and Description |
---|---|
protected |
TermVectorsWriter()
Sole constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAllDocVectors(Fields vectors,
MergeState mergeState)
Safe (but, slowish) default method to write every
vector field in the document.
|
abstract void |
addPosition(int position,
int startOffset,
int endOffset,
BytesRef payload)
Adds a term position and offsets
|
void |
addProx(int numProx,
DataInput positions,
DataInput offsets)
Called by IndexWriter when writing new segments.
|
abstract void |
close() |
abstract void |
finish(FieldInfos fis,
int numDocs)
Called before
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.
|
void |
finishTerm()
Called after a term and all its positions have been added.
|
int |
merge(MergeState mergeState)
Merges in the term vectors from the readers in
mergeState . |
abstract void |
startDocument(int numVectorFields)
Called before writing the term vectors of the document.
|
abstract void |
startField(FieldInfo info,
int numTerms,
boolean positions,
boolean offsets,
boolean payloads)
Called before writing the terms of the field.
|
abstract void |
startTerm(BytesRef term,
int freq)
Adds a term and its term frequency
freq . |
protected TermVectorsWriter()
public abstract void startDocument(int numVectorFields) throws IOException
startField(FieldInfo, int, boolean, boolean, boolean)
will
be called numVectorFields
times. Note that if term
vectors are enabled, this is called even if the document
has no vector fields, in this case numVectorFields
will be zero.IOException
public void finishDocument() throws IOException
IOException
public abstract void startField(FieldInfo info, int numTerms, boolean positions, boolean offsets, boolean payloads) throws IOException
startTerm(BytesRef, int)
will be called numTerms
times.IOException
public void finishField() throws IOException
IOException
public abstract void startTerm(BytesRef term, int freq) throws IOException
freq
.
If this field has positions and/or offsets enabled, then
addPosition(int, int, int, BytesRef)
will be called
freq
times respectively.IOException
public void finishTerm() throws IOException
IOException
public abstract void addPosition(int position, int startOffset, int endOffset, BytesRef payload) throws IOException
IOException
public abstract void finish(FieldInfos fis, int numDocs) throws IOException
close()
, passing in the number
of documents that were written. Note that this is
intentionally redundant (equivalent to the number of
calls to startDocument(int)
, but a Codec should
check that this is the case to detect the JRE bug described
in LUCENE-1282.IOException
public void addProx(int numProx, DataInput positions, DataInput offsets) throws IOException
This is an expert API that allows the codec to consume positions and offsets directly from the indexer.
The default implementation calls 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!!!
IOException
public int merge(MergeState mergeState) throws IOException
mergeState
. The default implementation skips
over deleted documents, and uses startDocument(int)
,
startField(FieldInfo, int, boolean, boolean, boolean)
,
startTerm(BytesRef, int)
, addPosition(int, int, int, BytesRef)
,
and finish(FieldInfos, int)
,
returning the number of documents that were written.
Implementations can override this method for more sophisticated
merging (bulk-byte copying, etc).IOException
protected final void addAllDocVectors(Fields vectors, MergeState mergeState) throws IOException
IOException
public abstract void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.