Class BlockWriter

    • Constructor Detail

      • BlockWriter

        protected BlockWriter​(IndexOutput blockOutput,
                              int targetNumBlockLines,
                              int deltaNumLines,
                              BlockEncoder blockEncoder)
    • Method Detail

      • addLine

        protected void addLine​(BytesRef term,
                               BlockTermState blockTermState,
                               IndexDictionary.Builder dictionaryBuilder)
                        throws java.io.IOException
        Adds a new BlockLine term for the current field.

        This method determines whether the new term is part of the current block, or if it is part of the next block. In the latter case, a new block is started (including one or more of the lastly added lines), the current block is written to the block file, and the current block key is added to the IndexDictionary.Builder.

        Parameters:
        term - The block line term. The BytesRef instance is used directly, the caller is responsible to make a deep copy if needed. This is required because we keep a list of block lines until we decide to write the current block, and each line must have a different term instance.
        blockTermState - Block line details.
        dictionaryBuilder - to which the block keys are added.
        Throws:
        java.io.IOException
      • splitAndWriteBlock

        protected void splitAndWriteBlock​(IndexDictionary.Builder dictionaryBuilder)
                                   throws java.io.IOException
        Defines the new block start according to targetNumBlockLines and deltaNumLines. The new block is started (including one or more of the lastly added lines), the current block is written to the block file, and the current block key is added to the IndexDictionary.Builder.
        Throws:
        java.io.IOException
      • writeBlock

        protected void writeBlock​(java.util.List<BlockLine> blockLines,
                                  IndexDictionary.Builder dictionaryBuilder)
                           throws java.io.IOException
        Writes a block and adds its block key to the dictionary builder.
        Throws:
        java.io.IOException
      • updateFieldMetadata

        protected void updateFieldMetadata​(long blockStartFP)
        updates the field metadata after all lines were written for the block.
      • writeBlockLine

        protected void writeBlockLine​(boolean isIncrementalEncodingSeed,
                                      BlockLine line,
                                      BlockLine previousLine)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • addBlockKey

        protected void addBlockKey​(java.util.List<BlockLine> blockLines,
                                   IndexDictionary.Builder dictionaryBuilder)
                            throws java.io.IOException
        Adds a new block key with its corresponding block file pointer to the IndexDictionary.Builder . The block key is the MDP (see TermBytes) of the block first term.
        Throws:
        java.io.IOException