final String tableName,
final ByteArrayId dataId,
final ByteArrayId adapterId,
final String... authorizations ) {
ScannerBase scanner = null;
try {
scanner = accumuloOperations.createScanner(
tableName,
authorizations);
scanner.fetchColumnFamily(new Text(
adapterId.getBytes()));
final IteratorSetting rowIteratorSettings = new IteratorSetting(
SingleEntryFilterIterator.WHOLE_ROW_ITERATOR_PRIORITY,
SingleEntryFilterIterator.WHOLE_ROW_ITERATOR_NAME,
WholeRowIterator.class);
scanner.addScanIterator(rowIteratorSettings);
final IteratorSetting filterIteratorSettings = new IteratorSetting(
SingleEntryFilterIterator.ENTRY_FILTER_ITERATOR_PRIORITY,
SingleEntryFilterIterator.ENTRY_FILTER_ITERATOR_NAME,
SingleEntryFilterIterator.class);
filterIteratorSettings.addOption(
SingleEntryFilterIterator.ADAPTER_ID,
ByteArrayUtils.byteArrayToString(adapterId.getBytes()));
filterIteratorSettings.addOption(
SingleEntryFilterIterator.DATA_ID,
ByteArrayUtils.byteArrayToString(dataId.getBytes()));
scanner.addScanIterator(filterIteratorSettings);
final Iterator<Map.Entry<Key, Value>> iterator = scanner.iterator();
if (iterator.hasNext()) {
return iterator.next();
}
}
catch (final TableNotFoundException e) {
LOGGER.warn(
"Unable to query table '" + tableName + "'. Table does not exist.",
e);
}
finally {
if (scanner != null)
scanner.close();
}
return null;
}