voldemort.store
Class AbstractStorageEngine<K,V,T>

java.lang.Object
  extended by voldemort.store.AbstractStore<K,V,T>
      extended by voldemort.store.AbstractStorageEngine<K,V,T>
All Implemented Interfaces:
StorageEngine<K,V,T>, Store<K,V,T>
Direct Known Subclasses:
BdbStorageEngine, ConfigurationStorageEngine, FileBackedCachingStorageEngine, InMemoryStorageEngine, MetadataStore, MysqlStorageEngine, ReadOnlyStorageEngine, SlopStorageEngine, ViewStorageEngine

public class AbstractStorageEngine<K,V,T>
extends AbstractStore<K,V,T>
implements StorageEngine<K,V,T>


Constructor Summary
AbstractStorageEngine(java.lang.String name)
           
 
Method Summary
 boolean beginBatchModifications()
          A lot of storage engines support efficient methods for performing large number of writes (puts/deletes) against the data source.
 boolean endBatchModifications()
           
 ClosableIterator<Pair<K,Versioned<V>>> entries()
          Get an iterator over pairs of entries in the store.
 ClosableIterator<Pair<K,Versioned<V>>> entries(int partitionId)
          Get an iterator over pairs of entries in a store's partition.
 KeyLockHandle<V> getAndLock(K 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.
 boolean isPartitionAware()
          Are partitions persisted in distinct files? In other words is the data stored on disk on a per-partition basis? This is really for the read-only use case in which each partition is stored in a distinct file.
 boolean isPartitionScanSupported()
          Does the storage engine support efficient scanning of a single partition?
 ClosableIterator<K> keys()
          Get an iterator over keys in the store.
 ClosableIterator<K> keys(int partitionId)
          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.
 java.util.List<Versioned<V>> multiVersionPut(K key, java.util.List<Versioned<V>> values)
          Atomically update storage with the list of versioned values for the given key, to improve storage efficiency.
 void putAndUnlock(K key, KeyLockHandle<V> 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.
 void releaseLock(KeyLockHandle<V> handle)
          Release any lock held by a prior getAndLock(Object) call.
protected  java.util.List<Versioned<V>> resolveAndConstructVersionsToPersist(java.util.List<Versioned<V>> valuesInStorage, java.util.List<Versioned<V>> multiPutValues)
          Computes the final list of versions to be stored, on top of what is currently being stored.
 void truncate()
          Truncate all entries in the store
 
Methods inherited from class voldemort.store.AbstractStore
close, delete, delete, get, get, getAll, getAll, getCapability, getName, getVersions, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface voldemort.store.Store
close, delete, delete, get, get, getAll, getAll, getCapability, getName, getVersions, put, put
 

Constructor Detail

AbstractStorageEngine

public AbstractStorageEngine(java.lang.String name)
Method Detail

entries

public ClosableIterator<Pair<K,Versioned<V>>> entries()
Description copied from interface: StorageEngine
Get an iterator over pairs of entries in the store. 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<K,V,T>
Returns:
An iterator over the entries in this StorageEngine.

keys

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

Specified by:
keys in interface StorageEngine<K,V,T>
Returns:
An iterator over the keys in this StorageEngine.

entries

public ClosableIterator<Pair<K,Versioned<V>>> entries(int partitionId)
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<K,V,T>
Parameters:
partitionId - partition whose entries are to be fetched
Returns:
An iterator over the entries in this StorageEngine.

keys

public ClosableIterator<K> keys(int partitionId)
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<K,V,T>
Parameters:
partitionId - partition whose keys are to be fetched
Returns:
An iterator over the keys in this StorageEngine.

truncate

public void truncate()
Description copied from interface: StorageEngine
Truncate all entries in the store

Specified by:
truncate in interface StorageEngine<K,V,T>

isPartitionAware

public boolean isPartitionAware()
Description copied from interface: StorageEngine
Are partitions persisted in distinct files? In other words is the data stored on disk on a per-partition basis? This is really for the read-only use case in which each partition is stored in a distinct file.

Specified by:
isPartitionAware in interface StorageEngine<K,V,T>
Returns:
Boolean indicating if partitions are persisted in distinct files (read-only use case).

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<K,V,T>
Returns:
true if the storage engine implements the capability. false otherwise

beginBatchModifications

public boolean beginBatchModifications()
Description copied from interface: StorageEngine
A lot of storage engines support efficient methods for performing large number of writes (puts/deletes) against the data source. This method puts the storage engine in this batch write mode

Specified by:
beginBatchModifications in interface StorageEngine<K,V,T>
Returns:
true if the storage engine took successful action to switch to 'batch-write' mode

multiVersionPut

public java.util.List<Versioned<V>> multiVersionPut(K key,
                                                    java.util.List<Versioned<V>> values)
Description copied from interface: StorageEngine
Atomically update storage with the list of versioned values for the given key, to improve storage efficiency.

Specified by:
multiVersionPut in interface StorageEngine<K,V,T>
Parameters:
key - Key to write
values - List of versioned values to be written atomically.
Returns:
list of obsolete versions that were rejected

endBatchModifications

public boolean endBatchModifications()
Specified by:
endBatchModifications in interface StorageEngine<K,V,T>
Returns:
true if the storage engine successfully returned to normal mode

resolveAndConstructVersionsToPersist

protected java.util.List<Versioned<V>> resolveAndConstructVersionsToPersist(java.util.List<Versioned<V>> valuesInStorage,
                                                                            java.util.List<Versioned<V>> multiPutValues)
Computes the final list of versions to be stored, on top of what is currently being stored. Final list is valuesInStorage modified in place

Parameters:
valuesInStorage - list of versions currently in storage
multiPutValues - list of new versions being written to storage
Returns:
list of versions from multiPutVals that were rejected as obsolete

getAndLock

public KeyLockHandle<V> getAndLock(K 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<K,V,T>
Returns:

putAndUnlock

public void putAndUnlock(K key,
                         KeyLockHandle<V> 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<K,V,T>
handle - handle object with new list of versions to be stored

releaseLock

public void releaseLock(KeyLockHandle<V> handle)
Description copied from interface: StorageEngine
Release any lock held by a prior getAndLock(Object) call. Helpful for exception handling during a read-modify-cycle

Specified by:
releaseLock in interface StorageEngine<K,V,T>


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