Class CompressingTermVectorsWriter

    • Constructor Detail

      • CompressingTermVectorsWriter

        public CompressingTermVectorsWriter​(Directory directory,
                                            SegmentInfo si,
                                            java.lang.String segmentSuffix,
                                            IOContext context,
                                            java.lang.String formatName,
                                            CompressionMode compressionMode,
                                            int chunkSize,
                                            int blockShift)
                                     throws java.io.IOException
        Sole constructor.
        Throws:
        java.io.IOException
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class TermVectorsWriter
        Throws:
        java.io.IOException
      • finishDocument

        public void finishDocument()
                            throws java.io.IOException
        Description copied from class: TermVectorsWriter
        Called after a doc and all its fields have been added.
        Overrides:
        finishDocument in class TermVectorsWriter
        Throws:
        java.io.IOException
      • finishField

        public void finishField()
                         throws java.io.IOException
        Description copied from class: TermVectorsWriter
        Called after a field and all its terms have been added.
        Overrides:
        finishField in class TermVectorsWriter
        Throws:
        java.io.IOException
      • addPosition

        public void addPosition​(int position,
                                int startOffset,
                                int endOffset,
                                BytesRef payload)
                         throws java.io.IOException
        Description copied from class: TermVectorsWriter
        Adds a term position and offsets
        Specified by:
        addPosition in class TermVectorsWriter
        Throws:
        java.io.IOException
      • triggerFlush

        private boolean triggerFlush()
      • flush

        private void flush()
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • flushNumFields

        private int flushNumFields​(int chunkDocs)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • flushFieldNums

        private int[] flushFieldNums()
                              throws java.io.IOException
        Returns a sorted array containing unique field numbers
        Throws:
        java.io.IOException
      • flushFields

        private void flushFields​(int totalFields,
                                 int[] fieldNums)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • flushFlags

        private void flushFlags​(int totalFields,
                                int[] fieldNums)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • flushNumTerms

        private void flushNumTerms​(int totalFields)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • flushTermLengths

        private void flushTermLengths()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • flushTermFreqs

        private void flushTermFreqs()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • flushPositions

        private void flushPositions()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • flushOffsets

        private void flushOffsets​(int[] fieldNums)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • flushPayloadLengths

        private void flushPayloadLengths()
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • addProx

        public void addProx​(int numProx,
                            DataInput positions,
                            DataInput offsets)
                     throws java.io.IOException
        Description copied from class: TermVectorsWriter
        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 TermVectorsWriter.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!!!

        Overrides:
        addProx in class TermVectorsWriter
        Throws:
        java.io.IOException
      • tooDirty

        boolean tooDirty​(CompressingTermVectorsReader candidate)
        Returns true if we should recompress this reader, even though we could bulk merge compressed data

        The last chunk written for a segment is typically incomplete, so without recompressing, in some worst-case situations (e.g. frequent reopen with tiny flushes), over time the compression ratio can degrade. This is a safety switch.