Class KeyStoreWriter

java.lang.Object
org.apache.cassandra.index.sai.disk.v1.keystore.KeyStoreWriter
All Implemented Interfaces:
Closeable, AutoCloseable

@NotThreadSafe public class KeyStoreWriter extends Object implements Closeable
Writes a sequence of partition keys or clustering keys for use with KeyLookup.

Partition keys are written unordered and clustering keys are written in ordered partitions determined by calls to startPartition(). In either case keys can be of varying lengths.

The blockShift field is used to quickly determine the id of the current block based on a point id or to check if we are exactly at the beginning of the block.

Keys are organized in blocks of (2 ^ blockShift) keys.

The blocks should not be too small because they allow prefix compression of the keys except the first key in a block.

The blocks should not be too large because we can't just randomly jump to the key inside the block, but we have to iterate through all the keys from the start of the block.

See Also:
  • Constructor Details

    • KeyStoreWriter

      public KeyStoreWriter(String componentName, MetadataWriter metadataWriter, org.apache.lucene.store.IndexOutput keysOutput, NumericValuesWriter keysBlockOffsets, int blockShift, boolean clustering) throws IOException
      Creates a new writer.

      It does not own the components, so you must close the components by yourself after you're done with the writer.

      Parameters:
      componentName - the component name for the KeyLookupMeta
      metadataWriter - the MetadataWriter for storing the KeyLookupMeta
      keysOutput - where to write the prefix-compressed keys
      keysBlockOffsets - where to write the offsets of each block of keys
      blockShift - the block shift that is used to determine the block size
      clustering - determines whether the keys will be written as ordered partitions
      Throws:
      IOException
  • Method Details