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


Java BatchWriter.close方法代码示例

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


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

示例1: writeRandomEntries

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
/**
 * Write random entries.
 * <p>
 * Closes the writer after entries are written.
 *
 * @param writer
 *          Writer to write entries to.
 */
void writeRandomEntries(BatchWriter writer) throws MutationsRejectedException {
  for (int i = 0; i < rowCount; i++) {
    byte[] row = getRandomBytes(keyFieldSize, true);

    for (int j = 0; j < columnCount; j++) {
      byte[] colF = getRandomBytes(keyFieldSize, true);
      byte[] colQ = getRandomBytes(keyFieldSize, true);
      byte[] value = getRandomBytes(valueFieldSize, false);

      Mutation mutation = new Mutation(row);
      mutation.put(colF, colQ, VISIBILITY, value);
      writer.addMutation(mutation);
    }
  }

  writer.close();
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:26,代码来源:BenchmarkBase.java

示例2: main

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  Opts opts = new Opts();
  BatchWriterOpts bwOpts = new BatchWriterOpts();
  opts.parseArgs(FileDataIngest.class.getName(), args, bwOpts);

  Connector conn = opts.getConnector();
  if (!conn.tableOperations().exists(opts.getTableName())) {
    conn.tableOperations().create(opts.getTableName());
    conn.tableOperations().attachIterator(opts.getTableName(), new IteratorSetting(1, ChunkCombiner.class));
  }
  BatchWriter bw = conn.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig());
  FileDataIngest fdi = new FileDataIngest(opts.chunkSize, opts.visibility);
  for (String filename : opts.files) {
    fdi.insertFileData(filename, bw);
  }
  bw.close();
  //TODO
  //opts.stopTracing();
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:20,代码来源:FileDataIngest.java

示例3: createEntries

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
private void createEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {

    // Trace the write operation. Note, unless you flush the BatchWriter, you will not capture
    // the write operation as it is occurs asynchronously. You can optionally create additional Spans
    // within a given Trace as seen below around the flush
    TraceScope scope = Trace.startSpan("Client Write", Sampler.ALWAYS);

    System.out.println("TraceID: " + Long.toHexString(scope.getSpan().getTraceId()));
    BatchWriter batchWriter = opts.getConnector().createBatchWriter(opts.getTableName(), new BatchWriterConfig());

    Mutation m = new Mutation("row");
    m.put("cf", "cq", "value");

    batchWriter.addMutation(m);
    // You can add timeline annotations to Spans which will be able to be viewed in the Monitor
    scope.getSpan().addTimelineAnnotation("Initiating Flush");
    batchWriter.flush();

    batchWriter.close();
    scope.close();
  }
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:22,代码来源:TracingExample.java

示例4: main

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
/**
 * Writes a specified number of entries to Accumulo using a {@link BatchWriter}. The rows of the entries will be sequential starting at a specified number.
 * The column families will be "foo" and column qualifiers will be "1". The values will be random byte arrays of a specified size.
 */
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException {
  Opts opts = new Opts();
  BatchWriterOpts bwOpts = new BatchWriterOpts();
  opts.parseArgs(SequentialBatchWriter.class.getName(), args, bwOpts);
  Connector connector = opts.getConnector();
  BatchWriter bw = connector.createBatchWriter(opts.getTableName(), bwOpts.getBatchWriterConfig());

  long end = opts.start + opts.num;

  for (long i = opts.start; i < end; i++) {
    Mutation m = RandomBatchWriter.createMutation(i, opts.valueSize, opts.vis);
    bw.addMutation(m);
  }

  bw.close();
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:21,代码来源:SequentialBatchWriter.java

示例5: main

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  Opts opts = new Opts();
  ScannerOpts scanOpts = new ScannerOpts();
  BatchWriterOpts bwOpts = new BatchWriterOpts();
  opts.parseArgs(Reverse.class.getName(), args, scanOpts, bwOpts);

  Connector conn = opts.getConnector();

  Scanner scanner = conn.createScanner(opts.shardTable, opts.auths);
  scanner.setBatchSize(scanOpts.scanBatchSize);
  BatchWriter bw = conn.createBatchWriter(opts.doc2TermTable, bwOpts.getBatchWriterConfig());

  for (Entry<Key,Value> entry : scanner) {
    Key key = entry.getKey();
    Mutation m = new Mutation(key.getColumnQualifier());
    m.put(key.getColumnFamily(), new Text(), new Value(new byte[0]));
    bw.addMutation(m);
  }

  bw.close();

}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:23,代码来源:Reverse.java

