Class InMemoryStoragePartition
java.lang.Object
com.linkedin.davinci.store.AbstractStoragePartition
com.linkedin.davinci.store.memory.InMemoryStoragePartition
An in-memory hashmap implementation of a storage partition
Assumptions:
1.No need to worry about synchronizing write/deletes as the model is based on a single writer.
So all updates are already serialized.
2. Concurrent reads may be stale if writes/deletes are going on. But the consistency model is also designed to be eventual.
Since "read your own writes semantics" is not guaranteed this eventual consistency is tolerable.
Even though there will be one writer and 1 or more readers, we may still need a concurrentHashMap to avoid
ConcurrentModicfictionException thrown from the iterators
-
Field Summary
Fields inherited from class com.linkedin.davinci.store.AbstractStoragePartition
partitionId -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCleans up the snapshotvoidclose()Close the specific partitionvoidCreates a snapshot of the current state of the storage if the blob transfer feature is enabled via the store configurationvoiddelete(byte[] key) Delete a key from the partition databasevoiddrop()Drop when it is not required anymore.byte[]get(byte[] key) Get a value from the partition databasebyte[]get(ByteBuffer key) <K,V> V get(K key) Get a Value from the partition databasevoidgetByKeyPrefix(byte[] keyPrefix, BytesStreamingCallback callback) Populate provided callback with key-value pairs from the partition database where the keys have provided prefix.longGet the partition database size in bytesvoidput(byte[] key, byte[] value) Puts a value into the partition databasevoidput(byte[] key, ByteBuffer valueBuffer) <K,V> void put(K key, V value) sync()Sync current database.booleanverifyConfig(StoragePartitionConfig storagePartitionConfig) Check whether current storage partition verifyConfig the given partition configMethods inherited from class com.linkedin.davinci.store.AbstractStoragePartition
beginBatchWrite, checkDatabaseIntegrity, deleteWithReplicationMetadata, endBatchWrite, get, getIterator, getPartitionId, getReplicationMetadata, getRmdByteUsage, putReplicationMetadata, putWithReplicationMetadata, putWithReplicationMetadata, reopen, validateBatchIngestion
-
Constructor Details
-
InMemoryStoragePartition
-
-
Method Details
-
put
public void put(byte[] key, byte[] value) Description copied from class:AbstractStoragePartitionPuts a value into the partition database- Specified by:
putin classAbstractStoragePartition
-
put
- Specified by:
putin classAbstractStoragePartition
-
put
public <K,V> void put(K key, V value) - Specified by:
putin classAbstractStoragePartition
-
get
Description copied from class:AbstractStoragePartitionGet a value from the partition database- Specified by:
getin classAbstractStoragePartition- Parameters:
key- key to be retrieved- Returns:
- null if the key does not exist, byte[] value if it exists.
- Throws:
PersistenceFailureException
-
get
public <K,V> V get(K key) Description copied from class:AbstractStoragePartitionGet a Value from the partition database- Specified by:
getin classAbstractStoragePartition- Type Parameters:
K- the type for KeyV- the type for the return value- Parameters:
key- key to be retrieved- Returns:
- null if the key does not exist, V value if it exists
-
get
- Specified by:
getin classAbstractStoragePartition
-
getByKeyPrefix
Description copied from class:AbstractStoragePartitionPopulate provided callback with key-value pairs from the partition database where the keys have provided prefix. If prefix is null, callback will be populated will all key-value pairs from the partition database.- Specified by:
getByKeyPrefixin classAbstractStoragePartition
-
delete
public void delete(byte[] key) Description copied from class:AbstractStoragePartitionDelete a key from the partition database- Specified by:
deletein classAbstractStoragePartition
-
sync
Description copied from class:AbstractStoragePartitionSync current database.- Specified by:
syncin classAbstractStoragePartition- Returns:
- Database related info, which is required to be checkpointed.
-
drop
public void drop()Description copied from class:AbstractStoragePartitionDrop when it is not required anymore.- Specified by:
dropin classAbstractStoragePartition
-
close
public void close()Description copied from class:AbstractStoragePartitionClose the specific partition- Specified by:
closein classAbstractStoragePartition
-
verifyConfig
Description copied from class:AbstractStoragePartitionCheck whether current storage partition verifyConfig the given partition config- Specified by:
verifyConfigin classAbstractStoragePartition- Returns:
-
getPartitionSizeInBytes
public long getPartitionSizeInBytes()Description copied from class:AbstractStoragePartitionGet the partition database size in bytes- Specified by:
getPartitionSizeInBytesin classAbstractStoragePartition- Returns:
- partition database size
-
createSnapshot
public void createSnapshot()Description copied from class:AbstractStoragePartitionCreates a snapshot of the current state of the storage if the blob transfer feature is enabled via the store configuration- Specified by:
createSnapshotin classAbstractStoragePartition
-
cleanupSnapshot
public void cleanupSnapshot()Description copied from class:AbstractStoragePartitionCleans up the snapshot- Specified by:
cleanupSnapshotin classAbstractStoragePartition
-