Class TermVectorsWriter

    • Constructor Detail

      • TermVectorsWriter

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

      • startDocument

        public abstract void startDocument​(int numVectorFields)
                                    throws 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:
        IOException
      • finishDocument

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

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

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

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

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

        public abstract void finish​(int numDocs)
                             throws 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:
        IOException
      • addProx

        public void addProx​(int numProx,
                            DataInput positions,
                            DataInput offsets)
                     throws 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:
        IOException
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
      • addAllDocVectors

        protected final void addAllDocVectors​(Fields vectors,
                                              MergeState mergeState)
                                       throws IOException
        Safe (but, slowish) default method to write every vector field in the document.
        Throws:
        IOException