Search in sources :

Example 11 with SamplerConfiguration

use of org.apache.accumulo.core.client.sample.SamplerConfiguration in project accumulo by apache.

the class ScanCommand method setupSampling.

protected void setupSampling(final String tableName, final CommandLine cl, final Shell shellState, ScannerBase scanner) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
    if (getUseSample(cl)) {
        SamplerConfiguration samplerConfig = shellState.getConnector().tableOperations().getSamplerConfiguration(tableName);
        if (samplerConfig == null) {
            throw new SampleNotPresentException("Table " + tableName + " does not have sampling configured");
        }
        Shell.log.debug("Using sampling configuration : " + samplerConfig);
        scanner.setSamplerConfiguration(samplerConfig);
    }
}
Also used : SampleNotPresentException(org.apache.accumulo.core.client.SampleNotPresentException) SamplerConfiguration(org.apache.accumulo.core.client.sample.SamplerConfiguration)

Example 12 with SamplerConfiguration

use of org.apache.accumulo.core.client.sample.SamplerConfiguration in project accumulo-examples by apache.

the class Query method main.

public static void main(String[] args) throws Exception {
    Opts opts = new Opts();
    BatchScannerOpts bsOpts = new BatchScannerOpts();
    opts.parseArgs(Query.class.getName(), args, bsOpts);
    Connector conn = opts.getConnector();
    BatchScanner bs = conn.createBatchScanner(opts.getTableName(), opts.auths, bsOpts.scanThreads);
    bs.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);
    if (opts.useSample) {
        SamplerConfiguration samplerConfig = conn.tableOperations().getSamplerConfiguration(opts.getTableName());
        CutoffIntersectingIterator.validateSamplerConfig(conn.tableOperations().getSamplerConfiguration(opts.getTableName()));
        bs.setSamplerConfiguration(samplerConfig);
    }
    for (String entry : query(bs, opts.terms, opts.sampleCutoff)) System.out.println("  " + entry);
    bs.close();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) BatchScannerOpts(org.apache.accumulo.examples.cli.BatchScannerOpts) BatchScannerOpts(org.apache.accumulo.examples.cli.BatchScannerOpts) BatchScanner(org.apache.accumulo.core.client.BatchScanner) SamplerConfiguration(org.apache.accumulo.core.client.sample.SamplerConfiguration)

Aggregations

SamplerConfiguration (org.apache.accumulo.core.client.sample.SamplerConfiguration)12 SampleNotPresentException (org.apache.accumulo.core.client.SampleNotPresentException)4 RowSampler (org.apache.accumulo.core.client.sample.RowSampler)4 Test (org.junit.Test)4 SummarizerConfiguration (org.apache.accumulo.core.client.summary.SummarizerConfiguration)3 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)3 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 SamplerConfigurationImpl (org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl)3 Connector (org.apache.accumulo.core.client.Connector)2 Scanner (org.apache.accumulo.core.client.Scanner)2 Configuration (org.apache.hadoop.conf.Configuration)2 IOException (java.io.IOException)1 TreeMap (java.util.TreeMap)1 BatchScanner (org.apache.accumulo.core.client.BatchScanner)1 BatchWriter (org.apache.accumulo.core.client.BatchWriter)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 ScannerBase (org.apache.accumulo.core.client.ScannerBase)1 CompactionConfig (org.apache.accumulo.core.client.admin.CompactionConfig)1 NewTableConfiguration (org.apache.accumulo.core.client.admin.NewTableConfiguration)1