use of org.apache.accumulo.core.util.format.FormatterConfig in project accumulo by apache.
the class GrepCommand 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);
if (cl.getArgList().isEmpty()) {
throw new MissingArgumentException("No terms specified");
}
final Class<? extends Formatter> formatter = getFormatter(cl, tableName, shellState);
final ScanInterpreter interpeter = getInterpreter(cl, tableName, shellState);
// handle first argument, if present, the authorizations list to
// scan with
int numThreads = 20;
if (cl.hasOption(numThreadsOpt.getOpt())) {
numThreads = Integer.parseInt(cl.getOptionValue(numThreadsOpt.getOpt()));
}
final Authorizations auths = getAuths(cl, shellState);
final BatchScanner scanner = shellState.getConnector().createBatchScanner(tableName, auths, numThreads);
scanner.setRanges(Collections.singletonList(getRange(cl, interpeter)));
scanner.setTimeout(getTimeout(cl), TimeUnit.MILLISECONDS);
setupSampling(tableName, cl, shellState, scanner);
for (int i = 0; i < cl.getArgs().length; i++) {
setUpIterator(Integer.MAX_VALUE - cl.getArgs().length + i, "grep" + i, cl.getArgs()[i], scanner, cl);
}
try {
// handle columns
fetchColumns(cl, scanner, interpeter);
// output the records
final FormatterConfig config = new FormatterConfig();
config.setPrintTimestamps(cl.hasOption(timestampOpt.getOpt()));
printRecords(cl, shellState, config, scanner, formatter, printFile);
} finally {
scanner.close();
}
}
return 0;
}
Aggregations