Module org.apache.lucene.codecs
Class SimpleTextTermVectorsWriter
- java.lang.Object
-
- org.apache.lucene.codecs.TermVectorsWriter
-
- org.apache.lucene.codecs.simpletext.SimpleTextTermVectorsWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Accountable
public class SimpleTextTermVectorsWriter extends TermVectorsWriter
Writes plain-text term vectors.FOR RECREATIONAL USE ONLY
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static BytesRef
DOC
(package private) static BytesRef
END
(package private) static BytesRef
ENDOFFSET
(package private) static BytesRef
FIELD
(package private) static BytesRef
FIELDNAME
(package private) static BytesRef
FIELDOFFSETS
(package private) static BytesRef
FIELDPAYLOADS
(package private) static BytesRef
FIELDPOSITIONS
(package private) static BytesRef
FIELDTERMCOUNT
private int
numDocsWritten
(package private) static BytesRef
NUMFIELDS
private boolean
offsets
private IndexOutput
out
(package private) static BytesRef
PAYLOAD
private boolean
payloads
(package private) static BytesRef
POSITION
private boolean
positions
private BytesRefBuilder
scratch
(package private) static BytesRef
STARTOFFSET
(package private) static BytesRef
TERMFREQ
(package private) static BytesRef
TERMTEXT
(package private) static java.lang.String
VECTORS_EXTENSION
-
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
-
Constructor Summary
Constructors Constructor Description SimpleTextTermVectorsWriter(Directory directory, java.lang.String segment, IOContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPosition(int position, int startOffset, int endOffset, BytesRef payload)
Adds a term position and offsetsvoid
close()
void
finish(int numDocs)
Called beforeTermVectorsWriter.close()
, passing in the number of documents that were written.private void
newLine()
long
ramBytesUsed()
Return the memory usage of this object in bytes.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
.private void
write(java.lang.String s)
private void
write(BytesRef bytes)
-
Methods inherited from class org.apache.lucene.codecs.TermVectorsWriter
addAllDocVectors, addProx, finishDocument, finishField, finishTerm, merge
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
-
-
-
Field Detail
-
END
static final BytesRef END
-
DOC
static final BytesRef DOC
-
NUMFIELDS
static final BytesRef NUMFIELDS
-
FIELD
static final BytesRef FIELD
-
FIELDNAME
static final BytesRef FIELDNAME
-
FIELDPOSITIONS
static final BytesRef FIELDPOSITIONS
-
FIELDOFFSETS
static final BytesRef FIELDOFFSETS
-
FIELDPAYLOADS
static final BytesRef FIELDPAYLOADS
-
FIELDTERMCOUNT
static final BytesRef FIELDTERMCOUNT
-
TERMTEXT
static final BytesRef TERMTEXT
-
TERMFREQ
static final BytesRef TERMFREQ
-
POSITION
static final BytesRef POSITION
-
PAYLOAD
static final BytesRef PAYLOAD
-
STARTOFFSET
static final BytesRef STARTOFFSET
-
ENDOFFSET
static final BytesRef ENDOFFSET
-
VECTORS_EXTENSION
static final java.lang.String VECTORS_EXTENSION
- See Also:
- Constant Field Values
-
out
private IndexOutput out
-
numDocsWritten
private int numDocsWritten
-
scratch
private final BytesRefBuilder scratch
-
offsets
private boolean offsets
-
positions
private boolean positions
-
payloads
private boolean payloads
-
-
Method Detail
-
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
-
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
-
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(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
-
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
-
write
private void write(java.lang.String s) throws java.io.IOException
- Throws:
java.io.IOException
-
write
private void write(BytesRef bytes) throws java.io.IOException
- Throws:
java.io.IOException
-
newLine
private void newLine() throws java.io.IOException
- Throws:
java.io.IOException
-
ramBytesUsed
public long ramBytesUsed()
Description copied from interface:Accountable
Return the memory usage of this object in bytes. Negative values are illegal.
-
-