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