use of org.apache.gora.store.DataStore in project gora by apache.
the class QueryCounter method run.
@SuppressWarnings("unchecked")
@Override
public int run(String[] args) throws Exception {
if (args.length < 2) {
LOG.info("Usage QueryCounter <keyClass> <persistentClass> [dataStoreClass]");
return 1;
}
Class<K> keyClass = (Class<K>) ClassLoadingUtils.loadClass(args[0]);
Class<T> persistentClass = (Class<T>) ClassLoadingUtils.loadClass(args[1]);
DataStore<K, T> dataStore;
Configuration conf = new Configuration();
if (args.length > 2) {
Class<? extends DataStore<K, T>> dataStoreClass = (Class<? extends DataStore<K, T>>) Class.forName(args[2]);
dataStore = DataStoreFactory.getDataStore(dataStoreClass, keyClass, persistentClass, conf);
} else {
dataStore = DataStoreFactory.getDataStore(keyClass, persistentClass, conf);
}
long results = countQuery(dataStore);
LOG.info("Number of result to the query:" + results);
return 0;
}
use of org.apache.gora.store.DataStore in project gora by apache.
the class GoraTestDriver method tearDown.
/** Should be called once after each test, probably in the
* method annotated with org.junit.After
*/
@SuppressWarnings("rawtypes")
public void tearDown() throws Exception {
log.info("tearing down test");
//delete everything
for (DataStore store : dataStores) {
try {
store.deleteSchema();
store.close();
} catch (Exception ignore) {
}
}
dataStores.clear();
}
use of org.apache.gora.store.DataStore in project gora by apache.
the class WSDataStoreFactory method getDataStore.
/**
* Instantiate a new {@link DataStore}. Uses default properties. Uses 'null' schema.
*
* @param dataStoreClass The datastore implementation class <i>as string</i>.
* @param keyClass The key class <i>as string</i>.
* @param persistentClass The value class <i>as string</i>.
* @param auth an authentication {@link Object} to be used for communication.
* @return A new store instance.
* @throws GoraException
*/
@SuppressWarnings({ "unchecked" })
public static <K, T extends Persistent> DataStore<K, T> getDataStore(String dataStoreClass, String keyClass, String persistentClass, Object auth) throws GoraException {
try {
Class<? extends DataStore<K, T>> c = (Class<? extends DataStore<K, T>>) Class.forName(dataStoreClass);
Class<K> k = (Class<K>) ClassLoadingUtils.loadClass(keyClass);
Class<T> p = (Class<T>) ClassLoadingUtils.loadClass(persistentClass);
return createDataStore(c, k, p, auth, createProps(), null);
} catch (GoraException ex) {
throw ex;
} catch (Exception ex) {
throw new GoraException(ex);
}
}
use of org.apache.gora.store.DataStore in project gora by apache.
the class GoraOutputFormat method getRecordWriter.
@Override
@SuppressWarnings("unchecked")
public RecordWriter<K, T> getRecordWriter(TaskAttemptContext context) throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
Class<? extends DataStore<K, T>> dataStoreClass = (Class<? extends DataStore<K, T>>) conf.getClass(DATA_STORE_CLASS, null);
Class<K> keyClass = (Class<K>) conf.getClass(OUTPUT_KEY_CLASS, null);
Class<T> rowClass = (Class<T>) conf.getClass(OUTPUT_VALUE_CLASS, null);
final DataStore<K, T> store = DataStoreFactory.createDataStore(dataStoreClass, keyClass, rowClass, context.getConfiguration());
setOutputPath(store, context);
return new GoraRecordWriter(store, context);
}
Aggregations