Class VersionBlockTreeTermsWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public final class VersionBlockTreeTermsWriter
    extends FieldsConsumer
    This is just like Lucene90BlockTreeTermsWriter, except it also stores a version per term, and adds a method to its TermsEnum implementation to seekExact only if the version is >= the specified version. The version is added to the terms index to avoid seeking if no term in the block has a high enough version. The term blocks file is .tiv and the terms index extension is .tipv.
    • Constructor Detail

      • VersionBlockTreeTermsWriter

        public VersionBlockTreeTermsWriter​(SegmentWriteState state,
                                           PostingsWriterBase postingsWriter,
                                           int minItemsInBlock,
                                           int maxItemsInBlock)
                                    throws java.io.IOException
        Create a new writer. The number of items (terms or sub-blocks) per block will aim to be between minItemsPerBlock and maxItemsPerBlock, though in some cases the blocks may be smaller than the min.
        Throws:
        java.io.IOException
    • Method Detail

      • writeTrailer

        private void writeTrailer​(IndexOutput out,
                                  long dirStart)
                           throws java.io.IOException
        Writes the terms file trailer.
        Throws:
        java.io.IOException
      • writeIndexTrailer

        private void writeIndexTrailer​(IndexOutput indexOut,
                                       long dirStart)
                                throws java.io.IOException
        Writes the index file trailer.
        Throws:
        java.io.IOException
      • write

        public void write​(Fields fields,
                          NormsProducer norms)
                   throws java.io.IOException
        Description copied from class: FieldsConsumer
        Write all fields, terms and postings. This the "pull" API, allowing you to iterate more than once over the postings, somewhat analogous to using a DOM API to traverse an XML tree.

        Notes:

        • You must compute index statistics, including each Term's docFreq and totalTermFreq, as well as the summary sumTotalTermFreq, sumTotalDocFreq and docCount.
        • You must skip terms that have no docs and fields that have no terms, even though the provided Fields API will expose them; this typically requires lazily writing the field or term until you've actually seen the first term or document.
        • The provided Fields instance is limited: you cannot call any methods that return statistics/counts; you cannot pass a non-null live docs when pulling docs/positions enums.
        Specified by:
        write in class FieldsConsumer
        Throws:
        java.io.IOException
      • encodeOutput

        static long encodeOutput​(long fp,
                                 boolean hasTerms,
                                 boolean isFloor)
      • brToString

        static java.lang.String brToString​(BytesRef b)
      • brToString

        static java.lang.String brToString​(byte[] b)
      • 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 FieldsConsumer
        Throws:
        java.io.IOException
      • writeBytesRef

        private static void writeBytesRef​(IndexOutput out,
                                          BytesRef bytes)
                                   throws java.io.IOException
        Throws:
        java.io.IOException