Search in sources :

Example 6 with Column

use of org.apache.accumulo.core.data.Column in project vertexium by visallo.

the class AccumuloGraphLogger method logStartIterator.

public void logStartIterator(ScannerBase scanner) {
    if (!queryLogger.isTraceEnabled()) {
        return;
    }
    SortedSet<Column> fetchedColumns = null;
    if (scanner instanceof ScannerOptions) {
        fetchedColumns = ((ScannerOptions) scanner).getFetchedColumns();
    }
    String table = null;
    try {
        Field tableField = scanner.getClass().getDeclaredField("table");
        tableField.setAccessible(true);
        Object tableObj = tableField.get(scanner);
        if (tableObj instanceof String) {
            table = (String) tableObj;
        } else {
            table = tableObj.toString();
        }
    } catch (Exception e) {
        queryLogger.trace("Could not get table name from scanner", e);
    }
    if (scanner instanceof BatchScanner) {
        try {
            Field rangesField = scanner.getClass().getDeclaredField("ranges");
            rangesField.setAccessible(true);
            ArrayList<Range> ranges = (ArrayList<Range>) rangesField.get(scanner);
            if (ranges.size() == 0) {
                logStartIterator(table, (Range) null, fetchedColumns);
            } else if (ranges.size() == 1) {
                logStartIterator(table, ranges.iterator().next(), fetchedColumns);
            } else {
                logStartIterator(table, ranges, fetchedColumns);
            }
        } catch (Exception e) {
            queryLogger.trace("Could not get ranges from BatchScanner", e);
        }
    } else if (scanner instanceof Scanner) {
        Range range = ((Scanner) scanner).getRange();
        logStartIterator(table, range, fetchedColumns);
    } else {
        queryLogger.trace("begin accumulo iterator: %s", scanner.getClass().getName());
    }
}
Also used : Field(java.lang.reflect.Field) BatchScanner(org.apache.accumulo.core.client.BatchScanner) Scanner(org.apache.accumulo.core.client.Scanner) Column(org.apache.accumulo.core.data.Column) BatchScanner(org.apache.accumulo.core.client.BatchScanner) ArrayList(java.util.ArrayList) ScannerOptions(org.apache.accumulo.core.client.impl.ScannerOptions) Range(org.apache.accumulo.core.data.Range)

Example 7 with Column

use of org.apache.accumulo.core.data.Column in project accumulo by apache.

the class ScannerOptionsTest method testFetchColumn.

@Test
public void testFetchColumn() {
    try (ScannerOptions options = new ScannerOptions()) {
        assertEquals(0, options.getFetchedColumns().size());
        IteratorSetting.Column col = new IteratorSetting.Column(new Text("family"), new Text("qualifier"));
        options.fetchColumn(col);
        SortedSet<Column> fetchedColumns = options.getFetchedColumns();
        assertEquals(1, fetchedColumns.size());
        Column fetchCol = fetchedColumns.iterator().next();
        assertEquals(col.getColumnFamily(), new Text(fetchCol.getColumnFamily()));
        assertEquals(col.getColumnQualifier(), new Text(fetchCol.getColumnQualifier()));
    }
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Column(org.apache.accumulo.core.data.Column) Text(org.apache.hadoop.io.Text) Test(org.junit.Test)

Example 8 with Column

use of org.apache.accumulo.core.data.Column in project accumulo by apache.

the class ScannerOptions method fetchColumn.

@Override
public synchronized void fetchColumn(Text colFam, Text colQual) {
    checkArgument(colFam != null, "colFam is null");
    checkArgument(colQual != null, "colQual is null");
    Column c = new Column(TextUtil.getBytes(colFam), TextUtil.getBytes(colQual), null);
    fetchedColumns.add(c);
}
Also used : Column(org.apache.accumulo.core.data.Column)

Example 9 with Column

use of org.apache.accumulo.core.data.Column in project accumulo by apache.

the class TestRandomDeletes method scanAll.

private static TreeSet<RowColumn> scanAll(ClientOnDefaultTable opts, ScannerOpts scanOpts, String tableName) throws Exception {
    TreeSet<RowColumn> result = new TreeSet<>();
    Connector conn = opts.getConnector();
    try (Scanner scanner = conn.createScanner(tableName, auths)) {
        scanner.setBatchSize(scanOpts.scanBatchSize);
        for (Entry<Key, Value> entry : scanner) {
            Key key = entry.getKey();
            Column column = new Column(TextUtil.getBytes(key.getColumnFamily()), TextUtil.getBytes(key.getColumnQualifier()), TextUtil.getBytes(key.getColumnVisibility()));
            result.add(new RowColumn(key.getRow(), column, key.getTimestamp()));
        }
    }
    return result;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Scanner(org.apache.accumulo.core.client.Scanner) Column(org.apache.accumulo.core.data.Column) TreeSet(java.util.TreeSet) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key)

Example 10 with Column

use of org.apache.accumulo.core.data.Column in project accumulo by apache.

the class RFileScanner method iterator.

@Override
public Iterator<Entry<Key, Value>> iterator() {
    try {
        RFileSource[] sources = opts.in.getSources();
        List<SortedKeyValueIterator<Key, Value>> readers = new ArrayList<>(sources.length);
        for (int i = 0; i < sources.length; i++) {
            // TODO may have been a bug with multiple files and caching in older version...
            FSDataInputStream inputStream = (FSDataInputStream) sources[i].getInputStream();
            readers.add(new RFile.Reader(new CachableBlockFile.Reader("source-" + i, inputStream, sources[i].getLength(), opts.in.getConf(), dataCache, indexCache, DefaultConfiguration.getInstance())));
        }
        if (getSamplerConfiguration() != null) {
            for (int i = 0; i < readers.size(); i++) {
                readers.set(i, ((Reader) readers.get(i)).getSample(new SamplerConfigurationImpl(getSamplerConfiguration())));
            }
        }
        SortedKeyValueIterator<Key, Value> iterator;
        if (opts.bounds != null) {
            iterator = new MultiIterator(readers, opts.bounds);
        } else {
            iterator = new MultiIterator(readers, false);
        }
        Set<ByteSequence> families = Collections.emptySet();
        if (opts.useSystemIterators) {
            SortedSet<Column> cols = this.getFetchedColumns();
            families = LocalityGroupUtil.families(cols);
            iterator = IteratorUtil.setupSystemScanIterators(iterator, cols, getAuthorizations(), EMPTY_BYTES);
        }
        try {
            if (opts.tableConfig != null && opts.tableConfig.size() > 0) {
                ConfigurationCopy conf = new ConfigurationCopy(opts.tableConfig);
                iterator = IteratorUtil.loadIterators(IteratorScope.scan, iterator, null, conf, serverSideIteratorList, serverSideIteratorOptions, new IterEnv());
            } else {
                iterator = IteratorUtil.loadIterators(iterator, serverSideIteratorList, serverSideIteratorOptions, new IterEnv(), false, null);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        iterator.seek(getRange() == null ? EMPTY_RANGE : getRange(), families, families.size() == 0 ? false : true);
        return new IteratorAdapter(iterator);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : MultiIterator(org.apache.accumulo.core.iterators.system.MultiIterator) ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) IteratorAdapter(org.apache.accumulo.core.iterators.IteratorAdapter) SamplerConfigurationImpl(org.apache.accumulo.core.sample.impl.SamplerConfigurationImpl) ArrayList(java.util.ArrayList) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) Reader(org.apache.accumulo.core.file.rfile.RFile.Reader) RFile(org.apache.accumulo.core.file.rfile.RFile) IOException(java.io.IOException) Reader(org.apache.accumulo.core.file.rfile.RFile.Reader) Column(org.apache.accumulo.core.data.Column) Value(org.apache.accumulo.core.data.Value) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) Key(org.apache.accumulo.core.data.Key) ByteSequence(org.apache.accumulo.core.data.ByteSequence)

Aggregations

Column (org.apache.accumulo.core.data.Column)16 Key (org.apache.accumulo.core.data.Key)10 Value (org.apache.accumulo.core.data.Value)10 HashSet (java.util.HashSet)6 TreeMap (java.util.TreeMap)6 Range (org.apache.accumulo.core.data.Range)6 SortedMapIterator (org.apache.accumulo.core.iterators.SortedMapIterator)5 Text (org.apache.hadoop.io.Text)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Scanner (org.apache.accumulo.core.client.Scanner)3 Test (org.junit.Test)3 TreeSet (java.util.TreeSet)2 BatchScanner (org.apache.accumulo.core.client.BatchScanner)2 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)2 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2 IteratorAdapter (org.apache.accumulo.core.iterators.IteratorAdapter)2 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1