Package com.linkedin.davinci.store
Class AbstractStoragePartition
- java.lang.Object
-
- com.linkedin.davinci.store.AbstractStoragePartition
-
- Direct Known Subclasses:
BlackHoleStorageEnginePartition
,InMemoryStoragePartition
,RocksDBStoragePartition
,VeniceStoreCacheStoragePartition
public abstract class AbstractStoragePartition extends java.lang.Object
An abstract implementation of a storage partition. This could be a database in BDB environment or a concurrent hashmap in the case of an in-memory implementation depending on the storage-partition model.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Integer
partitionId
-
Constructor Summary
Constructors Constructor Description AbstractStoragePartition(java.lang.Integer partitionId)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
beginBatchWrite(java.util.Map<java.lang.String,java.lang.String> checkpointedInfo, java.util.Optional<java.util.function.Supplier<byte[]>> checksumSupplier)
boolean
checkDatabaseIntegrity(java.util.Map<java.lang.String,java.lang.String> checkpointedInfo)
checks whether the current state of the database is valid during the start of ingestion.abstract void
close()
Close the specific partitionabstract void
createSnapshot()
Creates a snapshot of the current state of the storage if the blob transfer feature is enabled via the store configurationabstract void
delete(byte[] key)
Delete a key from the partition databasevoid
deleteWithReplicationMetadata(byte[] key, byte[] metadata)
This API deletes a record from RocksDB but updates the metadata in ByteBuffer format and puts it into RocksDB.abstract void
drop()
Drop when it is not required anymore.void
endBatchWrite()
abstract byte[]
get(byte[] key)
Get a value from the partition databasejava.nio.ByteBuffer
get(byte[] key, java.nio.ByteBuffer valueToBePopulated)
abstract byte[]
get(java.nio.ByteBuffer key)
abstract <K,V>
Vget(K key)
Get a Value from the partition databaseabstract void
getByKeyPrefix(byte[] keyPrefix, BytesStreamingCallback callback)
Populate provided callback with key-value pairs from the partition database where the keys have provided prefix.AbstractStorageIterator
getIterator()
java.lang.Integer
getPartitionId()
returns the id of this partitionabstract long
getPartitionSizeInBytes()
Get the partition database size in bytesbyte[]
getReplicationMetadata(java.nio.ByteBuffer key)
This API retrieves replication metadata from replicationMetadataColumnFamily.long
getRmdByteUsage()
abstract void
put(byte[] key, byte[] value)
Puts a value into the partition databaseabstract void
put(byte[] key, java.nio.ByteBuffer value)
abstract <K,V>
voidput(K key, V value)
void
putReplicationMetadata(byte[] key, byte[] metadata)
void
putWithReplicationMetadata(byte[] key, byte[] value, byte[] metadata)
This API takes in value and metadata as byte array format and put it into RocksDB.void
putWithReplicationMetadata(byte[] key, java.nio.ByteBuffer value, byte[] metadata)
This API takes in value and metadata as ByteBuffer format and put it into RocksDB.void
reopen()
Reopen the database.abstract java.util.Map<java.lang.String,java.lang.String>
sync()
Sync current database.boolean
validateBatchIngestion()
abstract boolean
verifyConfig(StoragePartitionConfig storagePartitionConfig)
Check whether current storage partition verifyConfig the given partition config
-
-
-
Method Detail
-
getPartitionId
public java.lang.Integer getPartitionId()
returns the id of this partition
-
put
public abstract void put(byte[] key, byte[] value)
Puts a value into the partition database
-
put
public abstract void put(byte[] key, java.nio.ByteBuffer value)
-
put
public abstract <K,V> void put(K key, V value)
-
get
public abstract byte[] get(byte[] key)
Get a value from the partition database- Parameters:
key
- key to be retrieved- Returns:
- null if the key does not exist, byte[] value if it exists.
-
get
public java.nio.ByteBuffer get(byte[] key, java.nio.ByteBuffer valueToBePopulated)
-
get
public abstract <K,V> V get(K key)
Get a Value from the partition database- 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
public abstract byte[] get(java.nio.ByteBuffer key)
-
getByKeyPrefix
public abstract void getByKeyPrefix(byte[] keyPrefix, BytesStreamingCallback callback)
Populate 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.- Parameters:
keyPrefix
-callback
-
-
delete
public abstract void delete(byte[] key)
Delete a key from the partition database
-
sync
public abstract java.util.Map<java.lang.String,java.lang.String> sync()
Sync current database.- Returns:
- Database related info, which is required to be checkpointed.
-
drop
public abstract void drop()
Drop when it is not required anymore.
-
close
public abstract void close()
Close the specific partition
-
reopen
public void reopen()
Reopen the database.
-
verifyConfig
public abstract boolean verifyConfig(StoragePartitionConfig storagePartitionConfig)
Check whether current storage partition verifyConfig the given partition config- Parameters:
storagePartitionConfig
-- Returns:
-
createSnapshot
public abstract void createSnapshot()
Creates a snapshot of the current state of the storage if the blob transfer feature is enabled via the store configuration
-
checkDatabaseIntegrity
public boolean checkDatabaseIntegrity(java.util.Map<java.lang.String,java.lang.String> checkpointedInfo)
checks whether the current state of the database is valid during the start of ingestion.
-
beginBatchWrite
public void beginBatchWrite(java.util.Map<java.lang.String,java.lang.String> checkpointedInfo, java.util.Optional<java.util.function.Supplier<byte[]>> checksumSupplier)
-
endBatchWrite
public void endBatchWrite()
-
getPartitionSizeInBytes
public abstract long getPartitionSizeInBytes()
Get the partition database size in bytes- Returns:
- partition database size
-
validateBatchIngestion
public boolean validateBatchIngestion()
-
putWithReplicationMetadata
public void putWithReplicationMetadata(byte[] key, java.nio.ByteBuffer value, byte[] metadata)
This API takes in value and metadata as ByteBuffer format and put it into RocksDB. OnlyReplicationMetadataRocksDBStoragePartition
will execute this method, other storage partition implementation will UnsupportedOperationException.
-
putWithReplicationMetadata
public void putWithReplicationMetadata(byte[] key, byte[] value, byte[] metadata)
This API takes in value and metadata as byte array format and put it into RocksDB. OnlyReplicationMetadataRocksDBStoragePartition
will execute this method, other storage partition implementation will VeniceUnsupportedOperationException.
-
putReplicationMetadata
public void putReplicationMetadata(byte[] key, byte[] metadata)
-
getReplicationMetadata
public byte[] getReplicationMetadata(java.nio.ByteBuffer key)
This API retrieves replication metadata from replicationMetadataColumnFamily. OnlyReplicationMetadataRocksDBStoragePartition
will execute this method, other storage partition implementation will VeniceUnsupportedOperationException.
-
deleteWithReplicationMetadata
public void deleteWithReplicationMetadata(byte[] key, byte[] metadata)
This API deletes a record from RocksDB but updates the metadata in ByteBuffer format and puts it into RocksDB. OnlyReplicationMetadataRocksDBStoragePartition
will execute this method, other storage partition implementation will VeniceUnsupportedOperationException.
-
getRmdByteUsage
public long getRmdByteUsage()
-
getIterator
public AbstractStorageIterator getIterator()
-
-