Package org.apache.accumulo.core.client

Examples of org.apache.accumulo.core.client.BatchWriter


      break;
    }

    String tableId = getId(tableName);

    BatchWriter tbw = tableWriters.get(tableId);
    if (tbw == null) {
      tbw = new TableBatchWriter(tableId);
      tableWriters.put(tableId, tbw);
    }
    return tbw;
View Full Code Here


        log.info("Simulating adding table: " + tableName);
        return;
      }
     
      log.debug("Adding table: " + tableName);
      BatchWriter bw = null;
      String table = tableName.toString();
     
      if (createTables && !conn.tableOperations().exists(table)) {
        try {
          conn.tableOperations().create(table);
View Full Code Here

        log.info("Simulating adding table: " + tableName);
        return;
      }
     
      log.debug("Adding table: " + tableName);
      BatchWriter bw = null;
      String table = tableName.toString();
     
      if (createTables && !conn.tableOperations().exists(table)) {
        try {
          conn.tableOperations().create(table);
View Full Code Here

  private void test2() throws Exception {
    basicTest(PRE_SPLIT_TABLE_NAME, NUM_PRE_SPLITS);
  }
 
  private void basicTest(String table, int expectedSplits) throws Exception {
    BatchWriter bw = getConnector().createBatchWriter(table, new BatchWriterConfig());
   
    Random r = new Random();
    byte rowData[] = new byte[ROW_SIZE];
   
    r.setSeed(SEED);
   
    for (int i = 0; i < NUM_ROWS; i++) {
     
      r.nextBytes(rowData);
      TestIngest.toPrintableChars(rowData);
     
      Mutation mut = new Mutation(new Text(rowData));
      mut.put(new Text(""), new Text(""), new Value(Integer.toString(i).getBytes(Constants.UTF8)));
      bw.addMutation(mut);
    }
   
    bw.close();
   
    checkSplits(table, expectedSplits, expectedSplits);
   
    verify(table);
   
View Full Code Here

public class Write extends Test {
 
  @Override
  public void visit(State state, Properties props) throws Exception {
   
    BatchWriter bw = state.getMultiTableBatchWriter().getBatchWriter(state.getString("seqTableName"));
   
    state.set("numWrites", state.getLong("numWrites") + 1);
   
    Long totalWrites = state.getLong("totalWrites") + 1;
    if ((totalWrites % 10000) == 0) {
      log.debug("Total writes: " + totalWrites);
    }
    state.set("totalWrites", totalWrites);
   
    Mutation m = new Mutation(new Text(String.format("%010d", totalWrites)));
    m.put(new Text("cf"), new Text("cq"), new Value("val".getBytes(Constants.UTF8)));
    bw.addMutation(m);
  }
View Full Code Here

  @Override
  public void run() throws Exception {

    getConnector().tableOperations().create("test");

    BatchWriter bw = getConnector().createBatchWriter("test", new BatchWriterConfig());

    Mutation m1 = new Mutation("r1");
    m1.put("cf1", "cq1", 1, "5");

    bw.addMutation(m1);

    bw.flush();

    Scanner scanner = getConnector().createScanner("test", new Authorizations());

    int count = 0;
    for (Entry<Key,Value> entry : scanner) {
      count++;
      if (!entry.getValue().toString().equals("5")) {
        throw new Exception("Unexpected value " + entry.getValue());
      }
    }

    if (count != 1) {
      throw new Exception("Unexpected count " + count);
    }

    if (countThreads() < 2) {
      printThreadNames();
      throw new Exception("Not seeing expected threads");
    }

    CleanUp.shutdownNow();

    Mutation m2 = new Mutation("r2");
    m2.put("cf1", "cq1", 1, "6");

    try {
      bw.addMutation(m1);
      bw.flush();
      throw new Exception("batch writer did not fail");
    } catch (Exception e) {

    }

    try {
      // expect this to fail also, want to clean up batch writer threads
      bw.close();
      throw new Exception("batch writer close not fail");
    } catch (Exception e) {

    }
View Full Code Here

    List<String> tableNames = (List<String>) state.get("tables");
   
    String tableName = tableNames.get(rand.nextInt(tableNames.size()));
   
    try {
      BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
      try {
        int numRows = rand.nextInt(100000);
        for (int i = 0; i < numRows; i++) {
          Mutation m = new Mutation(String.format("%016x", (rand.nextLong() & 0x7fffffffffffffffl)));
          long val = (rand.nextLong() & 0x7fffffffffffffffl);
          for (int j = 0; j < 10; j++) {
            m.put("cf", "cq" + j, new Value(String.format("%016x", val).getBytes(Constants.UTF8)));
          }
         
          bw.addMutation(m);
        }
      } finally {
        bw.close();
      }
     
      log.debug("Wrote to " + tableName);
    } catch (TableNotFoundException e) {
      log.debug("BatchWrite " + tableName + " failed, doesnt exist");
View Full Code Here

   
    String rootDir = "/tmp/shard_bulk/" + dataTableName;
   
    fs.mkdirs(new Path(rootDir));
   
    BatchWriter dataWriter = new SeqfileBatchWriter(conf, fs, rootDir + "/data.seq");
    BatchWriter indexWriter = new SeqfileBatchWriter(conf, fs, rootDir + "/index.seq");
   
    for (int i = 0; i < numToInsert; i++) {
      String docID = Insert.insertRandomDocument(nextDocID++, dataWriter, indexWriter, indexTableName, dataTableName, numPartitions, rand);
      log.debug("Bulk inserting document " + docID);
    }
   
    state.set("nextDocID", Long.valueOf(nextDocID));
   
    dataWriter.close();
    indexWriter.close();
   
    sort(state, fs, dataTableName, rootDir + "/data.seq", rootDir + "/data_bulk", rootDir + "/data_work", maxSplits);
    sort(state, fs, indexTableName, rootDir + "/index.seq", rootDir + "/index_bulk", rootDir + "/index_work", maxSplits);
   
    bulkImport(fs, state, dataTableName, rootDir, "data");
View Full Code Here

  }
 
  @Override
  public void run() throws Exception {
   
    BatchWriter bw = getConnector().createBatchWriter("foo", new BatchWriterConfig());
   
    for (int i = 0; i < 1000; i++) {
      Mutation m = new Mutation(new Text(String.format("%06d", i)));
      m.put(new Text("cf1"), new Text("cq1"), new Value(Integer.toString(1000 - i).getBytes(Constants.UTF8)));
      m.put(new Text("cf1"), new Text("cq2"), new Value(Integer.toString(i - 1000).getBytes(Constants.UTF8)));
     
      bw.addMutation(m);
    }
   
    bw.close();
   
    Scanner scanner = getConnector().createScanner("foo", new Authorizations());
   
    setupIter(scanner);
    verify(scanner, 1, 999);
View Full Code Here

   
    // Logger logger = Logger.getLogger(Constants.CORE_PACKAGE_NAME);
   
    int numRows = 1 << 18;
   
    BatchWriter bw = getConnector().createBatchWriter("bss", new BatchWriterConfig());
   
    for (int i = 0; i < numRows; i++) {
      Mutation m = new Mutation(new Text(String.format("%09x", i)));
      m.put(new Text("cf1"), new Text("cq1"), new Value(String.format("%016x", numRows - i).getBytes(Constants.UTF8)));
      bw.addMutation(m);
    }
   
    bw.close();
   
    getConnector().tableOperations().flush("bss", null, null, true);
   
    getConnector().tableOperations().setProperty("bss", Property.TABLE_SPLIT_THRESHOLD.getKey(), "4K");
   
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.BatchWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.