本文整理汇总了Java中org.apache.gora.store.DataStoreFactory类的典型用法代码示例。如果您正苦于以下问题:Java DataStoreFactory类的具体用法?Java DataStoreFactory怎么用?Java DataStoreFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataStoreFactory类属于org.apache.gora.store包,在下文中一共展示了DataStoreFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
public int run(String[] args) throws Exception {
if (args.length != 1) {
LOG.info("Usage : {} <node to delete>", Delete.class.getSimpleName());
return 0;
}
DataStore<Long,CINode> store = DataStoreFactory.getDataStore(Long.class, CINode.class, new Configuration());
boolean ret = store.delete(new BigInteger(args[0], 16).longValue());
store.flush();
LOG.info("Delete returned {}", ret);
store.close();
return ret ? 0 : 1;
}
示例2: run
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
public int run(String[] args) throws Exception {
DataStore<String,WebPage> inStore;
DataStore<String, TokenDatum> outStore;
Configuration hadoopConf = new Configuration();
if(args.length > 0) {
String dataStoreClass = args[0];
inStore = DataStoreFactory.getDataStore(dataStoreClass, String.class, WebPage.class, hadoopConf);
if(args.length > 1) {
dataStoreClass = args[1];
}
outStore = DataStoreFactory.getDataStore(dataStoreClass,
String.class, TokenDatum.class, hadoopConf);
} else {
inStore = DataStoreFactory.getDataStore(String.class, WebPage.class, hadoopConf);
outStore = DataStoreFactory.getDataStore(String.class, TokenDatum.class, hadoopConf);
}
return wordCount(inStore, outStore);
}
示例3: run
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Override
public int run(String[] args) throws Exception {
DataStore<String,WebPage> inStore;
DataStore<String, TokenDatum> outStore;
Configuration conf = new Configuration();
if(args.length > 0) {
String dataStoreClass = args[0];
inStore = DataStoreFactory.getDataStore(dataStoreClass,
String.class, WebPage.class, conf);
if(args.length > 1) {
dataStoreClass = args[1];
}
outStore = DataStoreFactory.getDataStore(dataStoreClass,
String.class, TokenDatum.class, conf);
} else {
inStore = DataStoreFactory.getDataStore(String.class, WebPage.class, conf);
outStore = DataStoreFactory.getDataStore(String.class, TokenDatum.class, conf);
}
return wordCount(inStore, outStore);
}
示例4: getRecordWriter
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@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);
}
示例5: initialize
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Override
public void initialize(Class<K> keyClass, Class<T> persistentClass,
Properties properties) {
setKeyClass(keyClass);
setPersistentClass(persistentClass);
if (this.beanFactory == null) {
this.beanFactory = new BeanFactoryImpl<>(keyClass, persistentClass);
}
schema = this.beanFactory.getCachedPersistent().getSchema();
fieldMap = AvroUtils.getFieldMap(schema);
autoCreateSchema = DataStoreFactory.getAutoCreateSchema(properties, this);
this.properties = properties;
datumReader = new SpecificDatumReader<>(schema);
datumWriter = new SpecificDatumWriter<>(schema);
}
示例6: getSchemaName
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
/**
* Returns the name of the schema to use for the persistent class.
*
* First the schema name in the {@link Configuration} is used. If null,
* the schema name in the defined properties is returned. If null then
* the provided mappingSchemaName is returned. If this is null too,
* the class name, without the package, of the persistent class is returned.
* @param mappingSchemaName the name of the schema as read from the mapping file
* @param persistentClass persistent class
*/
protected String getSchemaName(String mappingSchemaName, Class<?> persistentClass) {
String confSchemaName = getOrCreateConf().get("preferred.schema.name");
if (confSchemaName != null) {
return confSchemaName;
}
String schemaName = DataStoreFactory.getDefaultSchemaName(properties, this);
if(schemaName != null) {
return schemaName;
}
if(mappingSchemaName != null) {
return mappingSchemaName;
}
return StringUtils.getClassname(persistentClass);
}
示例7: testSerdeWebPage
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
/**
* Creates an WebPage object in-memory setting several fields to dirty.
* Run a query over the persistent data.
* Asserts that the results can be serialized and
* deserialzed without loosing data. We do this by asserting
* what we get 'before' and 'after' (de)serialization processes.
* Also simple assertion for equal number of URL's in WebPage
* and results.
* @throws Exception
*/
@SuppressWarnings("unchecked")
@Test
public void testSerdeWebPage() throws Exception {
MemStore<String, WebPage> store = DataStoreFactory.getDataStore(
MemStore.class, String.class, WebPage.class, new Configuration());
WebPageDataCreator.createWebPageData(store);
Result<String, WebPage> result = store.newQuery().execute();
int i = 0;
while (result.next()) {
WebPage page = result.get();
TestIOUtils.testSerializeDeserialize(page);
i++;
}
assertEquals(WebPageDataCreator.URLS.length, i);
}
示例8: initialize
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
/**
* Initialize is called when then the call to
* {@link org.apache.gora.store.DataStoreFactory#createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf)}
* is made. In this case, we merely delegate the store initialization to the
* {@link org.apache.gora.cassandra.store.CassandraClient#initialize(Class<K> keyClass, Class<T> persistentClass)}.
*/
public void initialize(Class<K> keyClass, Class<T> persistent, Properties properties) {
try {
super.initialize(keyClass, persistent, properties);
if (autoCreateSchema) {
// If this is not set, then each Cassandra client should set its default
// column family
colFamConsLvl = DataStoreFactory.findProperty(properties, this, COL_FAM_CL, null);
// operations
readOpConsLvl = DataStoreFactory.findProperty(properties, this, READ_OP_CL, null);
writeOpConsLvl = DataStoreFactory.findProperty(properties, this, WRITE_OP_CL, null);
}
this.cassandraClient.initialize(keyClass, persistent, properties);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
示例9: run
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Override
public int run(String[] args) throws Exception {
DataStore<String, WebPage> inStore;
DataStore<String, WebPage> outStore;
Configuration conf = new Configuration();
if (args.length > 0) {
String dataStoreClass = args[0];
inStore = DataStoreFactory.getDataStore(dataStoreClass,
String.class, WebPage.class, conf);
if (args.length > 1) {
dataStoreClass = args[1];
}
outStore = DataStoreFactory.getDataStore(dataStoreClass,
String.class, WebPage.class, conf);
} else {
inStore = DataStoreFactory.getDataStore(String.class, WebPage.class, conf);
outStore = DataStoreFactory.getDataStore(String.class, WebPage.class, conf);
}
return mapReduceSerialization(inStore, outStore);
}
示例10: initialize
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Override
public void initialize(Class<K> keyClass, Class<T> persistentClass,
Properties properties) {
setKeyClass(keyClass);
setPersistentClass(persistentClass);
if (this.beanFactory == null) {
this.beanFactory = new BeanFactoryImpl<>(keyClass, persistentClass);
}
schema = this.beanFactory.getCachedPersistent().getSchema();
fieldMap = AvroUtils.getFieldMap(schema);
autoCreateSchema = DataStoreFactory.getAutoCreateSchema(properties, this);
this.properties = properties;
datumReader = new SpecificDatumReader<>(schema);
datumWriter = new SpecificDatumWriter<>(schema);
}
示例11: getSchemaName
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
/**
* Returns the name of the schema to use for the persistent class.
*
* First the schema name in the {@link Configuration} is used. If null,
* the schema name in the defined properties is returned. If null then
* the provided mappingSchemaName is returned. If this is null too,
* the class name, without the package, of the persistent class is returned.
*
* @param mappingSchemaName the name of the schema as read from the mapping file
* @param persistentClass persistent class
* @return String
*/
protected String getSchemaName(String mappingSchemaName, Class<?> persistentClass) {
String confSchemaName = getOrCreateConf().get("preferred.schema.name");
if (confSchemaName != null) {
return confSchemaName;
}
String schemaName = DataStoreFactory.getDefaultSchemaName(properties, this);
if(schemaName != null) {
return schemaName;
}
if(mappingSchemaName != null) {
return mappingSchemaName;
}
return StringUtils.getClassname(persistentClass);
}
示例12: testSerdeWebPage
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
/**
* Creates an WebPage object in-memory setting several fields to dirty.
* Run a query over the persistent data.
* Asserts that the results can be serialized and
* deserialzed without loosing data. We do this by asserting
* what we get 'before' and 'after' (de)serialization processes.
* Also simple assertion for equal number of URL's in WebPage
* and results.
* @throws Exception
*/
@SuppressWarnings("unchecked")
@Test
public void testSerdeWebPage() throws Exception {
MemStore<String, WebPage> store = DataStoreFactory.getDataStore(
MemStore.class, String.class, WebPage.class, new Configuration());
WebPageDataCreator.createWebPageData(store);
Result<String, WebPage> result = store.newQuery().execute();
int i = 0;
while (result.next()) {
WebPage page = result.get();
TestIOUtils.testSerializeDeserialize(page);
i++;
}
assertEquals(WebPageDataCreator.URLS.length, i);
}
示例13: initialize
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
/**
* In initializing the cassandra datastore, read the mapping file, creates the basic connection to cassandra cluster,
* according to the gora properties
*
* @param keyClass key class
* @param persistentClass persistent class
* @param properties properties
*/
@Override
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) {
LOG.debug("Initializing Cassandra store");
String serializationType;
try {
this.keyClass = keyClass;
this.persistentClass = persistentClass;
if (this.beanFactory == null) {
this.beanFactory = new BeanFactoryImpl<>(keyClass, persistentClass);
}
String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE);
serializationType = properties.getProperty(CassandraStoreParameters.CASSANDRA_SERIALIZATION_TYPE);
CassandraMappingBuilder mappingBuilder = new CassandraMappingBuilder(this);
mapping = mappingBuilder.readMapping(mappingFile);
CassandraClient cassandraClient = new CassandraClient();
cassandraClient.initialize(properties, mapping);
cassandraSerializer = CassandraSerializer.getSerializer(cassandraClient, serializationType, this, mapping);
} catch (Exception e) {
throw new RuntimeException("Error while initializing Cassandra store: " + e.getMessage(), e);
}
}
示例14: initialize
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Override
public void initialize(Class<K> keyClass, Class<T> persistentClass,
Properties properties) {
setKeyClass(keyClass);
setPersistentClass(persistentClass);
if (this.beanFactory == null) {
this.beanFactory = new BeanFactoryImpl<K, T>(keyClass, persistentClass);
}
schema = this.beanFactory.getCachedPersistent().getSchema();
fieldMap = AvroUtils.getFieldMap(schema);
autoCreateSchema = DataStoreFactory.getAutoCreateSchema(properties, this);
this.properties = properties;
datumReader = new PersistentDatumReader<T>(schema, false);
datumWriter = new PersistentDatumWriter<T>(schema, false);
}
示例15: testCloneWebPage
import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Test
public void testCloneWebPage() throws Exception {
@SuppressWarnings("unchecked")
DataStore<String, WebPage> store = DataStoreFactory.createDataStore(
MemStore.class, String.class, WebPage.class, conf);
WebPageDataCreator.createWebPageData(store);
Query<String, WebPage> query = store.newQuery();
Result<String, WebPage> result = query.execute();
int tested = 0;
while(result.next()) {
WebPage page = result.get();
testClone(page);
tested++;
}
Assert.assertEquals(WebPageDataCreator.URLS.length, tested);
}