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());
}
}
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()));
}
}
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);
}
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;
}
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);
}
}
Aggregations