Search in sources :

Example 6 with FormatterConfig

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");
}
Also used : FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig) Test(org.junit.Test)

Example 7 with FormatterConfig

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());
}
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 8 with FormatterConfig

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());
}
Also used : FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig) Test(org.junit.Test)

Example 9 with FormatterConfig

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());
}
Also used : FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig) Test(org.junit.Test)

Example 10 with FormatterConfig

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;
}
Also used : DefaultScanInterpreter(org.apache.accumulo.core.util.interpret.DefaultScanInterpreter) ScanInterpreter(org.apache.accumulo.core.util.interpret.ScanInterpreter) Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) FormatterConfig(org.apache.accumulo.core.util.format.FormatterConfig) PrintFile(org.apache.accumulo.shell.Shell.PrintFile)

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