use of com.thinkaurelius.titan.graphdb.vertices.CacheVertex in project titan by thinkaurelius.
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;
}
TitanVertex vertex = tx.getInternalVertex(vertexId);
Preconditions.checkArgument(vertex instanceof CacheVertex, "The bounding transaction is not configured correctly");
CacheVertex v = (CacheVertex) vertex;
v.loadRelations(EVERYTHING_QUERY, new Retriever<SliceQuery, EntryList>() {
@Override
public EntryList get(SliceQuery input) {
return everything;
}
});
int removedRelations = 0;
Iterator<TitanRelation> iter = v.query().noPartitionRestriction().relations().iterator();
while (iter.hasNext()) {
iter.next();
iter.remove();
removedRelations++;
}
//There should be no more system relations to remove
metrics.incrementCustom(REMOVED_VERTEX_COUNT);
metrics.incrementCustom(REMOVED_RELATION_COUNT, removedRelations);
}
use of com.thinkaurelius.titan.graphdb.vertices.CacheVertex in project titan by thinkaurelius.
the class StandardTitanTx method executeMultiQuery.
public void executeMultiQuery(final Collection<InternalVertex> vertices, final SliceQuery sq, final QueryProfiler profiler) {
LongArrayList vids = new LongArrayList(vertices.size());
for (InternalVertex v : vertices) {
if (!v.isNew() && v.hasId() && (v instanceof CacheVertex) && !v.hasLoadedRelations(sq))
vids.add(v.longId());
}
if (!vids.isEmpty()) {
List<EntryList> results = QueryProfiler.profile(profiler, sq, true, q -> graph.edgeMultiQuery(vids, q, txHandle));
int pos = 0;
for (TitanVertex v : vertices) {
if (pos < vids.size() && vids.get(pos) == v.longId()) {
final EntryList vresults = results.get(pos);
((CacheVertex) v).loadRelations(sq, new Retriever<SliceQuery, EntryList>() {
@Override
public EntryList get(SliceQuery query) {
return vresults;
}
});
pos++;
}
}
}
}
Aggregations