Class StoredFieldsWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Accountable
    Direct Known Subclasses:
    Lucene90CompressingStoredFieldsWriter, SimpleTextStoredFieldsWriter

    public abstract class StoredFieldsWriter
    extends java.lang.Object
    implements java.io.Closeable, Accountable
    Codec API for writing stored fields:
    1. For every document, startDocument() is called, informing the Codec that a new document has started.
    2. writeField is called for each field in the document.
    3. After all documents have been written, finish(int) is called for verification/sanity-checks.
    4. Finally the writer is closed (close())
    • Constructor Detail

      • StoredFieldsWriter

        protected StoredFieldsWriter()
        Sole constructor. (For invocation by subclass constructors, typically implicit.)
    • Method Detail

      • startDocument

        public abstract void startDocument()
                                    throws java.io.IOException
        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:
        java.io.IOException
      • finishDocument

        public void finishDocument()
                            throws java.io.IOException
        Called when a document and all its fields have been added.
        Throws:
        java.io.IOException
      • writeField

        public abstract void writeField​(FieldInfo info,
                                        int value)
                                 throws java.io.IOException
        Writes a stored int value.
        Throws:
        java.io.IOException
      • writeField

        public abstract void writeField​(FieldInfo info,
                                        long value)
                                 throws java.io.IOException
        Writes a stored long value.
        Throws:
        java.io.IOException
      • writeField

        public abstract void writeField​(FieldInfo info,
                                        float value)
                                 throws java.io.IOException
        Writes a stored float value.
        Throws:
        java.io.IOException
      • writeField

        public abstract void writeField​(FieldInfo info,
                                        double value)
                                 throws java.io.IOException
        Writes a stored double value.
        Throws:
        java.io.IOException
      • writeField

        public void writeField​(FieldInfo info,
                               DataInput value,
                               int length)
                        throws java.io.IOException
        Writes a stored binary value from a DataInput and a length.
        Throws:
        java.io.IOException
      • writeField

        public abstract void writeField​(FieldInfo info,
                                        BytesRef value)
                                 throws java.io.IOException
        Writes a stored binary value.
        Throws:
        java.io.IOException
      • writeField

        public abstract void writeField​(FieldInfo info,
                                        java.lang.String value)
                                 throws java.io.IOException
        Writes a stored String value.
        Throws:
        java.io.IOException
      • finish

        public abstract void finish​(int numDocs)
                             throws java.io.IOException
        Called before close(), passing in the number of documents that were written. Note that this is intentionally redundant (equivalent to the number of calls to startDocument(), but a Codec should check that this is the case to detect the JRE bug described in LUCENE-1282.
        Throws:
        java.io.IOException
      • merge

        public int merge​(MergeState mergeState)
                  throws java.io.IOException
        Merges in the stored fields from the readers in mergeState. The default implementation skips over deleted documents, and uses startDocument(), writeField, and finish(int), returning the number of documents that were written. Implementations can override this method for more sophisticated merging (bulk-byte copying, etc).
        Throws:
        java.io.IOException
      • close

        public abstract void close()
                            throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException