org.apache.gora.store
Class DataStoreFactory

java.lang.Object
  extended by org.apache.gora.store.DataStoreFactory

public class DataStoreFactory
extends Object

A Factory for DataStores. DataStoreFactory instances are thread-safe.


Field Summary
static String AUTO_CREATE_SCHEMA
           
static String DATASTORE
           
static String GORA
           
static String GORA_DEFAULT_DATASTORE_KEY
           
static String GORA_DEFAULT_PROPERTIES_FILE
           
static String INPUT_PATH
           
static org.apache.commons.logging.Log log
           
static String MAPPING_FILE
           
static String OUTPUT_PATH
           
static Properties properties
          Deprecated. 
static String SCHEMA_NAME
           
 
Method Summary
static
<D extends DataStore<K,T>,K,T extends Persistent>
D
createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf)
          Instantiate a new DataStore.
static
<D extends DataStore<K,T>,K,T extends Persistent>
D
createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf, Properties properties)
          Instantiate a new DataStore.
static
<D extends DataStore<K,T>,K,T extends Persistent>
D
createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf, Properties properties, String schemaName)
          Instantiate a new DataStore.
static
<D extends DataStore<K,T>,K,T extends Persistent>
D
createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf, String schemaName)
          Instantiate a new DataStore.
static Properties createProps()
          Creates a new Properties.
static boolean findBooleanProperty(Properties properties, DataStore<?,?> store, String baseKey, String defaultValue)
           
static String findProperty(Properties properties, DataStore<?,?> store, String baseKey, String defaultValue)
          Tries to find a property with the given baseKey.
static String findPropertyOrDie(Properties properties, DataStore<?,?> store, String baseKey)
          Tries to find a property with the given baseKey.
static boolean getAutoCreateSchema(Properties properties, DataStore<?,?> store)
           
static
<D extends DataStore<K,T>,K,T extends Persistent>
D
getDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistentClass, org.apache.hadoop.conf.Configuration conf)
          Instantiate a new DataStore.
static
<K,T extends Persistent>
DataStore<K,T>
getDataStore(Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf)
          Instantiate the default DataStore.
static
<K,T extends Persistent>
DataStore<K,T>
getDataStore(String dataStoreClass, Class<K> keyClass, Class<T> persistentClass, org.apache.hadoop.conf.Configuration conf)
          Instantiate a new DataStore.
static
<K,T extends Persistent>
DataStore<K,T>
getDataStore(String dataStoreClass, String keyClass, String persistentClass, org.apache.hadoop.conf.Configuration conf)
          Instantiate a new DataStore.
static String getDefaultSchemaName(Properties properties, DataStore<?,?> store)
          Gets the default schema name of a given store class
static String getInputPath(Properties properties, DataStore<?,?> store)
          Returns the input path as read from the properties for file-backed data stores.
static String getMappingFile(Properties properties, DataStore<?,?> store, String defaultValue)
           
static String getOutputPath(Properties properties, DataStore<?,?> store)
          Returns the output path as read from the properties for file-backed data stores.
static
<D extends DataStore<K,T>,K,T extends Persistent>
void
setDefaultSchemaName(Properties properties, Class<D> dataStoreClass, String schemaName)
          Sets the default schema name to be used by the datastore of the given class
static void setDefaultSchemaName(Properties properties, String schemaName)
          Sets the default schema name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.commons.logging.Log log

GORA_DEFAULT_PROPERTIES_FILE

public static final String GORA_DEFAULT_PROPERTIES_FILE
See Also:
Constant Field Values

GORA_DEFAULT_DATASTORE_KEY

public static final String GORA_DEFAULT_DATASTORE_KEY
See Also:
Constant Field Values

GORA

public static final String GORA
See Also:
Constant Field Values

DATASTORE

public static final String DATASTORE
See Also:
Constant Field Values

AUTO_CREATE_SCHEMA

public static final String AUTO_CREATE_SCHEMA
See Also:
Constant Field Values

INPUT_PATH

public static final String INPUT_PATH
See Also:
Constant Field Values

OUTPUT_PATH

public static final String OUTPUT_PATH
See Also:
Constant Field Values

MAPPING_FILE

public static final String MAPPING_FILE
See Also:
Constant Field Values

SCHEMA_NAME

public static final String SCHEMA_NAME
See Also:
Constant Field Values

properties

@Deprecated
public static final Properties properties
Deprecated. 
Do not use! Deprecated because it shares system wide state. Use createProps() instead.

Method Detail

createProps

public static Properties createProps()
Creates a new Properties. It adds the default gora configuration resources. This properties object can be modified and used to instantiate store instances. It is recommended to use a properties object for a single store, because the properties object is passed on to store initialization methods that are able to store the properties as a field.

Returns:
The new properties object.

createDataStore

public static <D extends DataStore<K,T>,K,T extends Persistent> D createDataStore(Class<D> dataStoreClass,
                                                                                  Class<K> keyClass,
                                                                                  Class<T> persistent,
                                                                                  org.apache.hadoop.conf.Configuration conf)
                                                throws GoraException
Instantiate a new DataStore. Uses default properties. Uses 'null' schema.

Parameters:
dataStoreClass - The datastore implementation class.
keyClass - The key class.
persistent - The value class.
conf - Configuration to be used be the store.
Returns:
A new store instance.
Throws:
GoraException

createDataStore

public static <D extends DataStore<K,T>,K,T extends Persistent> D createDataStore(Class<D> dataStoreClass,
                                                                                  Class<K> keyClass,
                                                                                  Class<T> persistent,
                                                                                  org.apache.hadoop.conf.Configuration conf,
                                                                                  String schemaName)
                                                throws GoraException
Instantiate a new DataStore. Uses default properties.

Parameters:
dataStoreClass - The datastore implementation class.
keyClass - The key class.
persistent - The value class.
conf - Configuration to be used be the store.
schemaName - A default schemaname that will be put on the properties.
Returns:
A new store instance.
Throws:
GoraException

createDataStore

public static <D extends DataStore<K,T>,K,T extends Persistent> D createDataStore(Class<D> dataStoreClass,
                                                                                  Class<K> keyClass,
                                                                                  Class<T> persistent,
                                                                                  org.apache.hadoop.conf.Configuration conf,
                                                                                  Properties properties,
                                                                                  String schemaName)
                                                throws GoraException
Instantiate a new DataStore.

Parameters:
dataStoreClass - The datastore implementation class.
keyClass - The key class.
persistent - The value class.
conf - Configuration to be used be the store.
properties - The properties to be used be the store.
schemaName - A default schemaname that will be put on the properties.
Returns:
A new store instance.
Throws:
GoraException

createDataStore

public static <D extends DataStore<K,T>,K,T extends Persistent> D createDataStore(Class<D> dataStoreClass,
                                                                                  Class<K> keyClass,
                                                                                  Class<T> persistent,
                                                                                  org.apache.hadoop.conf.Configuration conf,
                                                                                  Properties properties)
                                                throws GoraException
Instantiate a new DataStore. Uses 'null' schema.

Parameters:
dataStoreClass - The datastore implementation class.
keyClass - The key class.
persistent - The value class.
conf - Configuration to be used be the store.
properties - The properties to be used be the store.
Returns:
A new store instance.
Throws:
GoraException

getDataStore

public static <D extends DataStore<K,T>,K,T extends Persistent> D getDataStore(Class<D> dataStoreClass,
                                                                               Class<K> keyClass,
                                                                               Class<T> persistentClass,
                                                                               org.apache.hadoop.conf.Configuration conf)
                                             throws GoraException
Instantiate a new DataStore. Uses default properties. Uses 'null' schema.

Parameters:
dataStoreClass - The datastore implementation class.
keyClass - The key class.
persistent - The value class.
conf - Configuration to be used be the store.
Returns:
A new store instance.
Throws:
GoraException

