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


Java Connector.createMultiTableBatchWriter方法代码示例

本文整理汇总了Java中org.apache.accumulo.core.client.Connector.createMultiTableBatchWriter方法的典型用法代码示例。如果您正苦于以下问题:Java Connector.createMultiTableBatchWriter方法的具体用法?Java Connector.createMultiTableBatchWriter怎么用?Java Connector.createMultiTableBatchWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.accumulo.core.client.Connector的用法示例。


在下文中一共展示了Connector.createMultiTableBatchWriter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, MutationsRejectedException, TableExistsException,
    TableNotFoundException {
  ClientOnRequiredTable opts = new ClientOnRequiredTable();
  BatchWriterOpts bwOpts = new BatchWriterOpts();
  opts.parseArgs(InsertWithBatchWriter.class.getName(), args, bwOpts);

  Connector connector = opts.getConnector();
  MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());

  if (!connector.tableOperations().exists(opts.getTableName()))
    connector.tableOperations().create(opts.getTableName());
  BatchWriter bw = mtbw.getBatchWriter(opts.getTableName());

  Text colf = new Text("colfam");
  System.out.println("writing ...");
  for (int i = 0; i < 10000; i++) {
    Mutation m = new Mutation(new Text(String.format("row_%d", i)));
    for (int j = 0; j < 5; j++) {
      m.put(colf, new Text(String.format("colqual_%d", j)), new Value((String.format("value_%d_%d", i, j)).getBytes()));
    }
    bw.addMutation(m);
    if (i % 100 == 0)
      System.out.println(i);
  }
  mtbw.close();
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:27,代码来源:InsertWithBatchWriter.java

示例2: getFreeTextIndexer

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
private static FreeTextIndexer getFreeTextIndexer(final Configuration conf) throws IOException {
    if (!conf.getBoolean(ENABLE_FREETEXT, true)) {
        return null;
    }
    final AccumuloFreeTextIndexer freeText = new AccumuloFreeTextIndexer();
    freeText.setConf(conf);
    Connector connector;
    try {
        connector = ConfigUtils.getConnector(conf);
    } catch (AccumuloException | AccumuloSecurityException e) {
        throw new IOException("Error when attempting to create a connection for writing the freeText index.", e);
    }
    final MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    freeText.setConnector(connector);
    freeText.setMultiTableBatchWriter(mtbw);
    freeText.init();

    return freeText;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:20,代码来源:RyaOutputFormat.java

示例3: getTemporalIndexer

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
private static TemporalIndexer getTemporalIndexer(final Configuration conf) throws IOException {
    if (!conf.getBoolean(ENABLE_TEMPORAL, true)) {
        return null;
    }
    final AccumuloTemporalIndexer temporal = new AccumuloTemporalIndexer();
    temporal.setConf(conf);
    Connector connector;
    try {
        connector = ConfigUtils.getConnector(conf);
    } catch (AccumuloException | AccumuloSecurityException e) {
        throw new IOException("Error when attempting to create a connection for writing the temporal index.", e);
    }
    final MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    temporal.setConnector(connector);
    temporal.setMultiTableBatchWriter(mtbw);
    temporal.init();
    return temporal;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:19,代码来源:RyaOutputFormat.java

示例4: setUp

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    conf = new Configuration();
    conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "triplestore_");
    conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true);
    // The temporal predicates are from http://linkedevents.org/ontology
    // and http://motools.sourceforge.net/event/event.html
    conf.setStrings(ConfigUtils.TEMPORAL_PREDICATES_LIST, ""
            + URI_PROPERTY_AT_TIME + ","
            + URI_PROPERTY_CIRCA + ","
            + URI_PROPERTY_EVENT_TIME);

    tIndexer = new AccumuloTemporalIndexer();
    tIndexer.setConf(conf);
    Connector connector = ConfigUtils.getConnector(conf);
    MultiTableBatchWriter mt_bw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    tIndexer.setConnector(connector);
    tIndexer.setMultiTableBatchWriter(mt_bw);
    tIndexer.init();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:AccumuloTemporalIndexerTest.java

