use of org.apache.accumulo.core.security.ColumnVisibility in project gora by apache.
the class AccumuloStore method deleteByQuery.
@Override
public long deleteByQuery(Query<K, T> query) {
try {
Scanner scanner = createScanner(query);
// add iterator that drops values on the server side
scanner.addScanIterator(new IteratorSetting(Integer.MAX_VALUE, SortedKeyIterator.class));
RowIterator iterator = new RowIterator(scanner.iterator());
long count = 0;
while (iterator.hasNext()) {
Iterator<Entry<Key, Value>> row = iterator.next();
Mutation m = null;
while (row.hasNext()) {
Entry<Key, Value> entry = row.next();
Key key = entry.getKey();
if (m == null)
m = new Mutation(key.getRow());
// TODO optimize to avoid continually creating column vis? prob does not matter for empty
m.putDelete(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibility()), key.getTimestamp());
}
getBatchWriter().addMutation(m);
count++;
}
return count;
} catch (TableNotFoundException e) {
// TODO return 0?
LOG.error(e.getMessage(), e);
return 0;
} catch (MutationsRejectedException e) {
LOG.error(e.getMessage(), e);
return 0;
} catch (IOException e) {
LOG.error(e.getMessage(), e);
return 0;
}
}
Aggregations