Search in sources :

Example 1 with FormatterConfig

use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.

the class DeleterFormatterTest method testYes.

@Test
public void testYes() throws IOException {
    input.set("y\nyes\n");
    data.put(new Key("z"), new Value("v2".getBytes(UTF_8)));
    formatter = new DeleterFormatter(writer, data.entrySet(), new FormatterConfig().setPrintTimestamps(true), shellState, false);
    assertTrue(formatter.hasNext());
    assertNull(formatter.next());
    verify("[DELETED]", " r ", "cf", "cq", "value");
    assertTrue(formatter.hasNext());
    assertNull(formatter.next());
    verify("[DELETED]", " z ", "v2");
}
Also used : FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 2 with FormatterConfig

use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.

the class DeleterFormatterTest method testNo.

@Test
public void testNo() throws IOException {
    input.set("no\n");
    data.put(new Key("z"), new Value("v2".getBytes(UTF_8)));
    formatter = new DeleterFormatter(writer, data.entrySet(), new FormatterConfig().setPrintTimestamps(true), shellState, false);
    assertTrue(formatter.hasNext());
    assertNull(formatter.next());
    verify("[SKIPPED]", " r ", "cf", "cq", "value");
    assertTrue(formatter.hasNext());
}
Also used : FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 3 with FormatterConfig

use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.

the class DeleteManyCommand method execute.

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
    final String tableName = OptUtil.getTableOpt(cl, shellState);
    final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
    // handle first argument, if present, the authorizations list to
    // scan with
    final Authorizations auths = getAuths(cl, shellState);
    final Scanner scanner = shellState.getConnector().createScanner(tableName, auths);
    scanner.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, "NOVALUE", SortedKeyIterator.class));
    // handle session-specific scan iterators
    addScanIterators(shellState, cl, scanner, tableName);
    // handle remaining optional arguments
    scanner.setRange(getRange(cl, interpeter));
    scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
    // handle columns
    fetchColumns(cl, scanner, interpeter);
    // output / delete the records
    final BatchWriter writer = shellState.getConnector().createBatchWriter(tableName, new BatchWriterConfig().setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS));
    FormatterConfig config = new FormatterConfig();
    config.setPrintTimestamps(cl.hasOption(timestampOpt.getOpt()));
    shellState.printLines(new DeleterFormatter(writer, scanner, config, shellState, cl.hasOption(forceOpt.getOpt())), false);
    return 0;
}
Also used : ScanInterpreter(org.apache.accumulo.core.util.interpret.ScanInterpreter) Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig) SortedKeyIterator(org.apache.accumulo.core.iterators.SortedKeyIterator) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) BatchWriter(org.apache.accumulo.core.client.BatchWriter) DeleterFormatter(org.apache.accumulo.shell.format.DeleterFormatter)

Example 4 with FormatterConfig

use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.

the class TraceFormatter method initialize.

@Override
public void initialize(Iterable<Entry<Key, Value>> scanner, FormatterConfig config) {
    this.scanner = scanner.iterator();
    this.config = new FormatterConfig(config);
}
Also used : FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig)

Example 5 with FormatterConfig

use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.

the class StatusFormatter method initialize.

@Override
public void initialize(Iterable<Entry<Key, Value>> scanner, FormatterConfig config) {
    this.iterator = scanner.iterator();
    this.config = new FormatterConfig(config);
}
Also used : FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig)

Aggregations

FormatterConfig (org.apache.accumulo.core.util.format.FormatterConfig)11 Test (org.junit.Test)6 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 Authorizations (org.apache.accumulo.core.security.Authorizations)3 ScanInterpreter (org.apache.accumulo.core.util.interpret.ScanInterpreter)3 Scanner (org.apache.accumulo.core.client.Scanner)2 PrintFile (org.apache.accumulo.shell.Shell.PrintFile)2 BatchScanner (org.apache.accumulo.core.client.BatchScanner)1 BatchWriter (org.apache.accumulo.core.client.BatchWriter)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 SortedKeyIterator (org.apache.accumulo.core.iterators.SortedKeyIterator)1 DefaultScanInterpreter (org.apache.accumulo.core.util.interpret.DefaultScanInterpreter)1 DeleterFormatter (org.apache.accumulo.shell.format.DeleterFormatter)1 MissingArgumentException (org.apache.commons.cli.MissingArgumentException)1