• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DataStoreFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.gora.store.DataStoreFactory的典型用法代码示例。如果您正苦于以下问题:Java DataStoreFactory类的具体用法?Java DataStoreFactory怎么用?Java DataStoreFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataStoreFactory类属于org.apache.gora.store包,在下文中一共展示了DataStoreFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:18,代码来源:Delete.java


示例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);
  }
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:21,代码来源:SparkWordCount.java


示例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);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:23,代码来源:WordCount.java


示例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);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:17,代码来源:GoraOutputFormat.java


示例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);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:18,代码来源:DataStoreBase.java


示例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);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:28,代码来源:DataStoreBase.java


示例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);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:29,代码来源:TestPersistentSerialization.java


示例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);
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:23,代码来源:CassandraStore.java


示例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);
}
 
开发者ID:apache,项目名称:gora,代码行数:23,代码来源:MapReduceSerialization.java


示例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);
}
 
开发者ID:apache,项目名称:gora,代码行数:18,代码来源:DataStoreBase.java


示例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);
}
 
开发者ID:apache,项目名称:gora,代码行数:30,代码来源:DataStoreBase.java


示例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);
}
 
开发者ID:apache,项目名称:gora,代码行数:29,代码来源:TestPersistentSerialization.java


示例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);
  }
}
 
开发者ID:apache,项目名称:gora,代码行数:30,代码来源:CassandraStore.java


示例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);
}
 
开发者ID:galaxyeye,项目名称:gora-0.3-simplified,代码行数:18,代码来源:DataStoreBase.java


示例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);
}
 
开发者ID:galaxyeye,项目名称:gora-0.3-simplified,代码行数:19,代码来源:TestPersistentDatumReader.java


示例16: testSerdeWebPage

import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@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++;
  }
  Assert.assertEquals(WebPageDataCreator.URLS.length, i);
}
 
开发者ID:galaxyeye,项目名称:gora-0.3-simplified,代码行数:19,代码来源:TestPersistentSerialization.java


示例17: 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++;
  }
  assertEquals(WebPageDataCreator.URLS.length, tested);
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:19,代码来源:TestPersistentDatumReader.java


示例18: testSerdeWebPage

import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@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);
}
 
开发者ID:maestros,项目名称:gora-oraclenosql,代码行数:19,代码来源:TestPersistentSerialization.java


示例19: setUp

import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
  cluster = new MiniAccumuloCluster(temporaryFolder.getRoot(), PASSWORD);
  cluster.start();

  Properties properties = DataStoreFactory.createProps();
  properties.setProperty(
      GORA_DATASTORE + AccumuloStore.MOCK_PROPERTY,
      "false");
  properties.setProperty(
      GORA_DATASTORE + AccumuloStore.INSTANCE_NAME_PROPERTY,
      cluster.getInstanceName());
  properties.setProperty(
      GORA_DATASTORE + AccumuloStore.ZOOKEEPERS_NAME_PROPERTY,
      cluster.getZooKeepers());
  properties.setProperty(
      GORA_DATASTORE + AccumuloStore.PASSWORD_PROPERTY,
      PASSWORD);

  employeeStore = DataStoreFactory.createDataStore(
      AccumuloStore.class,
      String.class,
      Employee.class,
      new Configuration(),
      properties);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:28,代码来源:AuthenticationTokenTest.java


示例20: createEmployeeDataStore

import org.apache.gora.store.DataStoreFactory; //导入依赖的package包/类
@Override
protected DataStore<String, Employee> createEmployeeDataStore()
    throws IOException {
  SolrStore<String, Employee> store = new SolrStore<>();
  store.initialize(String.class, Employee.class, DataStoreFactory.createProps());
  return store;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:8,代码来源:TestSolrStore.java



注:本文中的org.apache.gora.store.DataStoreFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerStatus类代码示例发布时间:2022-05-23
下一篇:
Java ExpandWar类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap