Search in sources :

Example 21 with ColumnVisibility

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;
    }
}
Also used : IsolatedScanner(org.apache.accumulo.core.client.IsolatedScanner) Scanner(org.apache.accumulo.core.client.Scanner) IOException(java.io.IOException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) Entry(java.util.Map.Entry) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) SortedKeyIterator(org.apache.accumulo.core.iterators.SortedKeyIterator) RowIterator(org.apache.accumulo.core.client.RowIterator) Value(org.apache.accumulo.core.data.Value) Mutation(org.apache.accumulo.core.data.Mutation) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Key(org.apache.accumulo.core.data.Key) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Aggregations

ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)21 Mutation (org.apache.accumulo.core.data.Mutation)16 Value (org.apache.accumulo.core.data.Value)11 Key (org.apache.accumulo.core.data.Key)10 Test (org.junit.Test)10 Entry (java.util.Map.Entry)9 BatchWriter (org.apache.accumulo.core.client.BatchWriter)9 Authorizations (org.apache.accumulo.core.security.Authorizations)9 Properties (java.util.Properties)8 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)8 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)8 Configuration (org.apache.hadoop.conf.Configuration)8 Element (uk.gov.gchq.gaffer.data.element.Element)8 AccumuloException (org.apache.accumulo.core.client.AccumuloException)7 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)7 Scanner (org.apache.accumulo.core.client.Scanner)7 Edge (uk.gov.gchq.gaffer.data.element.Edge)7 IteratorSettingBuilder (uk.gov.gchq.gaffer.accumulostore.utils.IteratorSettingBuilder)6 ColumnUpdate (org.apache.accumulo.core.data.ColumnUpdate)5 ByteArrayRef (org.apache.hadoop.hive.serde2.lazy.ByteArrayRef)5