Java Code Examples for org.apache.accumulo.core.security.ColumnVisibility#equals()

The following examples show how to use org.apache.accumulo.core.security.ColumnVisibility#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 6 votes vote down vote up
public boolean alterElementVisibility(Mutation m, AccumuloElement element, Visibility newVisibility, Object data) {
    ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(element.getVisibility());
    ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility);
    if (currentColumnVisibility.equals(newColumnVisibility)) {
        return false;
    }

    if (element instanceof AccumuloEdge) {
        AccumuloEdge edge = (AccumuloEdge) element;
        m.put(AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), currentColumnVisibility, currentTimeMillis(), toSignalDeletedValue(data));
        m.put(AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), newColumnVisibility, currentTimeMillis(), toSignalValue(data));

        m.putDelete(AccumuloEdge.CF_OUT_VERTEX, new Text(edge.getVertexId(Direction.OUT)), currentColumnVisibility, currentTimeMillis());
        m.put(AccumuloEdge.CF_OUT_VERTEX, new Text(edge.getVertexId(Direction.OUT)), newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE);

        m.putDelete(AccumuloEdge.CF_IN_VERTEX, new Text(edge.getVertexId(Direction.IN)), currentColumnVisibility, currentTimeMillis());
        m.put(AccumuloEdge.CF_IN_VERTEX, new Text(edge.getVertexId(Direction.IN)), newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE);
    } else if (element instanceof AccumuloVertex) {
        m.put(AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, currentColumnVisibility, currentTimeMillis(), toSignalDeletedValue(data));
        m.put(AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, newColumnVisibility, currentTimeMillis(), toSignalValue(data));
    } else {
        throw new IllegalArgumentException("Invalid element type: " + element);
    }
    return true;
}
 
Example 2
Source File: AccumuloGraph.java    From vertexium with Apache License 2.0 5 votes vote down vote up
public static Visibility accumuloVisibilityToVisibility(ColumnVisibility columnVisibility) {
    if (columnVisibility.equals(EMPTY_COLUMN_VISIBILITY)) {
        return Visibility.EMPTY;
    }
    String columnVisibilityString = columnVisibility.toString();
    return accumuloVisibilityToVisibility(columnVisibilityString);
}
 
Example 3
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 5 votes vote down vote up
public boolean alterEdgeVertexOutVertex(Mutation vertexOutMutation, Edge edge, Visibility newVisibility) {
    ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility());
    ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility);
    if (currentColumnVisibility.equals(newColumnVisibility)) {
        return false;
    }
    AccumuloEdgeInfo edgeInfo = new AccumuloEdgeInfo(getNameSubstitutionStrategy().deflate(edge.getLabel()), edge.getVertexId(Direction.IN));
    vertexOutMutation.putDelete(AccumuloVertex.CF_OUT_EDGE, new Text(edge.getId()), currentColumnVisibility);
    vertexOutMutation.put(AccumuloVertex.CF_OUT_EDGE, new Text(edge.getId()), newColumnVisibility, edgeInfo.toValue());
    return true;
}
 
Example 4
Source File: ElementMutationBuilder.java    From vertexium with Apache License 2.0 5 votes vote down vote up
public boolean alterEdgeVertexInVertex(Mutation vertexInMutation, Edge edge, Visibility newVisibility) {
    ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility());
    ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility);
    if (currentColumnVisibility.equals(newColumnVisibility)) {
        return false;
    }
    AccumuloEdgeInfo edgeInfo = new AccumuloEdgeInfo(getNameSubstitutionStrategy().deflate(edge.getLabel()), edge.getVertexId(Direction.OUT));
    vertexInMutation.putDelete(AccumuloVertex.CF_IN_EDGE, new Text(edge.getId()), currentColumnVisibility);
    vertexInMutation.put(AccumuloVertex.CF_IN_EDGE, new Text(edge.getId()), newColumnVisibility, edgeInfo.toValue());
    return true;
}
 
Example 5
Source File: MergeToolMapper.java    From rya with Apache License 2.0 4 votes vote down vote up
/**
 * Expert users can override this method for more complete control over
 * the execution of the Mapper.
 *
 * @param context
 * @throws IOException
 */
@Override
public void run(final Context context) throws IOException, InterruptedException {
    setup(context);
    this.context = context;

    try {
        RyaStatement parentRyaStatement = nextParentRyaStatement();
        RyaStatement childRyaStatement = nextChildRyaStatement();

        CompareKeysResult compareKeysResult = null;
        // Iteratively compare parent keys to child keys until finished
        while (compareKeysResult != CompareKeysResult.FINISHED) {
            compareKeysResult = compareKeys(parentRyaStatement, childRyaStatement);

            // Based on how the keys compare add or delete keys and advance the child or parent iterators forward
            switch (compareKeysResult) {
                case ADVANCE_CHILD:
                    childRyaStatement = nextChildRyaStatement();
                    break;
                case ADVANCE_PARENT:
                    parentRyaStatement = nextParentRyaStatement();
                    break;
                case ADVANCE_CHILD_AND_ADD:
                    final RyaStatement tempChildRyaStatement = childRyaStatement;
                    childRyaStatement = nextChildRyaStatement();
                    addKey(tempChildRyaStatement, context);
                    break;
                case ADVANCE_PARENT_AND_DELETE:
                    final RyaStatement tempParentRyaStatement = parentRyaStatement;
                    parentRyaStatement = nextParentRyaStatement();
                    deleteKey(tempParentRyaStatement, context);
                    break;
                case ADVANCE_BOTH:
                    final ColumnVisibility cv1 = new ColumnVisibility(parentRyaStatement.getColumnVisibility());
                    final ColumnVisibility cv2 = new ColumnVisibility(childRyaStatement.getColumnVisibility());

                    // Update new column visibility now if necessary
                    if (!cv1.equals(cv2) && !cv2.equals(AccumuloRdfConstants.EMPTY_CV)) {
                        final ColumnVisibility newCv = combineColumnVisibilities(cv1, cv2);
                        final RyaStatement newCvRyaStatement = updateRyaStatementColumnVisibility(parentRyaStatement, newCv);

                        deleteKey(parentRyaStatement, context);
                        addKey(newCvRyaStatement, context);
                    }

                    parentRyaStatement = nextParentRyaStatement();
                    childRyaStatement = nextChildRyaStatement();
                    break;
                case FINISHED:
                    log.info("Finished scanning parent and child tables");
                    break;
                default:
                    log.error("Unknown result: " + compareKeysResult);
                    break;
            }
        }
    } catch (MutationsRejectedException | TripleRowResolverException e) {
        log.error("Error encountered while merging", e);
    } finally {
        cleanup(context);
    }
}