use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.
the class DeleterFormatterTest method testSingle.
@Test
public void testSingle() throws IOException {
formatter = new DeleterFormatter(writer, data.entrySet(), new FormatterConfig().setPrintTimestamps(true), shellState, true);
assertTrue(formatter.hasNext());
assertNull(formatter.next());
verify("[DELETED]", " r ", "cf", "cq", "value");
}
use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.
the class DeleterFormatterTest method testNoConfirmation.
@Test
public void testNoConfirmation() throws IOException {
input.set("");
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");
assertFalse(formatter.hasNext());
}
use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.
the class DeleterFormatterTest method testMutationException.
@Test
public void testMutationException() {
formatter = new DeleterFormatter(exceptionWriter, data.entrySet(), new FormatterConfig().setPrintTimestamps(true), shellState, true);
assertTrue(formatter.hasNext());
assertNull(formatter.next());
assertFalse(formatter.hasNext());
}
use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.
the class DeleterFormatterTest method testEmpty.
@Test
public void testEmpty() {
formatter = new DeleterFormatter(writer, Collections.<Key, Value>emptyMap().entrySet(), new FormatterConfig().setPrintTimestamps(true), shellState, true);
assertFalse(formatter.hasNext());
}
use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.
the class ScanCommand method execute.
@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {
try (final PrintFile printFile = getOutputFile(cl)) {
final String tableName = OptUtil.getTableOpt(cl, shellState);
final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
String classLoaderContext = null;
if (cl.hasOption(contextOpt.getOpt())) {
classLoaderContext = cl.getOptionValue(contextOpt.getOpt());
}
// 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);
if (null != classLoaderContext) {
scanner.setClassLoaderContext(classLoaderContext);
}
// handle session-specific scan iterators
addScanIterators(shellState, cl, scanner, tableName);
// handle remaining optional arguments
scanner.setRange(getRange(cl, interpeter));
// handle columns
fetchColumns(cl, scanner, interpeter);
// set timeout
scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
setupSampling(tableName, cl, shellState, scanner);
// output the records
final FormatterConfig config = new FormatterConfig();
config.setPrintTimestamps(cl.hasOption(timestampOpt.getOpt()));
if (cl.hasOption(showFewOpt.getOpt())) {
final String showLength = cl.getOptionValue(showFewOpt.getOpt());
try {
final int length = Integer.parseInt(showLength);
config.setShownLength(length);
} catch (NumberFormatException nfe) {
shellState.getReader().println("Arg must be an integer.");
} catch (IllegalArgumentException iae) {
shellState.getReader().println("Arg must be greater than one.");
}
}
printRecords(cl, shellState, config, scanner, formatter, printFile);
}
return 0;
}
Aggregations