voldemort.store.bdb
Class PartitionPrefixedBdbStorageEngine

java.lang.Object
  extended by voldemort.store.AbstractStore<K,V,T>
      extended by voldemort.store.AbstractStorageEngine<ByteArray,byte[],byte[]>
          extended by voldemort.store.bdb.BdbStorageEngine
              extended by voldemort.store.bdb.PartitionPrefixedBdbStorageEngine
All Implemented Interfaces:
NativeBackupable, StorageEngine<ByteArray,byte[],byte[]>, Store<ByteArray,byte[],byte[]>

public class PartitionPrefixedBdbStorageEngine
extends BdbStorageEngine

Extends BDB Storage Engine with capabilities to perform partition range scans, to speed up scan jobs, that filter on partition id


Field Summary
 
Fields inherited from class voldemort.store.bdb.BdbStorageEngine
bdbEnvironmentStats, checkpointerOffForBatchWrites, minimizeScanImpact
 
Constructor Summary
PartitionPrefixedBdbStorageEngine(java.lang.String name, com.sleepycat.je.Environment environment, com.sleepycat.je.Database database, BdbRuntimeConfig config, RoutingStrategy strategy)
           
 
Method Summary
 boolean delete(ByteArray key, Version version)
          Delete all entries prior to the given version
 ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries(int partition)
          Get an iterator over pairs of entries in a store's partition.
 java.util.List<Versioned<byte[]>> get(ByteArray key, byte[] transforms)
          Get the value associated with the given key
 KeyLockHandle<byte[]> getAndLock(ByteArray key)
          Returns the list of versions stored for the key, at the same time locking the key for any writes until StorageEngine.putAndUnlock(Object, KeyLockHandle) or StorageEngine.releaseLock(KeyLockHandle) is called with the same lock handle.
protected  org.apache.log4j.Logger getLogger()
           
 boolean isPartitionScanSupported()
          Does the storage engine support efficient scanning of a single partition?
 ClosableIterator<ByteArray> keys(int partition)
          Get an iterator over keys in the store's partition Note that the iterator need not be threadsafe, and that it must be manually closed after use.
 void put(ByteArray key, Versioned<byte[]> value, byte[] transforms)
          Associate the value with the key and version in this store
 void putAndUnlock(ByteArray key, KeyLockHandle<byte[]> handle)
          Takes the handle issued from a prior StorageEngine.getAndLock(Object) call, and update the key with the set of values provided in the handle, also releasing the lock held on the key.
 
Methods inherited from class voldemort.store.bdb.BdbStorageEngine
beginBatchModifications, close, endBatchModifications, entries, equals, getAll, getBdbDatabase, getBdbEnvironmentStats, getBdbStats, getBdbStats, getStats, getVersions, hashCode, keys, nativeBackup, releaseLock, truncate
 
Methods inherited from class voldemort.store.AbstractStorageEngine
isPartitionAware, multiVersionPut, resolveAndConstructVersionsToPersist
 
Methods inherited from class voldemort.store.AbstractStore
delete, get, getAll, getCapability, getName, put
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface voldemort.store.Store
delete, get, getAll, getCapability, getName, put
 

Constructor Detail

PartitionPrefixedBdbStorageEngine

public PartitionPrefixedBdbStorageEngine(java.lang.String name,
                                         com.sleepycat.je.Environment environment,
                                         com.sleepycat.je.Database database,
                                         BdbRuntimeConfig config,
                                         RoutingStrategy strategy)
Method Detail

entries

public ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries(int partition)
Description copied from interface: StorageEngine
Get an iterator over pairs of entries in a store's partition. The key is the first element in the pair and the versioned value is the second element. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
entries in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
entries in class BdbStorageEngine
Parameters:
partition - partition whose entries are to be fetched
Returns:
An iterator over the entries in this StorageEngine.

keys

public ClosableIterator<ByteArray> keys(int partition)
Description copied from interface: StorageEngine
Get an iterator over keys in the store's partition Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
keys in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
keys in class BdbStorageEngine
Parameters:
partition - partition whose keys are to be fetched
Returns:
An iterator over the keys in this StorageEngine.

get

public java.util.List<Versioned<byte[]>> get(ByteArray key,
                                             byte[] transforms)
                                      throws PersistenceFailureException
Description copied from interface: Store
Get the value associated with the given key

Specified by:
get in interface Store<ByteArray,byte[],byte[]>
Overrides:
get in class BdbStorageEngine
Parameters:
key - The key to check for
Returns:
The value associated with the key or an empty list if no values are found.
Throws:
PersistenceFailureException

put

public void put(ByteArray key,
                Versioned<byte[]> value,
                byte[] transforms)
         throws PersistenceFailureException
Description copied from interface: Store
Associate the value with the key and version in this store

Specified by:
put in interface Store<ByteArray,byte[],byte[]>
Overrides:
put in class BdbStorageEngine
Parameters:
key - The key to use
value - The value to store and its version.
Throws:
PersistenceFailureException

delete

public boolean delete(ByteArray key,
                      Version version)
               throws PersistenceFailureException
Description copied from interface: Store
Delete all entries prior to the given version

Specified by:
delete in interface Store<ByteArray,byte[],byte[]>
Overrides:
delete in class BdbStorageEngine
Parameters:
key - The key to delete
version - The current value of the key
Returns:
True if anything was deleted
Throws:
PersistenceFailureException

getAndLock

public KeyLockHandle<byte[]> getAndLock(ByteArray key)
Description copied from interface: StorageEngine
Returns the list of versions stored for the key, at the same time locking the key for any writes until StorageEngine.putAndUnlock(Object, KeyLockHandle) or StorageEngine.releaseLock(KeyLockHandle) is called with the same lock handle. The idea here is to facilitate custom atomic Read-Modify-Write logic outside the storage engine NOTE : An invocation of getAndLock should be followed by EXACTLY ONE call to either putAndLock or releaseLock, for resources to be freed properly

Specified by:
getAndLock in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
getAndLock in class BdbStorageEngine
Returns:

putAndUnlock

public void putAndUnlock(ByteArray key,
                         KeyLockHandle<byte[]> handle)
Description copied from interface: StorageEngine
Takes the handle issued from a prior StorageEngine.getAndLock(Object) call, and update the key with the set of values provided in the handle, also releasing the lock held on the key.

Specified by:
putAndUnlock in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
putAndUnlock in class BdbStorageEngine
handle - handle object with new list of versions to be stored

getLogger

protected org.apache.log4j.Logger getLogger()
Overrides:
getLogger in class BdbStorageEngine

isPartitionScanSupported

public boolean isPartitionScanSupported()
Description copied from interface: StorageEngine
Does the storage engine support efficient scanning of a single partition?

Specified by:
isPartitionScanSupported in interface StorageEngine<ByteArray,byte[],byte[]>
Overrides:
isPartitionScanSupported in class AbstractStorageEngine<ByteArray,byte[],byte[]>
Returns:
true if the storage engine implements the capability. false otherwise


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu