public void saveEdge(AccumuloEdge edge) { ColumnVisibility edgeColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); Mutation m = createMutationForEdge(edge, edgeColumnVisibility); saveEdgeMutation(m); String edgeLabel = edge.getNewEdgeLabel() != null ? edge.getNewEdgeLabel() : edge.getLabel(); saveEdgeInfoOnVertex(edge, edgeLabel, edgeColumnVisibility); }
public void alterEdgeLabel(AccumuloEdge edge, String newEdgeLabel) { ColumnVisibility edgeColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); Mutation m = createAlterEdgeLabelMutation(edge, newEdgeLabel, edgeColumnVisibility); saveEdgeMutation(m); saveEdgeInfoOnVertex(edge, newEdgeLabel, edgeColumnVisibility); }
private Mutation createAlterEdgeLabelMutation( AccumuloEdge edge, String newEdgeLabel, ColumnVisibility edgeColumnVisibility) { String edgeRowKey = edge.getId(); Mutation m = new Mutation(edgeRowKey); m.putDelete( AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), edgeColumnVisibility, currentTimeMillis()); m.put( AccumuloEdge.CF_SIGNAL, new Text(newEdgeLabel), edgeColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE); return m; }
public boolean alterElementVisibility( Mutation m, AccumuloElement element, Visibility newVisibility) { ColumnVisibility currentColumnVisibility = visibilityToAccumuloVisibility(element.getVisibility()); ColumnVisibility newColumnVisibility = visibilityToAccumuloVisibility(newVisibility); if (currentColumnVisibility.equals(newColumnVisibility)) { return false; } if (element instanceof AccumuloEdge) { AccumuloEdge edge = (AccumuloEdge) element; m.putDelete( AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), currentColumnVisibility, currentTimeMillis()); m.put( AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE); 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.putDelete( AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, currentColumnVisibility, currentTimeMillis()); m.put( AccumuloVertex.CF_SIGNAL, EMPTY_TEXT, newColumnVisibility, currentTimeMillis(), ElementMutationBuilder.EMPTY_VALUE); } else { throw new IllegalArgumentException("Invalid element type: " + element); } 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; }
private Mutation createMutationForEdge(AccumuloEdge edge, ColumnVisibility edgeColumnVisibility) { String edgeRowKey = edge.getId(); Mutation m = new Mutation(edgeRowKey); String edgeLabel = edge.getLabel(); if (edge.getNewEdgeLabel() != null) { edgeLabel = edge.getNewEdgeLabel(); m.putDelete( AccumuloEdge.CF_SIGNAL, new Text(edge.getLabel()), edgeColumnVisibility, currentTimeMillis()); } m.put( AccumuloEdge.CF_SIGNAL, new Text(edgeLabel), edgeColumnVisibility, edge.getTimestamp(), ElementMutationBuilder.EMPTY_VALUE); m.put( AccumuloEdge.CF_OUT_VERTEX, new Text(edge.getVertexId(Direction.OUT)), edgeColumnVisibility, edge.getTimestamp(), ElementMutationBuilder.EMPTY_VALUE); m.put( AccumuloEdge.CF_IN_VERTEX, new Text(edge.getVertexId(Direction.IN)), edgeColumnVisibility, edge.getTimestamp(), ElementMutationBuilder.EMPTY_VALUE); for (PropertyDeleteMutation propertyDeleteMutation : edge.getPropertyDeleteMutations()) { addPropertyDeleteToMutation(m, propertyDeleteMutation); } for (PropertySoftDeleteMutation propertySoftDeleteMutation : edge.getPropertySoftDeleteMutations()) { addPropertySoftDeleteToMutation(m, propertySoftDeleteMutation); } for (Property property : edge.getProperties()) { addPropertyToMutation(edge.getGraph(), m, edgeRowKey, property); } return m; }
public Iterable<KeyValuePair> getEdgeTableKeyValuePairsEdge(AccumuloEdge edge) { List<KeyValuePair> results = new ArrayList<>(); ColumnVisibility edgeColumnVisibility = visibilityToAccumuloVisibility(edge.getVisibility()); Text edgeRowKey = new Text(edge.getId()); String edgeLabel = edge.getLabel(); if (edge.getNewEdgeLabel() != null) { throw new VertexiumException("Cannot get key/value pairs for label changes"); } results.add( new KeyValuePair( new Key( edgeRowKey, AccumuloEdge.CF_SIGNAL, new Text(edgeLabel), edgeColumnVisibility, edge.getTimestamp()), ElementMutationBuilder.EMPTY_VALUE)); results.add( new KeyValuePair( new Key( edgeRowKey, AccumuloEdge.CF_OUT_VERTEX, new Text(edge.getVertexId(Direction.OUT)), edgeColumnVisibility, edge.getTimestamp()), ElementMutationBuilder.EMPTY_VALUE)); results.add( new KeyValuePair( new Key( edgeRowKey, AccumuloEdge.CF_IN_VERTEX, new Text(edge.getVertexId(Direction.IN)), edgeColumnVisibility, edge.getTimestamp()), ElementMutationBuilder.EMPTY_VALUE)); if (edge.getPropertyDeleteMutations().iterator().hasNext()) { throw new VertexiumException("Cannot get key/value pairs for property deletions"); } for (PropertySoftDeleteMutation propertySoftDeleteMutation : edge.getPropertySoftDeleteMutations()) { addPropertySoftDeleteToKeyValuePairs(results, edgeRowKey, propertySoftDeleteMutation); } for (Property property : edge.getProperties()) { addPropertyToKeyValuePairs(results, edgeRowKey, property); } return results; }