Search in sources :

Example 71 with ColumnVisibility

use of org.apache.accumulo.core.security.ColumnVisibility in project incubator-rya by apache.

the class EntityCentricIndex method createMutation.

private static Mutation createMutation(final TripleRow tripleRow) {
    final Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
    final byte[] columnVisibility = tripleRow.getColumnVisibility();
    final ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
    final Long timestamp = tripleRow.getTimestamp();
    final byte[] value = tripleRow.getValue();
    final Value v = value == null ? EMPTY_VALUE : new Value(value);
    final byte[] columnQualifier = tripleRow.getColumnQualifier();
    final Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
    final byte[] columnFamily = tripleRow.getColumnFamily();
    final Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
    mutation.put(cfText, cqText, cv, timestamp, v);
    return mutation;
}
Also used : Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility)

Example 72 with ColumnVisibility

use of org.apache.accumulo.core.security.ColumnVisibility in project incubator-rya by apache.

the class MergeToolMapper method writeMutation.

/**
 * Writes a mutation to the specified table.  If the mutation is meant to delete then the mutation will
 * be transformed to a delete mutation.
 * @param table the table to write to.
 * @param mutation the {@link mutation}.
 * @param context the {@link Context}.
 * @param isDelete {@code true} if the mutation should be a delete mutation.  {@code false} otherwise.
 * @throws IOException
 * @throws InterruptedException
 */
private static void writeMutation(final Text table, final Mutation mutation, final Context context, final boolean isDelete) throws IOException, InterruptedException {
    if (isDelete) {
        final List<ColumnUpdate> updates = mutation.getUpdates();
        final ColumnUpdate columnUpdate = updates.get(0);
        final ColumnVisibility cv = columnUpdate.getColumnVisibility() != null ? new ColumnVisibility(columnUpdate.getColumnVisibility()) : null;
        final Mutation deleteMutation = new Mutation(new Text(mutation.getRow()));
        deleteMutation.putDelete(columnUpdate.getColumnFamily(), columnUpdate.getColumnQualifier(), cv, columnUpdate.getTimestamp());
        context.write(table, deleteMutation);
    } else {
        context.write(table, mutation);
    }
}
Also used : ColumnUpdate(org.apache.accumulo.core.data.ColumnUpdate) Text(org.apache.hadoop.io.Text) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Mutation(org.apache.accumulo.core.data.Mutation)

Example 73 with ColumnVisibility

use of org.apache.accumulo.core.security.ColumnVisibility in project incubator-rya by apache.

the class PcjTables method makeWriteResultMutations.

/**
 * Create the {@link Mutations} required to write a new {@link BindingSet}
 * to a PCJ table for each {@link VariableOrder} that is provided.
 *
 * @param varOrders - The variables orders the result will be written to. (not null)
 * @param result - A new PCJ result. (not null)
 * @return Mutation that will write the result to a PCJ table.
 * @throws PCJStorageException The binding set could not be encoded.
 */
private static Set<Mutation> makeWriteResultMutations(final Set<VariableOrder> varOrders, final VisibilityBindingSet result) throws PCJStorageException {
    checkNotNull(varOrders);
    checkNotNull(result);
    final Set<Mutation> mutations = new HashSet<>();
    final AccumuloPcjSerializer converter = new AccumuloPcjSerializer();
    VisibilityBindingSetSerDe bsSerDe = new VisibilityBindingSetSerDe();
    for (final VariableOrder varOrder : varOrders) {
        try {
            // Serialize the result to the variable order.
            final byte[] rowKey = converter.convert(result, varOrder);
            // Row ID = binding set values, Column Family = variable order of the binding set.
            final Mutation addResult = new Mutation(rowKey);
            final String visibility = result.getVisibility();
            addResult.put(varOrder.toString(), "", new ColumnVisibility(visibility), new Value(bsSerDe.serialize(result).toArray()));
            mutations.add(addResult);
        } catch (Exception e) {
            throw new PCJStorageException("Could not serialize a result.", e);
        }
    }
    return mutations;
}
Also used : Value(org.apache.accumulo.core.data.Value) Mutation(org.apache.accumulo.core.data.Mutation) ConditionalMutation(org.apache.accumulo.core.data.ConditionalMutation) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) RepositoryException(org.openrdf.repository.RepositoryException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) MalformedQueryException(org.openrdf.query.MalformedQueryException) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) HashSet(java.util.HashSet)

Example 74 with ColumnVisibility

use of org.apache.accumulo.core.security.ColumnVisibility in project incubator-rya by apache.

the class EntityCentricIndexTest method createMutationFromKeyValue.

private static Mutation createMutationFromKeyValue(Key key, Value value) {
    Mutation m = new Mutation(key.getRow());
    m.put(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibility()), key.getTimestamp(), value);
    return m;
}
Also used : Mutation(org.apache.accumulo.core.data.Mutation) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility)

Example 75 with ColumnVisibility

use of org.apache.accumulo.core.security.ColumnVisibility in project incubator-rya by apache.

the class RyaTableMutationsFactory method createMutation.

protected Mutation createMutation(TripleRow tripleRow) {
    Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
    byte[] columnVisibility = tripleRow.getColumnVisibility();
    ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
    Long timestamp = tripleRow.getTimestamp();
    byte[] value = tripleRow.getValue();
    Value v = value == null ? EMPTY_VALUE : new Value(value);
    byte[] columnQualifier = tripleRow.getColumnQualifier();
    Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
    byte[] columnFamily = tripleRow.getColumnFamily();
    Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
    mutation.put(cfText, cqText, cv, timestamp, v);
    return mutation;
}
Also used : Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility)

Aggregations

ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)131 Mutation (org.apache.accumulo.core.data.Mutation)57 Text (org.apache.hadoop.io.Text)57 Value (org.apache.accumulo.core.data.Value)52 Key (org.apache.accumulo.core.data.Key)39 Test (org.junit.Test)37 BatchWriter (org.apache.accumulo.core.client.BatchWriter)28 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)20 Authorizations (org.apache.accumulo.core.security.Authorizations)17 ArrayList (java.util.ArrayList)16 Entry (java.util.Map.Entry)16 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)16 Scanner (org.apache.accumulo.core.client.Scanner)14 AccumuloException (org.apache.accumulo.core.client.AccumuloException)12 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)12 Configuration (org.apache.hadoop.conf.Configuration)12 Connector (org.apache.accumulo.core.client.Connector)10 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)10 TMutation (org.apache.accumulo.core.data.thrift.TMutation)10 Element (uk.gov.gchq.gaffer.data.element.Element)9