public boolean alterEdgeVertexInVertex( Mutation vertexInMutation, Edge edge, Visibility newVisibility) { ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility); if (currentColumnVisibility.equals(newColumnVisibility)) { return false; } EdgeInfo edgeInfo = new EdgeInfo( 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; }
private void saveEdgeInfoOnVertex( AccumuloEdge edge, String edgeLabel, ColumnVisibility edgeColumnVisibility) { Text edgeIdText = new Text(edge.getId()); // Update out vertex. Mutation addEdgeToOutMutation = new Mutation(edge.getVertexId(Direction.OUT)); EdgeInfo edgeInfo = new EdgeInfo( getNameSubstitutionStrategy().deflate(edgeLabel), edge.getVertexId(Direction.IN)); addEdgeToOutMutation.put( AccumuloVertex.CF_OUT_EDGE, edgeIdText, edgeColumnVisibility, edgeInfo.toValue()); saveVertexMutation(addEdgeToOutMutation); // Update in vertex. Mutation addEdgeToInMutation = new Mutation(edge.getVertexId(Direction.IN)); edgeInfo = new EdgeInfo( getNameSubstitutionStrategy().deflate(edgeLabel), edge.getVertexId(Direction.OUT)); addEdgeToInMutation.put( AccumuloVertex.CF_IN_EDGE, edgeIdText, edgeColumnVisibility, edgeInfo.toValue()); saveVertexMutation(addEdgeToInMutation); }
public Iterable<KeyValuePair> getVertexTableKeyValuePairsEdge(AccumuloEdge edge) { List<KeyValuePair> results = new ArrayList<>(); ColumnVisibility edgeColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); String edgeLabel = edge.getNewEdgeLabel() != null ? edge.getNewEdgeLabel() : edge.getLabel(); Text edgeIdText = new Text(edge.getId()); long timestamp = edge.getTimestamp(); // out vertex. Text vertexOutIdRowKey = new Text(edge.getVertexId(Direction.OUT)); org.vertexium.accumulo.iterator.model.EdgeInfo edgeInfo = new EdgeInfo( getNameSubstitutionStrategy().deflate(edgeLabel), edge.getVertexId(Direction.IN)); results.add( new KeyValuePair( new Key( vertexOutIdRowKey, AccumuloVertex.CF_OUT_EDGE, edgeIdText, edgeColumnVisibility, timestamp), edgeInfo.toValue())); // in vertex. Text vertexInIdRowKey = new Text(edge.getVertexId(Direction.IN)); edgeInfo = new EdgeInfo( getNameSubstitutionStrategy().deflate(edgeLabel), edge.getVertexId(Direction.OUT)); results.add( new KeyValuePair( new Key( vertexInIdRowKey, AccumuloVertex.CF_IN_EDGE, edgeIdText, edgeColumnVisibility, timestamp), edgeInfo.toValue())); return results; }