示例5: createMultitableBatchWriter

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
public static MultiTableBatchWriter createMultitableBatchWriter(final Configuration conf)
        throws AccumuloException, AccumuloSecurityException {
    final Long DEFAULT_MAX_MEMORY = getWriterMaxMemory(conf);
    final Long DEFAULT_MAX_LATENCY = getWriterMaxLatency(conf);
    final Integer DEFAULT_MAX_WRITE_THREADS = getWriterMaxWriteThreads(conf);
    final Connector connector = ConfigUtils.getConnector(conf);
    return connector.createMultiTableBatchWriter(DEFAULT_MAX_MEMORY, DEFAULT_MAX_LATENCY, DEFAULT_MAX_WRITE_THREADS);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:9,代码来源:ConfigUtils.java

示例6: RyaRecordWriter

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
/**
 * Constructor.
 * @param conf Configuration containing any relevant options.
 * @throws  IOException if the core Rya indexer or entity indexer can't
 *          be initialized
 */
public RyaRecordWriter(final Configuration conf) throws IOException {
    // set the visibility
    final String visibility = conf.get(CV_PROPERTY);
    if (visibility != null) {
        cv = visibility.getBytes(StandardCharsets.UTF_8);
    }
    // set the default context
    final String context = conf.get(CONTEXT_PROPERTY, "");
    if (context != null && !context.isEmpty()) {
        defaultContext = new RyaURI(context);
    }

    // set up the buffer
    bufferSizeLimit = conf.getLong(MAX_MUTATION_BUFFER_SIZE, ONE_MEGABYTE);
    final int bufferCapacity = (int) (bufferSizeLimit / AVE_STATEMENT_SIZE);
    buffer = new ArrayList<RyaStatement>(bufferCapacity);

    // set up the indexers
    freeTextIndexer = getFreeTextIndexer(conf);
    temporalIndexer = getTemporalIndexer(conf);
    entityIndexer = getEntityIndexer(conf);
    ryaIndexer = getRyaIndexer(conf);

    // The entity index needs a batch writer -- typically it uses the DAO's, but decoupling
    // them lets it be used with or without the core tables, like the other indexers.
    if (entityIndexer != null) {
        Connector conn;
        try {
            conn = ConfigUtils.getConnector(conf);
        } catch (AccumuloException | AccumuloSecurityException e) {
            throw new IOException("Error connecting to Accumulo for entity index output", e);
        }
        final BatchWriterConfig batchWriterConfig = new BatchWriterConfig();
        batchWriterConfig.setMaxMemory(RdfCloudTripleStoreConstants.MAX_MEMORY);
        batchWriterConfig.setTimeout(RdfCloudTripleStoreConstants.MAX_TIME, TimeUnit.MILLISECONDS);
        batchWriterConfig.setMaxWriteThreads(RdfCloudTripleStoreConstants.NUM_THREADS);
        writer = conn.createMultiTableBatchWriter(batchWriterConfig);
        entityIndexer.setMultiTableBatchWriter(writer);
    }

    // update fields used for metrics
    startTime = System.currentTimeMillis();
    lastCommitFinishTime = startTime;

    // set up the triple context
    tripleContext = RyaTripleContext.getInstance(new AccumuloRdfConfiguration(conf));
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:54,代码来源:RyaOutputFormat.java

示例7: testTemporalIndexing

import org.apache.accumulo.core.client.Connector; //导入方法依赖的package包/类
@Test
public void testTemporalIndexing() throws Exception {
    final TemporalInstant[] instants = {
            new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 01),
            new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 02),
            new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 03),
            new TemporalInstantRfc3339(2015, 12, 30, 12, 00, 03)
    };
    final Statement[] statements = new Statement[instants.length];
    RyaOutputFormat.setCoreTablesEnabled(job, false);
    RyaOutputFormat.setFreeTextEnabled(job, false);
    RyaOutputFormat.setTemporalEnabled(job, true);
    RyaOutputFormat.setEntityEnabled(job, false);
    final ValueFactory vf = new ValueFactoryImpl();
    for (int i = 0; i < instants.length; i++) {
        final RyaType time = RdfToRyaConversions.convertLiteral(vf.createLiteral(instants[i].toString()));
        final RyaStatement input = RyaStatement.builder()
                .setSubject(new RyaURI(GRAPH + ":s"))
                .setPredicate(new RyaURI(GRAPH + ":p"))
                .setObject(time)
                .build();
        write(input);
        statements[i] = RyaToRdfConversions.convertStatement(input);
    }
    final AccumuloTemporalIndexer temporal = new AccumuloTemporalIndexer();
    temporal.setConf(conf);
    Connector connector = ConfigUtils.getConnector(conf);
    MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(new BatchWriterConfig());
    temporal.setConnector(connector);
    temporal.setMultiTableBatchWriter(mtbw);
    temporal.init();
    final Set<Statement> empty = new HashSet<>();
    final Set<Statement> head = new HashSet<>();
    final Set<Statement> tail = new HashSet<>();
    head.add(statements[0]);
    tail.add(statements[2]);
    tail.add(statements[3]);
    Assert.assertEquals(empty, getSet(temporal.queryInstantBeforeInstant(instants[0], new StatementConstraints())));
    Assert.assertEquals(empty, getSet(temporal.queryInstantAfterInstant(instants[3], new StatementConstraints())));
    Assert.assertEquals(head, getSet(temporal.queryInstantBeforeInstant(instants[1], new StatementConstraints())));
    Assert.assertEquals(tail, getSet(temporal.queryInstantAfterInstant(instants[1], new StatementConstraints())));
    temporal.close();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:44,代码来源:RyaOutputFormatTest.java


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