use of org.janusgraph.graphdb.vertices.CacheVertex in project janusgraph by JanusGraph.
the class GhostVertexRemover method process.
@Override
public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) {
long vertexId = getVertexId(key);
assert entries.size() == 1;
assert entries.get(everythingQueryLimit) != null;
final EntryList everything = entries.get(everythingQueryLimit);
if (!isGhostVertex(vertexId, everything)) {
return;
}
if (everything.size() >= RELATION_COUNT_LIMIT) {
metrics.incrementCustom(SKIPPED_GHOST_LIMIT_COUNT);
return;
}
JanusGraphVertex vertex = tx.getInternalVertex(vertexId);
Preconditions.checkArgument(vertex instanceof CacheVertex, "The bounding transaction is not configured correctly");
CacheVertex v = (CacheVertex) vertex;
v.loadRelations(EVERYTHING_QUERY, input -> everything);
int removedRelations = 0;
Iterator<JanusGraphRelation> iterator = v.query().noPartitionRestriction().relations().iterator();
while (iterator.hasNext()) {
iterator.next();
iterator.remove();
removedRelations++;
}
// There should be no more system relations to remove
metrics.incrementCustom(REMOVED_VERTEX_COUNT);
metrics.incrementCustom(REMOVED_RELATION_COUNT, removedRelations);
}
use of org.janusgraph.graphdb.vertices.CacheVertex in project janusgraph by JanusGraph.
the class StandardJanusGraphTx method executeMultiQuery.
public void executeMultiQuery(final Collection<InternalVertex> vertices, final SliceQuery sq, final QueryProfiler profiler) {
LongArrayList vertexIds = new LongArrayList(vertices.size());
for (InternalVertex v : vertices) {
if (!v.isNew() && v.hasId() && (v instanceof CacheVertex) && !v.hasLoadedRelations(sq))
vertexIds.add(v.longId());
}
if (!vertexIds.isEmpty()) {
List<EntryList> results = QueryProfiler.profile(profiler, sq, true, q -> graph.edgeMultiQuery(vertexIds, q, txHandle));
int pos = 0;
for (JanusGraphVertex v : vertices) {
if (pos < vertexIds.size() && vertexIds.get(pos) == v.longId()) {
final EntryList vresults = results.get(pos);
((CacheVertex) v).loadRelations(sq, query -> vresults);
pos++;
}
}
}
}
Aggregations