use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method markEdgeHidden.
@Override
public void markEdgeHidden(Edge edge, Visibility visibility, Authorizations authorizations) {
checkNotNull(edge);
Span trace = Trace.start("markEdgeHidden");
trace.data("edgeId", edge.getId());
try {
Vertex out = edge.getVertex(Direction.OUT, authorizations);
if (out == null) {
throw new VertexiumException(String.format("Unable to mark edge hidden %s, can't find out vertex %s", edge.getId(), edge.getVertexId(Direction.OUT)));
}
Vertex in = edge.getVertex(Direction.IN, authorizations);
if (in == null) {
throw new VertexiumException(String.format("Unable to mark edge hidden %s, can't find in vertex %s", edge.getId(), edge.getVertexId(Direction.IN)));
}
ColumnVisibility columnVisibility = visibilityToAccumuloVisibility(visibility);
Mutation outMutation = new Mutation(out.getId());
outMutation.put(AccumuloVertex.CF_OUT_EDGE_HIDDEN, new Text(edge.getId()), columnVisibility, AccumuloElement.HIDDEN_VALUE);
Mutation inMutation = new Mutation(in.getId());
inMutation.put(AccumuloVertex.CF_IN_EDGE_HIDDEN, new Text(edge.getId()), columnVisibility, AccumuloElement.HIDDEN_VALUE);
addMutations(VertexiumObjectType.VERTEX, outMutation, inMutation);
// Delete everything else related to edge.
addMutations(VertexiumObjectType.EDGE, getMarkHiddenRowMutation(edge.getId(), columnVisibility));
if (out instanceof AccumuloVertex) {
((AccumuloVertex) out).removeOutEdge(edge);
}
if (in instanceof AccumuloVertex) {
((AccumuloVertex) in).removeInEdge(edge);
}
getSearchIndex().markElementHidden(this, edge, visibility, authorizations);
if (hasEventListeners()) {
queueEvent(new MarkHiddenEdgeEvent(this, edge));
}
} finally {
trace.stop();
}
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method findRelatedEdgeSummary.
@Override
public Iterable<RelatedEdge> findRelatedEdgeSummary(Iterable<String> vertexIds, Long endTime, Authorizations authorizations) {
Set<String> vertexIdsSet = IterableUtils.toSet(vertexIds);
Span trace = Trace.start("findRelatedEdgeSummary");
try {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("findRelatedEdgeSummary:\n %s", IterableUtils.join(vertexIdsSet, "\n "));
}
if (vertexIdsSet.size() == 0) {
return new ArrayList<>();
}
List<org.apache.accumulo.core.data.Range> ranges = new ArrayList<>();
for (String vertexId : vertexIdsSet) {
ranges.add(RangeUtils.createRangeFromString(vertexId));
}
Long startTime = null;
int maxVersions = 1;
FetchHints fetchHints = FetchHints.builder().setIncludeOutEdgeRefs(true).build();
ScannerBase scanner = createElementScanner(fetchHints, ElementType.VERTEX, maxVersions, startTime, endTime, ranges, false, authorizations);
IteratorSetting edgeRefFilterSettings = new IteratorSetting(1000, EdgeRefFilter.class.getSimpleName(), EdgeRefFilter.class);
EdgeRefFilter.setVertexIds(edgeRefFilterSettings, vertexIdsSet);
scanner.addScanIterator(edgeRefFilterSettings);
final long timerStartTime = System.currentTimeMillis();
try {
List<RelatedEdge> results = new ArrayList<>();
List<String> softDeletedEdgeIds = new ArrayList<>();
for (Map.Entry<Key, Value> row : scanner) {
Text columnFamily = row.getKey().getColumnFamily();
if (!columnFamily.equals(AccumuloVertex.CF_OUT_EDGE)) {
if (columnFamily.equals(AccumuloVertex.CF_OUT_EDGE_SOFT_DELETE) || columnFamily.equals(AccumuloVertex.CF_OUT_EDGE_HIDDEN)) {
softDeletedEdgeIds.add(row.getKey().getColumnQualifier().toString());
results.removeIf(relatedEdge -> softDeletedEdgeIds.contains(relatedEdge.getEdgeId()));
}
continue;
}
org.vertexium.accumulo.iterator.model.EdgeInfo edgeInfo = new EdgeInfo(row.getValue().get(), row.getKey().getTimestamp());
String edgeId = row.getKey().getColumnQualifier().toString();
String outVertexId = row.getKey().getRow().toString();
String inVertexId = edgeInfo.getVertexId();
String label = getNameSubstitutionStrategy().inflate(edgeInfo.getLabel());
if (!softDeletedEdgeIds.contains(edgeId)) {
results.add(new RelatedEdgeImpl(edgeId, label, outVertexId, inVertexId));
}
}
return results;
} finally {
scanner.close();
GRAPH_LOGGER.logEndIterator(System.currentTimeMillis() - timerStartTime);
}
} finally {
trace.stop();
}
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method prepareEdge.
@Override
public EdgeBuilder prepareEdge(String edgeId, Vertex outVertex, Vertex inVertex, String label, Long timestamp, Visibility visibility) {
checkNotNull(outVertex, "outVertex cannot be null");
checkNotNull(inVertex, "inVertex cannot be null");
checkNotNull(label, "label cannot be null");
if (edgeId == null) {
edgeId = getIdGenerator().nextId();
}
if (timestamp == null) {
timestamp = IncreasingTime.currentTimeMillis();
}
final long timestampLong = timestamp;
final String finalEdgeId = edgeId;
return new EdgeBuilder(finalEdgeId, outVertex, inVertex, label, visibility) {
@Override
public Edge save(Authorizations authorizations) {
Span trace = Trace.start("prepareEdge");
trace.data("edgeId", finalEdgeId);
try {
AddEdgeToVertexRunnable addEdgeToVertex = new AddEdgeToVertexRunnable() {
@Override
public void run(AccumuloEdge edge) {
if (getOutVertex() instanceof AccumuloVertex) {
((AccumuloVertex) getOutVertex()).addOutEdge(edge);
}
if (getInVertex() instanceof AccumuloVertex) {
((AccumuloVertex) getInVertex()).addInEdge(edge);
}
}
};
// This has to occur before createEdge since it will mutate the properties
elementMutationBuilder.saveEdgeBuilder(AccumuloGraph.this, this, timestampLong);
AccumuloEdge edge = createEdge(AccumuloGraph.this, this, timestampLong, FetchHints.ALL_INCLUDING_HIDDEN, authorizations);
return savePreparedEdge(this, edge, addEdgeToVertex, authorizations);
} finally {
trace.stop();
}
}
};
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method prepareEdge.
@Override
public AccumuloEdgeBuilderByVertexId prepareEdge(String edgeId, String outVertexId, String inVertexId, String label, Long timestamp, Visibility visibility) {
checkNotNull(outVertexId, "outVertexId cannot be null");
checkNotNull(inVertexId, "inVertexId cannot be null");
checkNotNull(label, "label cannot be null");
if (edgeId == null) {
edgeId = getIdGenerator().nextId();
}
if (timestamp == null) {
timestamp = IncreasingTime.currentTimeMillis();
}
final long timestampLong = timestamp;
final String finalEdgeId = edgeId;
return new AccumuloEdgeBuilderByVertexId(finalEdgeId, outVertexId, inVertexId, label, visibility, elementMutationBuilder) {
@Override
public Edge save(Authorizations authorizations) {
Span trace = Trace.start("prepareEdge");
trace.data("edgeId", finalEdgeId);
try {
// This has to occur before createEdge since it will mutate the properties
elementMutationBuilder.saveEdgeBuilder(AccumuloGraph.this, this, timestampLong);
AccumuloEdge edge = AccumuloGraph.this.createEdge(AccumuloGraph.this, this, timestampLong, FetchHints.ALL_INCLUDING_HIDDEN, authorizations);
return savePreparedEdge(this, edge, null, authorizations);
} finally {
trace.stop();
}
}
@Override
protected AccumuloEdge createEdge(Authorizations authorizations) {
return AccumuloGraph.this.createEdge(AccumuloGraph.this, this, timestampLong, FetchHints.ALL_INCLUDING_HIDDEN, authorizations);
}
};
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method softDeleteEdge.
@Override
public void softDeleteEdge(Edge edge, Long timestamp, Authorizations authorizations) {
checkNotNull(edge);
Span trace = Trace.start("softDeleteEdge");
trace.data("edgeId", edge.getId());
try {
if (timestamp == null) {
timestamp = IncreasingTime.currentTimeMillis();
}
getSearchIndex().deleteElement(this, edge, authorizations);
ColumnVisibility visibility = visibilityToAccumuloVisibility(edge.getVisibility());
Mutation outMutation = new Mutation(edge.getVertexId(Direction.OUT));
outMutation.put(AccumuloVertex.CF_OUT_EDGE_SOFT_DELETE, new Text(edge.getId()), visibility, timestamp, AccumuloElement.SOFT_DELETE_VALUE);
Mutation inMutation = new Mutation(edge.getVertexId(Direction.IN));
inMutation.put(AccumuloVertex.CF_IN_EDGE_SOFT_DELETE, new Text(edge.getId()), visibility, timestamp, AccumuloElement.SOFT_DELETE_VALUE);
addMutations(VertexiumObjectType.VERTEX, outMutation, inMutation);
// Soft deletes everything else related to edge.
addMutations(VertexiumObjectType.EDGE, getSoftDeleteRowMutation(edge.getId(), timestamp));
if (hasEventListeners()) {
queueEvent(new SoftDeleteEdgeEvent(this, edge));
}
} finally {
trace.stop();
}
}
Aggregations