Search in sources :

Example 1 with DeleterFormatter

use of org.apache.accumulo.shell.format.DeleterFormatter 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)

Aggregations

BatchWriter (org.apache.accumulo.core.client.BatchWriter)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 Scanner (org.apache.accumulo.core.client.Scanner)1 SortedKeyIterator (org.apache.accumulo.core.iterators.SortedKeyIterator)1 Authorizations (org.apache.accumulo.core.security.Authorizations)1 FormatterConfig (org.apache.accumulo.core.util.format.FormatterConfig)1 ScanInterpreter (org.apache.accumulo.core.util.interpret.ScanInterpreter)1 DeleterFormatter (org.apache.accumulo.shell.format.DeleterFormatter)1