Examples of BatchScanner


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

    System.out.printf("Multiple thread scan time %6.2f %n", time2 / 1000.0);
   
  }
 
  private long batchScan(List<Range> ranges, int threads) throws Exception {
    BatchScanner bs = getConnector().createBatchScanner("test_ingest", TestIngest.AUTHS, threads);
   
    bs.setRanges(ranges);
   
    int count = 0;
   
    long t1 = System.currentTimeMillis();
   
    byte rval[] = new byte[50];
    Random random = new Random();
   
    for (Entry<Key,Value> entry : bs) {
      count++;
      int row = VerifyIngest.getRow(entry.getKey());
      int col = VerifyIngest.getCol(entry.getKey());
     
      if (row < 0 || row >= NUM_TO_INGEST) {
        throw new Exception("unexcepted row " + row);
      }
     
      rval = TestIngest.genRandomValue(random, rval, 2, row, col);
     
      if (entry.getValue().compareTo(rval) != 0) {
        throw new Exception("unexcepted value row=" + row + " col=" + col);
      }
    }
   
    long t2 = System.currentTimeMillis();
   
    bs.close();
   
    if (count != NUM_TO_INGEST) {
      throw new Exception("Batch Scan did not return expected number of values " + count);
    }
   
View Full Code Here

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

   
    if (!caught)
      throw new Exception("Scan did not fail");
   
    // try to batch scan the table
    BatchScanner bs = getConnector().createBatchScanner("tt", Constants.NO_AUTHS, 2);
    bs.setRanges(Collections.singleton(new Range()));
   
    caught = false;
    try {
      for (Entry<Key,Value> entry : bs) {
        entry.getKey();
View Full Code Here

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

    Opts opts = new Opts();
    BatchScannerOpts bsOpts = new BatchScannerOpts();
    opts.parseArgs(RandomBatchScanner.class.getName(), args, bsOpts);
   
    Connector connector = opts.getConnector();
    BatchScanner batchReader = connector.createBatchScanner(opts.tableName, opts.auths, bsOpts.scanThreads);
    batchReader.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);
   
    Random r;
    if (opts.seed == null)
      r = new Random();
    else
      r = new Random(opts.seed);
   
    // do one cold
    boolean status = doRandomQueries(opts.num, opts.min, opts.max, opts.size, r, batchReader);
   
    System.gc();
    System.gc();
    System.gc();
   
    if (opts.seed == null)
      r = new Random();
    else
      r = new Random(opts.seed);
   
    // do one hot (connections already established, metadata table cached)
    status = status && doRandomQueries(opts.num, opts.min, opts.max, opts.size, r, batchReader);
   
    batchReader.close();
    if (!status) {
      System.exit(1);
    }
  }
View Full Code Here

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

    int refCount = 0;
   
    try {
      // look for other tables that references this tables files
      Connector conn = master.getConnector();
      BatchScanner bs = conn.createBatchScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS, 8);
      try {
        bs.setRanges(Collections.singleton(Constants.NON_ROOT_METADATA_KEYSPACE));
        bs.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
        IteratorSetting cfg = new IteratorSetting(40, "grep", GrepIterator.class);
        GrepIterator.setTerm(cfg, "../" + tableId + "/");
        bs.addScanIterator(cfg);
       
        for (Entry<Key,Value> entry : bs) {
          if (entry.getKey().getColumnQualifier().toString().startsWith("../" + tableId + "/")) {
            refCount++;
          }
        }
      } finally {
        bs.close();
      }
     
    } catch (Exception e) {
      refCount = -1;
      log.error("Failed to scan !METADATA looking for references to deleted table " + tableId, e);
View Full Code Here

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

      Mutation m = new Mutation(asText(r));
      m.put(asText(random.nextInt()), asText(random.nextInt()), new Value(Integer.toHexString(r).getBytes()));
      bw.addMutation(m);
    }
    bw.close();
    BatchScanner s = c.createBatchScanner("test", Constants.NO_AUTHS, 2);
    s.setRanges(Collections.singletonList(new Range()));
    Key key = null;
    int count = 0;
    for (Entry<Key,Value> entry : s) {
      if (key != null)
        assertTrue(key.compareTo(entry.getKey()) < 0);
View Full Code Here

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

    Opts opts = new Opts();
    BatchScannerOpts bsOpts = new BatchScannerOpts();
    opts.parseArgs(Query.class.getName(), args, bsOpts);
   
    Connector conn = opts.getConnector();
    BatchScanner bs = conn.createBatchScanner(opts.tableName, opts.auths, bsOpts.scanThreads);
    bs.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);
   
    Text columns[] = new Text[opts.terms.size()];
    int i = 0;
    for (String term : opts.terms) {
      columns[i++] = new Text(term);
    }
    IteratorSetting ii = new IteratorSetting(20, "ii", IntersectingIterator.class);
    IntersectingIterator.setColumnFamilies(ii, columns);
    bs.addScanIterator(ii);
    bs.setRanges(Collections.singleton(new Range()));
    for (Entry<Key,Value> entry : bs) {
      System.out.println("  " + entry.getKey().getColumnQualifier());
    }
   
  }
