voldemort.store
Class StoreUtils

java.lang.Object
  extended by voldemort.store.StoreUtils

public class StoreUtils
extends java.lang.Object

Group of store utilities


Constructor Summary
StoreUtils()
           
 
Method Summary
static
<K> void
assertValidKey(K key)
           
static void assertValidKeys(java.lang.Iterable<?> keys)
           
static void assertValidMetadata(ByteArray key, RoutingStrategy routingStrategy, Node currentNode)
          Check if the current node is part of routing request based on cluster.xml or throw an exception.
static void close(java.io.Closeable c)
          Closes a Closeable and logs a potential error instead of re-throwing the exception.
static
<K,V,T> java.util.List<Versioned<V>>
get(Store<K,V,T> storageEngine, K key, T transform)
          Implements get by delegating to getAll.
static
<K,V,T> java.util.Map<K,java.util.List<Versioned<V>>>
getAll(Store<K,V,T> storageEngine, java.lang.Iterable<K> keys, java.util.Map<K,T> transforms)
          Implements getAll by delegating to get.
static StoreDefinition getStoreDef(java.util.List<StoreDefinition> list, java.lang.String name)
          Get a store definition from the given list of store definitions
static java.util.HashMap<java.lang.String,StoreDefinition> getStoreDefsAsMap(java.util.List<StoreDefinition> storeDefs)
           
static java.util.List<java.lang.String> getStoreNames(java.util.List<StoreDefinition> list, boolean ignoreViews)
          Get the list of store names from a list of store definitions
static
<V> java.util.List<Version>
getVersions(java.util.List<Versioned<V>> versioneds)
           
static
<K,V> ClosableIterator<K>
keys(ClosableIterator<Pair<K,V>> values)
           
static
<K,V> java.util.HashMap<K,V>
newEmptyHashMap(java.lang.Iterable<?> iterable)
          Returns an empty map with expected size matching the iterable size if it's of type Collection.
static
<T> Serializer<T>
unsafeGetSerializer(SerializerFactory serializerFactory, SerializerDefinition serializerDefinition)
          This is a temporary measure until we have a type-safe solution for retrieving serializers from a SerializerFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StoreUtils

public StoreUtils()
Method Detail

assertValidKeys

public static void assertValidKeys(java.lang.Iterable<?> keys)

assertValidKey

public static <K> void assertValidKey(K key)

get

public static <K,V,T> java.util.List<Versioned<V>> get(Store<K,V,T> storageEngine,
                                                       K key,
                                                       T transform)
Implements get by delegating to getAll.


getAll

public static <K,V,T> java.util.Map<K,java.util.List<Versioned<V>>> getAll(Store<K,V,T> storageEngine,
                                                                           java.lang.Iterable<K> keys,
                                                                           java.util.Map<K,T> transforms)
Implements getAll by delegating to get.


newEmptyHashMap

public static <K,V> java.util.HashMap<K,V> newEmptyHashMap(java.lang.Iterable<?> iterable)
Returns an empty map with expected size matching the iterable size if it's of type Collection. Otherwise, an empty map with the default size is returned.


close

public static void close(java.io.Closeable c)
Closes a Closeable and logs a potential error instead of re-throwing the exception. If null is passed, this method is a no-op. This is typically used in finally blocks to prevent an exception thrown during close from hiding an exception thrown inside the try.

Parameters:
c - The Closeable to close, may be null.

assertValidMetadata

public static void assertValidMetadata(ByteArray key,
                                       RoutingStrategy routingStrategy,
                                       Node currentNode)
Check if the current node is part of routing request based on cluster.xml or throw an exception.

Parameters:
key - The key we are checking
routingStrategy - The routing strategy
currentNode - Current node

getVersions

public static <V> java.util.List<Version> getVersions(java.util.List<Versioned<V>> versioneds)

keys

public static <K,V> ClosableIterator<K> keys(ClosableIterator<Pair<K,V>> values)

unsafeGetSerializer

public static <T> Serializer<T> unsafeGetSerializer(SerializerFactory serializerFactory,
                                                    SerializerDefinition serializerDefinition)
This is a temporary measure until we have a type-safe solution for retrieving serializers from a SerializerFactory. It avoids warnings all over the codebase while making it easy to verify who calls it.


getStoreDef

public static StoreDefinition getStoreDef(java.util.List<StoreDefinition> list,
                                          java.lang.String name)
Get a store definition from the given list of store definitions

Parameters:
list - A list of store definitions
name - The name of the store
Returns:
The store definition

getStoreNames

public static java.util.List<java.lang.String> getStoreNames(java.util.List<StoreDefinition> list,
                                                             boolean ignoreViews)
Get the list of store names from a list of store definitions

Parameters:
list -
ignoreViews -
Returns:
list of store names

getStoreDefsAsMap

public static java.util.HashMap<java.lang.String,StoreDefinition> getStoreDefsAsMap(java.util.List<StoreDefinition> storeDefs)


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