Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
To put, get or iterate through keys via different schemas, we have to use different key prefixes since we have introduced schema v3 with containerID as prefixes in this feature.
Then we should abstract the key format for db put and get for all three schemas and we could add containerID as key prefix for schema v3.
For example:
The original way as follows, it could not be used to put & get per-disk Rocksdb instance since we don't have the container ID as prefix here:
metadataTable.putWithBatch(batchOperation, CONTAINER_BYTES_USED, getBytesUsed()); // use raw const defined metadataTable.putWithBatch(batchOperation, BLOCK_COUNT, getKeyCount() - deletedBlockCount); metadataTable.putWithBatch(batchOperation, PENDING_DELETE_BLOCK_COUNT, (long)(getNumPendingDeletionBlocks() - deletedBlockCount));
The new way as follows:
metadataTable.putWithBatch(batchOperation, bytesUsedKey(), getBytesUsed()); // use a wrapper helper metadataTable.putWithBatch(batchOperation, blockCountKey(), getKeyCount() - deletedBlockCount); metadataTable.putWithBatch(batchOperation, pendingDeleteBlockCountKey(), (long)(getNumPendingDeletionBlocks() - deletedBlockCount));
So we wrap the schema check and add prefix logic into a helper function above.
These helper function will return a formatted key with prefix for schema v3 and the original const for schema v1 & v2.
NOTE: This will be only be a refactoring patch that return the original values for the keys for schema v1 & v2, after we introduced schema v3,
we'll add logics to return keys with prefixes in future patches.
Attachments
Issue Links
- links to