getDataStore

public static <K,T extends Persistent> DataStore<K,T> getDataStore(String dataStoreClass,
                                                                   Class<K> keyClass,
                                                                   Class<T> persistentClass,
                                                                   org.apache.hadoop.conf.Configuration conf)
                                                      throws GoraException
Instantiate a new DataStore. Uses default properties. Uses 'null' schema.

Parameters:
dataStoreClass - The datastore implementation class as string.
keyClass - The key class.
persistent - The value class.
conf - Configuration to be used be the store.
Returns:
A new store instance.
Throws:
GoraException

getDataStore

public static <K,T extends Persistent> DataStore<K,T> getDataStore(String dataStoreClass,
                                                                   String keyClass,
                                                                   String persistentClass,
                                                                   org.apache.hadoop.conf.Configuration conf)
                                                      throws GoraException
Instantiate a new DataStore. Uses default properties. Uses 'null' schema.

Parameters:
dataStoreClass - The datastore implementation class as string.
keyClass - The key class as string.
persistent - The value class as string.
conf - Configuration to be used be the store.
Returns:
A new store instance.
Throws:
GoraException

getDataStore

public static <K,T extends Persistent> DataStore<K,T> getDataStore(Class<K> keyClass,
                                                                   Class<T> persistent,
                                                                   org.apache.hadoop.conf.Configuration conf)
                                                      throws GoraException
Instantiate the default DataStore. Uses default properties. Uses 'null' schema.

Parameters:
keyClass - The key class.
persistent - The value class.
conf - Configuration to be used be the store.
Returns:
A new store instance.
Throws:
GoraException

findProperty

public static String findProperty(Properties properties,
                                  DataStore<?,?> store,
                                  String baseKey,
                                  String defaultValue)
Tries to find a property with the given baseKey. First the property key constructed as "gora.<classname>.<baseKey>" is searched. If not found, the property keys for all superclasses is recursively tested. Lastly, the property key constructed as "gora.datastore.<baseKey>" is searched.

Returns:
the first found value, or defaultValue

findPropertyOrDie

public static String findPropertyOrDie(Properties properties,
                                       DataStore<?,?> store,
                                       String baseKey)
                                throws IOException
Tries to find a property with the given baseKey. First the property key constructed as "gora.<classname>.<baseKey>" is searched. If not found, the property keys for all superclasses is recursively tested. Lastly, the property key constructed as "gora.datastore.<baseKey>" is searched.

Returns:
the first found value, or throws IOException
Throws:
IOException

findBooleanProperty

public static boolean findBooleanProperty(Properties properties,
                                          DataStore<?,?> store,
                                          String baseKey,
                                          String defaultValue)

getAutoCreateSchema

public static boolean getAutoCreateSchema(Properties properties,
                                          DataStore<?,?> store)

getInputPath

public static String getInputPath(Properties properties,
                                  DataStore<?,?> store)
Returns the input path as read from the properties for file-backed data stores.


getOutputPath

public static String getOutputPath(Properties properties,
                                   DataStore<?,?> store)
Returns the output path as read from the properties for file-backed data stores.


getMappingFile

public static String getMappingFile(Properties properties,
                                    DataStore<?,?> store,
                                    String defaultValue)

getDefaultSchemaName

public static String getDefaultSchemaName(Properties properties,
                                          DataStore<?,?> store)
Gets the default schema name of a given store class


setDefaultSchemaName

public static void setDefaultSchemaName(Properties properties,
                                        String schemaName)
Sets the default schema name.


setDefaultSchemaName

public static <D extends DataStore<K,T>,K,T extends Persistent> void setDefaultSchemaName(Properties properties,
                                                                                          Class<D> dataStoreClass,
                                                                                          String schemaName)
Sets the default schema name to be used by the datastore of the given class



Copyright © 2010-2013 The Apache Software Foundation. All Rights Reserved.