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 BytesRefDOC(package private) static BytesRefEND(package private) static BytesRefENDOFFSET(package private) static BytesRefFIELD(package private) static BytesRefFIELDNAME(package private) static BytesRefFIELDOFFSETS(package private) static BytesRefFIELDPAYLOADS(package private) static BytesRefFIELDPOSITIONS(package private) static BytesRefFIELDTERMCOUNTprivate intnumDocsWritten(package private) static BytesRefNUMFIELDSprivate booleanoffsetsprivate IndexOutputout(package private) static BytesRefPAYLOADprivate booleanpayloads(package private) static BytesRefPOSITIONprivate booleanpositionsprivate BytesRefBuilderscratch(package private) static BytesRefSTARTOFFSET(package private) static BytesRefTERMFREQ(package private) static BytesRefTERMTEXT(package private) static java.lang.StringVECTORS_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 voidaddPosition(int position, int startOffset, int endOffset, BytesRef payload)Adds a term position and offsetsvoidclose()voidfinish(FieldInfos fis, int numDocs)Called beforeTermVectorsWriter.close(), passing in the number of documents that were written.private voidnewLine()longramBytesUsed()Return the memory usage of this object in bytes.voidstartDocument(int numVectorFields)Called before writing the term vectors of the document.voidstartField(FieldInfo info, int numTerms, boolean positions, boolean offsets, boolean payloads)Called before writing the terms of the field.voidstartTerm(BytesRef term, int freq)Adds a term and its term frequencyfreq.private voidwrite(java.lang.String s)private voidwrite(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.IOExceptionDescription copied from class:TermVectorsWriterCalled before writing the term vectors of the document.TermVectorsWriter.startField(FieldInfo, int, boolean, boolean, boolean)will be callednumVectorFieldstimes. Note that if term vectors are enabled, this is called even if the document has no vector fields, in this casenumVectorFieldswill be zero.- Specified by:
startDocumentin 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:TermVectorsWriterCalled before writing the terms of the field.TermVectorsWriter.startTerm(BytesRef, int)will be callednumTermstimes.- Specified by:
startFieldin classTermVectorsWriter- Throws:
java.io.IOException
-
startTerm
public void startTerm(BytesRef term, int freq) throws java.io.IOException
Description copied from class:TermVectorsWriterAdds a term and its term frequencyfreq. If this field has positions and/or offsets enabled, thenTermVectorsWriter.addPosition(int, int, int, BytesRef)will be calledfreqtimes respectively.- Specified by:
startTermin classTermVectorsWriter- Throws:
java.io.IOException
-
addPosition
public void addPosition(int position, int startOffset, int endOffset, BytesRef payload) throws java.io.IOExceptionDescription copied from class:TermVectorsWriterAdds a term position and offsets- Specified by:
addPositionin classTermVectorsWriter- Throws:
java.io.IOException
-
finish
public void finish(FieldInfos fis, int numDocs) throws java.io.IOException
Description copied from class:TermVectorsWriterCalled 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:
finishin classTermVectorsWriter- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein 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:AccountableReturn the memory usage of this object in bytes. Negative values are illegal.
-
-