当前位置: 首页>>代码示例>>Java>>正文


Java DataStoreFactory类代码示例

本文整理汇总了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;
}
 
开发者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


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