org.apache.lucene.codecs.uniformsplit.sharedterms

## Class STBlockWriter

- java.lang.Object
- - org.apache.lucene.codecs.uniformsplit.BlockWriter
  - - org.apache.lucene.codecs.uniformsplit.sharedterms.STBlockWriter

    public class STBlockWriter
    extends BlockWriter

Writes terms blocks with the Shared Terms format.

As defined in `STUniformSplitTermsWriter`, all the fields terms are shared in the same dictionary. Each block line contains a term and all the fields `TermState`s for this term.

WARNING: This API is experimental and might change in incompatible ways in the next release.

### Field Summary

Fields
`protected Set<FieldMetadata>` `fieldsInBlock`

### Fields inherited from class org.apache.lucene.codecs.uniformsplit.BlockWriter

`blockEncoder, blockLines, blockLinesWriteBuffer, blockOutput, blockWriteBuffer, deltaNumLines, fieldMetadata, lastTerm, reusableBlockHeader, scratchBytesRef, targetNumBlockLines, termStateSerializer, termStatesWriteBuffer`

### Constructor Summary

Constructors
Constructor and Description
`STBlockWriter(IndexOutput blockOutput, int targetNumBlockLines, int deltaNumLines, BlockEncoder blockEncoder)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addLine(BytesRef term, List<FieldMetadataTermState> termStates, IndexDictionary.Builder dictionaryBuilder)` Adds a new `BlockLine` term for the current field.
`protected void` `finishLastBlock(IndexDictionary.Builder dictionaryBuilder)` This method is called when there is no more term for the field.
`protected void` `updateFieldMetadata(long blockStartFP)` updates the field metadata after all lines were written for the block.
`protected void` `writeBlockLine(boolean isIncrementalEncodingSeed, BlockLine line, BlockLine previousLine)`

### Methods inherited from class org.apache.lucene.codecs.uniformsplit.BlockWriter

`addBlockKey, addLine, splitAndWriteBlock, writeBlock`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### fieldsInBlock

    protected final Set<FieldMetadata> fieldsInBlock

### Constructor Detail

#### STBlockWriter

    public STBlockWriter(IndexOutput blockOutput,
                         int targetNumBlockLines,
                         int deltaNumLines,
                         BlockEncoder blockEncoder)

### Method Detail

#### addLine

    public void addLine(BytesRef term,
                        List<FieldMetadataTermState> termStates,
                        IndexDictionary.Builder dictionaryBuilder)
                 throws 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.
  `termStates` - Block line details for all fields in the line.
  `dictionaryBuilder` - to which the block keys are added.
Throws:
  `IOException`

#### finishLastBlock

    protected void finishLastBlock(IndexDictionary.Builder dictionaryBuilder)
                            throws IOException

Description copied from class: `BlockWriter`
This method is called when there is no more term for the field. It writes the remaining lines added with `BlockWriter.addLine(org.apache.lucene.util.BytesRef, org.apache.lucene.codecs.BlockTermState, org.apache.lucene.codecs.uniformsplit.IndexDictionary.Builder)` as the last block of the field and resets this `BlockWriter` state. Then this `BlockWriter` can be used for another field.

Overrides:
  `finishLastBlock` in class `BlockWriter`
Throws:
  `IOException`

#### writeBlockLine

    protected void writeBlockLine(boolean isIncrementalEncodingSeed,
                                  BlockLine line,
                                  BlockLine previousLine)
                           throws IOException

Overrides:
  `writeBlockLine` in class `BlockWriter`
Throws:
  `IOException`

#### updateFieldMetadata

    protected void updateFieldMetadata(long blockStartFP)

Description copied from class: `BlockWriter`
updates the field metadata after all lines were written for the block.

Overrides:
  `updateFieldMetadata` in class `BlockWriter`