示例6: test

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
  conn.tableOperations().create(tableName);
  BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());

  for (Entry<Key,Value> e : data) {
    Key k = e.getKey();
    Mutation m = new Mutation(k.getRow());
    m.put(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp(), e.getValue());
    bw.addMutation(m);
  }
  bw.close();

  assertEquals(0, CIFTester.main(tableName, CIFTester.TestMapper.class.getName()));
  assertEquals(1, assertionErrors.get(tableName).size());
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:17,代码来源:ChunkInputFormatIT.java

示例7: testErrorOnNextWithoutClose

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
@Test
public void testErrorOnNextWithoutClose() throws Exception {
  conn.tableOperations().create(tableName);
  BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());

  for (Entry<Key,Value> e : data) {
    Key k = e.getKey();
    Mutation m = new Mutation(k.getRow());
    m.put(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp(), e.getValue());
    bw.addMutation(m);
  }
  bw.close();

  assertEquals(1, CIFTester.main(tableName, CIFTester.TestNoClose.class.getName()));
  assertEquals(1, assertionErrors.get(tableName).size());
  // this should actually exist, in addition to the dummy entry
  assertEquals(2, assertionErrors.get(tableName + "_map_ioexception").size());
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:19,代码来源:ChunkInputFormatIT.java

示例8: setupInstance

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
@Before
public void setupInstance() throws Exception {
  tableName = getUniqueNames(1)[0];
  conn = getConnector();
  conn.tableOperations().create(tableName);
  BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
  ColumnVisibility cv = new ColumnVisibility();
  // / has 1 dir
  // /local has 2 dirs 1 file
  // /local/user1 has 2 files
  bw.addMutation(Ingest.buildMutation(cv, "/local", true, false, true, 272, 12345, null));
  bw.addMutation(Ingest.buildMutation(cv, "/local/user1", true, false, true, 272, 12345, null));
  bw.addMutation(Ingest.buildMutation(cv, "/local/user2", true, false, true, 272, 12345, null));
  bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 12345, null));
  bw.addMutation(Ingest.buildMutation(cv, "/local/file", false, false, false, 1024, 23456, null));
  bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file1", false, false, false, 2024, 12345, null));
  bw.addMutation(Ingest.buildMutation(cv, "/local/user1/file2", false, false, false, 1028, 23456, null));
  bw.close();
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:20,代码来源:CountIT.java

