Package org.apache.lucene.codecs
Class StoredFieldsWriter
java.lang.Object
org.apache.lucene.codecs.StoredFieldsWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Accountable
- Direct Known Subclasses:
Lucene90CompressingStoredFieldsWriter
Codec API for writing stored fields:
- For every document,
startDocument()
is called, informing the Codec that a new document has started. writeField
is called for each field in the document.- After all documents have been written,
finish(int)
is called for verification/sanity-checks. - Finally the writer is closed (
close()
)
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
A visitor that adds every field it sees. -
Field Summary
Fields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
abstract void
finish
(int numDocs) Called beforeclose()
, passing in the number of documents that were written.void
Called when a document and all its fields have been added.int
merge
(MergeState mergeState) Merges in the stored fields from the readers inmergeState
.abstract void
Called before writing the stored fields of the document.abstract void
writeField
(FieldInfo info, double value) Writes a stored double value.abstract void
writeField
(FieldInfo info, float value) Writes a stored float value.abstract void
writeField
(FieldInfo info, int value) Writes a stored int value.abstract void
writeField
(FieldInfo info, long value) Writes a stored long value.abstract void
writeField
(FieldInfo info, String value) Writes a stored String value.void
writeField
(FieldInfo info, DataInput value, int length) Writes a stored binary value from aDataInput
and alength
.abstract void
writeField
(FieldInfo info, BytesRef value) Writes a stored binary value.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, ramBytesUsed
-
Constructor Details
-
StoredFieldsWriter
protected StoredFieldsWriter()Sole constructor. (For invocation by subclass constructors, typically implicit.)
-
-
Method Details
-
startDocument
Called before writing the stored fields of the document.writeField
will be called for each stored field. Note that this is called even if the document has no stored fields.- Throws:
IOException
-
finishDocument
Called when a document and all its fields have been added.- Throws:
IOException
-
writeField
Writes a stored int value.- Throws:
IOException
-
writeField
Writes a stored long value.- Throws:
IOException
-
writeField
Writes a stored float value.- Throws:
IOException
-
writeField
Writes a stored double value.- Throws:
IOException
-
writeField
Writes a stored binary value from aDataInput
and alength
.- Throws:
IOException
-
writeField
Writes a stored binary value.- Throws:
IOException
-
writeField
Writes a stored String value.- Throws:
IOException
-
finish
Called beforeclose()
, passing in the number of documents that were written. Note that this is intentionally redundant (equivalent to the number of calls tostartDocument()
, but a Codec should check that this is the case to detect the JRE bug described in LUCENE-1282.- Throws:
IOException
-
merge
Merges in the stored fields from the readers inmergeState
. The default implementation skips over deleted documents, and usesstartDocument()
,writeField
, andfinish(int)
, returning the number of documents that were written. Implementations can override this method for more sophisticated merging (bulk-byte copying, etc).- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-