use of com.thinkaurelius.titan.graphdb.internal.InternalVertex in project titan by thinkaurelius.
the class CacheVertexProperty method it.
@Override
public InternalRelation it() {
InternalRelation it = null;
InternalVertex startVertex = getVertex(0);
if (startVertex.hasAddedRelations() && startVertex.hasRemovedRelations()) {
//Test whether this relation has been replaced
final long id = super.longId();
it = Iterables.getOnlyElement(startVertex.getAddedRelations(new Predicate<InternalRelation>() {
@Override
public boolean apply(@Nullable InternalRelation internalRelation) {
return (internalRelation instanceof StandardVertexProperty) && ((StandardVertexProperty) internalRelation).getPreviousID() == id;
}
}), null);
}
return (it != null) ? it : super.it();
}
use of com.thinkaurelius.titan.graphdb.internal.InternalVertex in project titan by thinkaurelius.
the class MultiVertexCentricQueryBuilder method relations.
protected Map<TitanVertex, Iterable<? extends TitanRelation>> relations(RelationType returnType) {
Preconditions.checkArgument(!vertices.isEmpty(), "Need to add at least one vertex to query");
BaseVertexCentricQuery vq = super.constructQuery(returnType);
Map<TitanVertex, Iterable<? extends TitanRelation>> result = new HashMap<TitanVertex, Iterable<? extends TitanRelation>>(vertices.size());
if (!vq.isEmpty()) {
for (BackendQueryHolder<SliceQuery> sq : vq.getQueries()) {
tx.executeMultiQuery(vertices, sq.getBackendQuery());
}
Condition<TitanRelation> condition = vq.getCondition();
for (InternalVertex v : vertices) {
// Add other-vertex and direction related conditions
And<TitanRelation> newcond = new And<TitanRelation>();
if (condition instanceof And)
newcond.addAll((And) condition);
else
newcond.add(condition);
newcond.add(new DirectionCondition<TitanRelation>(v, getDirection()));
VertexCentricQuery vqsingle = new VertexCentricQuery(v, newcond, vq.getDirection(), vq.getQueries(), vq.getLimit());
result.put(v, new QueryProcessor<VertexCentricQuery, TitanRelation, SliceQuery>(vqsingle, tx.edgeProcessor));
}
} else {
Iterable<? extends TitanRelation> emptyIter = IterablesUtil.emptyIterable();
for (TitanVertex v : vertices) result.put(v, emptyIter);
}
return result;
}
use of com.thinkaurelius.titan.graphdb.internal.InternalVertex in project titan by thinkaurelius.
the class GuavaVertexCache method get.
@Override
public InternalVertex get(final long id, final Retriever<Long, InternalVertex> retriever) {
final Long vertexId = id;
InternalVertex vertex = cache.getIfPresent(vertexId);
if (vertex == null) {
InternalVertex newVertex = volatileVertices.get(vertexId);
if (newVertex == null) {
newVertex = retriever.get(vertexId);
}
assert newVertex != null;
try {
vertex = cache.get(vertexId, new NewVertexCallable(newVertex));
} catch (Exception e) {
throw new AssertionError("Should not happen: " + e.getMessage());
}
assert vertex != null;
}
return vertex;
}
use of com.thinkaurelius.titan.graphdb.internal.InternalVertex in project titan by thinkaurelius.
the class LRUVertexCache method get.
@Override
public InternalVertex get(long id, final Retriever<Long, InternalVertex> retriever) {
final Long vertexId = id;
InternalVertex vertex = cache.get(vertexId);
if (vertex == null) {
InternalVertex newVertex = volatileVertices.get(vertexId);
if (newVertex == null) {
newVertex = retriever.get(vertexId);
}
vertex = cache.putIfAbsent(vertexId, newVertex);
if (vertex == null)
vertex = newVertex;
}
return vertex;
}
Aggregations