Class TermVectorsWriter

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void abort()
      Aborts writing entirely, implementation should remove any partially-written files, etc.
      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.
      abstract java.util.Comparator<BytesRef> getComparator()
      Return the BytesRef Comparator used to sort terms before feeding to this API.
      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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • startDocument

        public abstract void startDocument​(int numVectorFields)
                                    throws java.io.IOException
        Called before writing the term vectors of the document. 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.
        Throws:
        java.io.IOException
      • finishDocument

        public void finishDocument()
                            throws java.io.IOException
        Called after a doc and all its fields have been added.
        Throws:
        java.io.IOException
      • startField

        public abstract void startField​(FieldInfo info,
                                        int numTerms,
                                        boolean positions,
                                        boolean offsets,
                                        boolean payloads)
                                 throws java.io.IOException
        Called before writing the terms of the field. startTerm(BytesRef, int) will be called numTerms times.
        Throws:
        java.io.IOException
      • finishField

        public void finishField()
                         throws java.io.IOException
        Called after a field and all its terms have been added.
        Throws:
        java.io.IOException
      • startTerm

        public abstract void startTerm​(BytesRef term,
                                       int freq)
                                throws java.io.IOException
        Adds a term and its term frequency freq. If this field has positions and/or offsets enabled, then addPosition(int, int, int, BytesRef) will be called freq times respectively.
        Throws:
        java.io.IOException
      • finishTerm

        public void finishTerm()
                        throws java.io.IOException
        Called after a term and all its positions have been added.
        Throws:
        java.io.IOException
      • addPosition

        public abstract void addPosition​(int position,
                                         int startOffset,
                                         int endOffset,
                                         BytesRef payload)
                                  throws java.io.IOException
        Adds a term position and offsets
        Throws:
        java.io.IOException
      • abort

        public abstract void abort()
        Aborts writing entirely, implementation should remove any partially-written files, etc.
      • finish

        public abstract void finish​(FieldInfos fis,
                                    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(int), but a Codec should check that this is the case to detect the JRE bug described in LUCENE-1282.
        Throws:
        java.io.IOException
      • addProx

        public void addProx​(int numProx,
                            DataInput positions,
                            DataInput offsets)
                     throws java.io.IOException
        Called by IndexWriter when writing new segments.

        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!!!

        Throws:
        java.io.IOException
      • getComparator

        public abstract java.util.Comparator<BytesRef> getComparator()
                                                              throws java.io.IOException
        Return the BytesRef Comparator used to sort terms before feeding to this API.
        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