Class KeyStoreWriter
- All Implemented Interfaces:
Closeable,AutoCloseable
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 Summary
ConstructorsConstructorDescriptionKeyStoreWriter(String componentName, MetadataWriter metadataWriter, org.apache.lucene.store.IndexOutput keysOutput, NumericValuesWriter keysBlockOffsets, int blockShift, boolean clustering) Creates a new writer. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(ByteComparable key) Appends a key at the end of the sequence.voidclose()Flushes any in-memory buffers to the output streams.void
-
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 theKeyLookupMetametadataWriter- theMetadataWriterfor storing theKeyLookupMetakeysOutput- where to write the prefix-compressed keyskeysBlockOffsets- where to write the offsets of each block of keysblockShift- the block shift that is used to determine the block sizeclustering- determines whether the keys will be written as ordered partitions- Throws:
IOException
-
-
Method Details
-
startPartition
public void startPartition() -
add
Appends a key at the end of the sequence.- Throws:
IOException- if write to disk failsIllegalArgumentException- if the key is not greater than the previous added key
-
close
Flushes any in-memory buffers to the output streams. Does not close the output streams. No more writes are allowed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-