use of org.janusgraph.graphdb.query.vertex.VertexCentricQueryBuilder in project janusgraph by JanusGraph.
the class RelationIdentifierUtils method findEdgeRelations.
public static Iterable<? extends JanusGraphRelation> findEdgeRelations(JanusGraphVertex v, RelationType type, RelationIdentifier rId, JanusGraphTransaction tx) {
Direction dir = Direction.OUT;
JanusGraphVertex other = ((StandardJanusGraphTx) tx).getInternalVertex(rId.getInVertexId());
if (other == null || other.isRemoved())
return null;
if (((StandardJanusGraphTx) tx).isPartitionedVertex(v) && !((StandardJanusGraphTx) tx).isPartitionedVertex(other)) {
// Swap for likely better performance
JanusGraphVertex tmp = other;
other = v;
v = tmp;
dir = Direction.IN;
}
VertexCentricQueryBuilder query = ((VertexCentricQueryBuilder) v.query()).noPartitionRestriction().types(type).direction(dir).adjacent(other);
RelationType internalVertex = ((StandardJanusGraphTx) tx).getExistingRelationType(type.longId());
if (((InternalRelationType) internalVertex).getConsistencyModifier() != ConsistencyModifier.FORK) {
query.has(ImplicitKey.JANUSGRAPHID.name(), rId.getRelationId());
}
return query.edges();
}
use of org.janusgraph.graphdb.query.vertex.VertexCentricQueryBuilder in project janusgraph by JanusGraph.
the class IndexSerializer method indexMatches.
private static void indexMatches(JanusGraphVertex vertex, RecordEntry[] current, IndexRecords matches, IndexField[] fields, int pos, boolean onlyLoaded, PropertyKey replaceKey, RecordEntry replaceValue) {
if (pos >= fields.length) {
matches.add(current);
return;
}
final PropertyKey key = fields[pos].getFieldKey();
List<RecordEntry> values;
if (key.equals(replaceKey)) {
values = ImmutableList.of(replaceValue);
} else {
values = new ArrayList<>();
Iterable<JanusGraphVertexProperty> props;
if (onlyLoaded || (!vertex.isNew() && IDManager.VertexIDType.PartitionedVertex.is(vertex.longId()))) {
// going through transaction so we can query deleted vertices
final VertexCentricQueryBuilder qb = ((InternalVertex) vertex).tx().query(vertex);
qb.noPartitionRestriction().type(key);
if (onlyLoaded)
qb.queryOnlyLoaded();
props = qb.properties();
} else {
props = vertex.query().keys(key.name()).properties();
}
for (final JanusGraphVertexProperty p : props) {
assert !onlyLoaded || p.isLoaded() || p.isRemoved();
assert key.dataType().equals(p.value().getClass()) : key + " -> " + p;
values.add(new RecordEntry(p));
}
}
for (final RecordEntry value : values) {
current[pos] = value;
indexMatches(vertex, current, matches, fields, pos + 1, onlyLoaded, replaceKey, replaceValue);
}
}
Aggregations