use of org.apache.accumulo.examples.cli.BatchScannerOpts in project accumulo-examples by apache.
the class ContinuousQuery method main.
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
BatchScannerOpts bsOpts = new BatchScannerOpts();
opts.parseArgs(ContinuousQuery.class.getName(), args, bsOpts);
Connector conn = opts.getConnector();
ArrayList<Text[]> randTerms = findRandomTerms(conn.createScanner(opts.doc2Term, opts.auths), opts.numTerms);
Random rand = new Random();
BatchScanner bs = conn.createBatchScanner(opts.tableName, opts.auths, bsOpts.scanThreads);
bs.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);
for (long i = 0; i < opts.iterations; i += 1) {
Text[] columns = randTerms.get(rand.nextInt(randTerms.size()));
bs.clearScanIterators();
bs.clearColumns();
IteratorSetting ii = new IteratorSetting(20, "ii", IntersectingIterator.class);
IntersectingIterator.setColumnFamilies(ii, columns);
bs.addScanIterator(ii);
bs.setRanges(Collections.singleton(new Range()));
long t1 = System.currentTimeMillis();
int count = Iterators.size(bs.iterator());
long t2 = System.currentTimeMillis();
System.out.printf(" %s %,d %6.3f%n", Arrays.asList(columns), count, (t2 - t1) / 1000.0);
}
bs.close();
}
use of org.apache.accumulo.examples.cli.BatchScannerOpts in project accumulo-examples by apache.
the class RandomBatchScanner method main.
/**
* Scans over a specified number of entries to Accumulo using a {@link BatchScanner}. Completes scans twice to compare times for a fresh query with those for
* a repeated query which has cached metadata and connections already established.
*/
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
Opts opts = new Opts();
BatchScannerOpts bsOpts = new BatchScannerOpts();
opts.parseArgs(RandomBatchScanner.class.getName(), args, bsOpts);
Connector connector = opts.getConnector();
BatchScanner batchReader = connector.createBatchScanner(opts.getTableName(), 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);
}
}
use of org.apache.accumulo.examples.cli.BatchScannerOpts in project accumulo-examples by apache.
the class Query method main.
public static void main(String[] args) throws Exception {
Opts opts = new Opts();
BatchScannerOpts bsOpts = new BatchScannerOpts();
opts.parseArgs(Query.class.getName(), args, bsOpts);
Connector conn = opts.getConnector();
BatchScanner bs = conn.createBatchScanner(opts.getTableName(), opts.auths, bsOpts.scanThreads);
bs.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);
if (opts.useSample) {
SamplerConfiguration samplerConfig = conn.tableOperations().getSamplerConfiguration(opts.getTableName());
CutoffIntersectingIterator.validateSamplerConfig(conn.tableOperations().getSamplerConfiguration(opts.getTableName()));
bs.setSamplerConfiguration(samplerConfig);
}
for (String entry : query(bs, opts.terms, opts.sampleCutoff)) System.out.println(" " + entry);
bs.close();
}
Aggregations