Search in sources :

Example 6 with ScannerOpts

use of org.apache.accumulo.examples.cli.ScannerOpts in project accumulo-examples by apache.

the class TracingExample method main.

public static void main(String[] args) throws Exception {
    try {
        TracingExample tracingExample = new TracingExample();
        Opts opts = new Opts();
        ScannerOpts scannerOpts = new ScannerOpts();
        opts.parseArgs(TracingExample.class.getName(), args, scannerOpts);
        tracingExample.enableTracing(opts);
        tracingExample.execute(opts);
    } catch (Exception e) {
        log.error("Caught exception running TraceExample", e);
        System.exit(1);
    }
}
Also used : ScannerOpts(org.apache.accumulo.examples.cli.ScannerOpts) ScannerOpts(org.apache.accumulo.examples.cli.ScannerOpts) TableExistsException(org.apache.accumulo.core.client.TableExistsException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 7 with ScannerOpts

use of org.apache.accumulo.examples.cli.ScannerOpts in project accumulo-examples by apache.

the class CountIT method test.

@Test
public void test() throws Exception {
    Scanner scanner = conn.createScanner(tableName, new Authorizations());
    scanner.fetchColumn(new Text("dir"), new Text("counts"));
    assertFalse(scanner.iterator().hasNext());
    ScannerOpts scanOpts = new ScannerOpts();
    BatchWriterOpts bwOpts = new BatchWriterOpts();
    FileCount fc = new FileCount(conn, tableName, Authorizations.EMPTY, new ColumnVisibility(), scanOpts, bwOpts);
    fc.run();
    ArrayList<Pair<String, String>> expected = new ArrayList<>();
    expected.add(new Pair<>(QueryUtil.getRow("").toString(), "1,0,3,3"));
    expected.add(new Pair<>(QueryUtil.getRow("/local").toString(), "2,1,2,3"));
    expected.add(new Pair<>(QueryUtil.getRow("/local/user1").toString(), "0,2,0,2"));
    expected.add(new Pair<>(QueryUtil.getRow("/local/user2").toString(), "0,0,0,0"));
    int i = 0;
    for (Entry<Key, Value> e : scanner) {
        assertEquals(e.getKey().getRow().toString(), expected.get(i).getFirst());
        assertEquals(e.getValue().toString(), expected.get(i).getSecond());
        i++;
    }
    assertEquals(i, expected.size());
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) ScannerOpts(org.apache.accumulo.examples.cli.ScannerOpts) Value(org.apache.accumulo.core.data.Value) BatchWriterOpts(org.apache.accumulo.examples.cli.BatchWriterOpts) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Key(org.apache.accumulo.core.data.Key) Pair(org.apache.accumulo.core.util.Pair) Test(org.junit.Test)

Aggregations

ScannerOpts (org.apache.accumulo.examples.cli.ScannerOpts)7 BatchWriterOpts (org.apache.accumulo.examples.cli.BatchWriterOpts)4 Scanner (org.apache.accumulo.core.client.Scanner)3 Value (org.apache.accumulo.core.data.Value)3 Text (org.apache.hadoop.io.Text)3 Key (org.apache.accumulo.core.data.Key)2 Mutation (org.apache.accumulo.core.data.Mutation)2 ClientOpts (org.apache.accumulo.examples.cli.ClientOpts)2 ArrayList (java.util.ArrayList)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 BatchWriter (org.apache.accumulo.core.client.BatchWriter)1 Connector (org.apache.accumulo.core.client.Connector)1 TableExistsException (org.apache.accumulo.core.client.TableExistsException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 Authorizations (org.apache.accumulo.core.security.Authorizations)1 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)1 Pair (org.apache.accumulo.core.util.Pair)1 Test (org.junit.Test)1