示例9: testSimpleOutput

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
public void testSimpleOutput() throws Exception {
    BatchWriter batchWriter = connector.createBatchWriter(table, 10l, 10l, 2);
    Mutation row = new Mutation("row");
    row.put("cf", "cq", new Value(new byte[0]));
    batchWriter.addMutation(row);
    batchWriter.flush();
    batchWriter.close();

    String location = "accumulo://" + table + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&range=a|z&mock=true";
    AccumuloStorage storage = createAccumuloStorage(location);
    int count = 0;
    while (true) {
        Tuple next = storage.getNext();
        if (next == null)
            break;
        assertEquals(6, next.size());
        count++;
    }
    assertEquals(1, count);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:AccumuloStorageTest.java

示例10: testColumns

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
public void testColumns() throws Exception {
    BatchWriter batchWriter = connector.createBatchWriter(table, 10l, 10l, 2);
    Mutation row = new Mutation("a");
    row.put("cf1", "cq", new Value(new byte[0]));
    row.put("cf2", "cq", new Value(new byte[0]));
    row.put("cf3", "cq1", new Value(new byte[0]));
    row.put("cf3", "cq2", new Value(new byte[0]));
    batchWriter.addMutation(row);
    batchWriter.flush();
    batchWriter.close();

    String location = "accumulo://" + table + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&range=a|c&columns=cf1,cf3|cq1&mock=true";
    AccumuloStorage storage = createAccumuloStorage(location);
    int count = 0;
    while (true) {
        Tuple next = storage.getNext();
        if (next == null)
            break;
        assertEquals(6, next.size());
        count++;
    }
    assertEquals(2, count);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:AccumuloStorageTest.java

示例11: testWholeRowRange

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
public void testWholeRowRange() throws Exception {
    BatchWriter batchWriter = connector.createBatchWriter(table, 10l, 10l, 2);
    Mutation row = new Mutation("a");
    row.put("cf1", "cq", new Value(new byte[0]));
    row.put("cf2", "cq", new Value(new byte[0]));
    row.put("cf3", "cq1", new Value(new byte[0]));
    row.put("cf3", "cq2", new Value(new byte[0]));
    batchWriter.addMutation(row);
    batchWriter.flush();
    batchWriter.close();

    String location = "accumulo://" + table + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&range=a&mock=true";
    AccumuloStorage storage = createAccumuloStorage(location);
    int count = 0;
    while (true) {
        Tuple next = storage.getNext();
        if (next == null)
            break;
        assertEquals(6, next.size());
        count++;
    }
    assertEquals(4, count);
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:AccumuloStorageTest.java

示例12: createTable

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
@Before
public void createTable() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
  connector.tableOperations().create(table);
  BatchWriter bw = connector.createBatchWriter(table, new BatchWriterConfig());
  for (char ch = 'a'; ch <= 'z'; ch++) {
    Mutation m = new Mutation(ch + "_row");

    m.put("fam1", "qual1", "val1:1");
    m.put("fam1", "qual2", "val1:2");
    m.put("fam2", "qual1", "val2:1");
    m.put("fam2", "qual2", "val2:2");
    m.put("fam2", "qual3", "val2:3");
    noAuthCount = m.getUpdates().size();
    bw.addMutation(m);
  }
  bw.close();
}
 
开发者ID:JHUAPL,项目名称:accumulo-proxy-instance,代码行数:18,代码来源:ScannerTest.java

示例13: setState

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
public static void setState(Store id, State state) throws TableNotFoundException, MutationsRejectedException {
  checkNotNull(id);
  checkNotNull(state);
  
  BatchWriter bw = null;
  try {
    bw = id.connector().createBatchWriter(id.metadataTable(), id.writerConfig());
    Mutation m = new Mutation(id.uuid());
    m.put(STATE_COLFAM, EMPTY_TEXT, new Value(state.toString().getBytes()));
    
    bw.addMutation(m);
    bw.flush();
  } finally {
    if (null != bw) {
      bw.close();
    }
  }
}
 
开发者ID:joshelser,项目名称:cosmos,代码行数:19,代码来源:PersistedStores.java

示例14: store

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
/**
 * Serialize this store to the metadata table as defined in the {@link Store}
 * 
 * @param id
 * @param connector
 * @throws TableNotFoundException
 * @throws MutationsRejectedException
 */
public static void store(Store id) throws TableNotFoundException, MutationsRejectedException {
  checkNotNull(id);
  
  Mutation m = new Mutation(id.uuid());
  m.put(SERIALIZED_STORE_COLFAM, Defaults.EMPTY_TEXT, serialize(id));
  
  BatchWriter bw = null;
  try {
    bw = id.connector().createBatchWriter(id.metadataTable(), id.writerConfig());
    bw.addMutation(m);
  } finally {
    if (null != bw) {
      bw.close();
    }
  }
}
 
开发者ID:joshelser,项目名称:cosmos,代码行数:25,代码来源:PersistedStores.java

示例15: createEntries

import org.apache.accumulo.core.client.BatchWriter; //导入方法依赖的package包/类
private void createEntries(Opts opts) throws Exception {
  if (opts.createEntries || opts.deleteEntries) {
    BatchWriterConfig cfg = new BatchWriterConfig();
    cfg.setDurability(opts.durability);
    BatchWriter writer = new SignedBatchWriter(conn, opts.getTableName(), cfg, opts.signatureConfig, opts.signatureKeys);
    ColumnVisibility cv = new ColumnVisibility(opts.auths.toString().replace(',', '|'));

    Text cf = new Text("datatypes");
    Text cq = new Text("xml");
    byte[] row = {'h', 'e', 'l', 'l', 'o', '\0'};
    byte[] value = {'w', 'o', 'r', 'l', 'd', '\0'};

    for (int i = 0; i < 10; i++) {
      row[row.length - 1] = (byte) i;
      Mutation m = new Mutation(new Text(row));
      if (opts.deleteEntries) {
        m.putDelete(cf, cq, cv);
      }
      if (opts.createEntries) {
        value[value.length - 1] = (byte) i;
        m.put(cf, cq, cv, new Value(value));
      }
      writer.addMutation(m);
    }
    writer.close();
  }
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:28,代码来源:SignedReadWriteExample.java


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