java.lang.Object
org.apache.cassandra.index.sai.disk.v1.keystore.KeyLookup

@NotThreadSafe public class KeyLookup extends Object
Provides read access to an on-disk sequence of partition or clustering keys written by KeyStoreWriter.

Care has been taken to make this structure as efficient as possible. Reading keys does not require allocating data heap buffers per each read operation. Only one key at a time is loaded to memory. Low complexity algorithms are used – a lookup of the key by point id is constant time, and a lookup of the point id by the key is logarithmic.

Because the blocks are prefix compressed, random access applies only to the locating the whole block. In order to jump to a concrete key inside the block, the block keys are iterated from the block beginning.

See Also:
  • Field Details

  • Constructor Details

    • KeyLookup

      public KeyLookup(@Nonnull FileHandle keysFileHandle, @Nonnull FileHandle keysBlockOffsets, @Nonnull KeyLookupMeta keyLookupMeta, @Nonnull NumericValuesMeta keyBlockOffsetsMeta) throws IOException
      Creates a new reader based on its data components.

      It does not own the components, so you must close them separately after you're done with the reader.

      Parameters:
      keysFileHandle - handle to the file with a sequence of prefix-compressed blocks each storing a fixed number of keys
      keysBlockOffsets - handle to the file containing an encoded sequence of the file offsets pointing to the blocks
      keyLookupMeta - metadata object created earlier by the writer
      keyBlockOffsetsMeta - metadata object for the block offsets
      Throws:
      IOException
  • Method Details

    • openCursor

      @Nonnull public KeyLookup.Cursor openCursor() throws IOException
      Opens a cursor over the keys stored in the keys file.

      This will read the first key into the key buffer and point to the first point in the keys file.

      The cursor is to be used in a single thread. The cursor is valid as long this object hasn't been closed. You must close the cursor when you no longer need it.

      Throws:
      IOException