View Full Code Here

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

      }
     
      ranges.add(range);
    }
   
    BatchScanner bs = getConnector().createBatchScanner(table, Constants.NO_AUTHS, 3);
    bs.setRanges(ranges);
   
    long t1 = System.currentTimeMillis();
   
    for (Entry<Key,Value> entry : bs) {
      long v = Long.parseLong(entry.getValue().toString());
      if (!expected.remove(v)) {
        throw new Exception("Got unexpected return " + entry.getKey() + " " + entry.getValue());
      }
    }
   
    long t2 = System.currentTimeMillis();
   
    if (expected.size() > 0) {
      throw new Exception("Did not get all expected values " + expected.size());
    }
   
    bs.close();
   
    return t2 - t1;
  }
View Full Code Here

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

      ranges.add(new Range(new Text(String.format("%08x", (i << 8) - 16))));
    }
   
    getConnector().tableOperations().create("t3");
    getConnector().tableOperations().addSplits("t3", splits);
    BatchScanner bs = getConnector().createBatchScanner("t3", Constants.NO_AUTHS, 3);
    bs.setRanges(ranges);
    count = 0;
    for (Entry<Key,Value> entry : bs) {
      if (entry != null)
        count++;
    }
   
    if (count != 0) {
      throw new Exception("Did not see expected number of entries, count = " + count);
    }
   
    bs.close();
   
  }
View Full Code Here

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

    Scanner scanner = null;/*
                            * connector.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS); ColumnFQ.fetch(scanner,
                            * Constants.METADATA_LOCATION_COLUMN); ColumnFQ.fetch(scanner, Constants.METADATA_PREV_ROW_COLUMN);
                            */
   
    BatchScanner bs = connector.createBatchScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS, 1);
    bs.fetchColumnFamily(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY);
    Constants.METADATA_PREV_ROW_COLUMN.fetch(bs);
   
    bs.setRanges(ranges);
   
    // System.out.println(ranges);
   
    ScanStats stats = new ScanStats();
    for (int i = 0; i < numLoop; i++) {
View Full Code Here

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

      Mutation m = new Mutation(asText(r));
      m.put(asText(random.nextInt()), asText(random.nextInt()), new Value(Integer.toHexString(r).getBytes()));
      bw.addMutation(m);
    }
    bw.close();
    BatchScanner s = c.createBatchScanner("test", Constants.NO_AUTHS, 2);
    s.setRanges(Collections.singletonList(new Range()));
    Key key = null;
    int count = 0;
    for (Entry<Key,Value> entry : s) {
      if (key != null)
        assertTrue(key.compareTo(entry.getKey()) < 0);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.