EdgeSerializer.TypedInterval[] clonedSKC = Arrays.copyOf(sortKeyConstraints,sortKeyConstraints.length); clonedSKC[position-1]=new EdgeSerializer.TypedInterval(keyType,new PointInterval(point)); constructSliceQueries(extendedSortKey, clonedSKC, position, bestCandidate, direction, intervalConstraints, sliceLimit, isIntervalFittedConditions, bestCandidateSupportsOrder, queries); q.setLimit(computeLimit(intervalConstraints.size()-position, sliceLimit)); queries.add(new BackendQueryHolder<SliceQuery>(q, isFitted, bestCandidateSupportsOrder));
private VertexList executeIndividualVertexIds(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { VertexCentricQuery query = constructQuery(vertex, baseQuery); if (useSimpleQueryProcessor(query, vertex)) return new SimpleVertexQueryProcessor(query,tx).vertexIds(); return edges2VertexIds((Iterable) executeIndividualRelations(vertex,baseQuery), vertex); }
private Iterable<TitanVertex> executeIndividualVertices(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { VertexCentricQuery query = constructQuery(vertex, baseQuery); if (useSimpleQueryProcessor(query, vertex)) return new SimpleVertexQueryProcessor(query,tx).vertexIds(); else return edges2Vertices((Iterable) executeIndividualRelations(vertex,baseQuery), query.getVertex()); }
public Iterable<TitanVertex> executeVertices(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { //If there is a sort order, we need to first merge the relations (and sort) and then compute vertices if (!orders.isEmpty()) return edges2VertexIds((Iterable) executeRelations(vertex,baseQuery), vertex); if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); Iterable<TitanVertex> merge = null; for (InternalVertex rep : representatives) { Iterable<TitanVertex> iter = executeIndividualVertices(rep,baseQuery); if (merge==null) merge = iter; else merge = ResultMergeSortIterator.mergeSort(merge,iter,VertexArrayList.VERTEX_ID_COMPARATOR,false); } return ResultSetIterator.wrap(merge,baseQuery.getLimit()); } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualVertices(vertex,baseQuery); }
if (!hasTypes()) { BackendQueryHolder<SliceQuery> query = new BackendQueryHolder<SliceQuery>(serializer.getQuery(returnType, querySystem), ((dir == Direction.BOTH || (returnType == RelationCategory.PROPERTY && dir == Direction.OUT)) sliceLimit *= 2; query.getBackendQuery().setLimit(computeLimit(conditions.size(),sliceLimit)); queries = ImmutableList.of(query); conditions.add(returnType); queries = new ArrayList<BackendQueryHolder<SliceQuery>>(types.length + 2); Map<RelationType,Interval> intervalConstraints = new HashMap<RelationType, Interval>(conditions.size()); final boolean isIntervalFittedConditions = compileConstraints(conditions,intervalConstraints); for (Interval pint : intervalConstraints.values()) { //Check if one of the constraints leads to an empty result set if (pint.isEmpty()) return BaseVertexCentricQuery.emptyQuery(); PropertyKey[] extendedSortKey = getExtendedSortKey(candidate,direction,tx); PropertyKey[] extendedSortKey = getExtendedSortKey(bestCandidate,direction,tx); EdgeSerializer.TypedInterval[] sortKeyConstraints = new EdgeSerializer.TypedInterval[extendedSortKey.length]; constructSliceQueries(extendedSortKey,sortKeyConstraints,0,bestCandidate,direction,intervalConstraints, sliceLimit,isIntervalFittedConditions,bestCandidateSupportsOrder,queries); return BaseVertexCentricQuery.emptyQuery(); conditions.add(getTypeCondition(ts));
public VertexList executeVertexIds(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { //If there is a sort order, we need to first merge the relations (and sort) and then compute vertices if (!orders.isEmpty()) return edges2VertexIds((Iterable) executeRelations(vertex,baseQuery), vertex); if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); VertexListInternal merge = null; for (InternalVertex rep : representatives) { if (merge!=null && merge.size()>=baseQuery.getLimit()) break; VertexList vlist = executeIndividualVertexIds(rep,baseQuery); if (merge==null) merge = (VertexListInternal)vlist; else merge.addAll(vlist); } if (merge.size()>baseQuery.getLimit()) merge = (VertexListInternal)merge.subList(0,baseQuery.getLimit()); return merge; } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualVertexIds(vertex,baseQuery); }
protected Iterable<TitanRelation> executeRelations(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); Iterable<TitanRelation> merge = null; for (InternalVertex rep : representatives) { Iterable<TitanRelation> iter = executeIndividualRelations(rep,baseQuery); if (merge==null) merge = iter; else merge = ResultMergeSortIterator.mergeSort(merge,iter,(Comparator)orders,false); } return ResultSetIterator.wrap(merge,baseQuery.getLimit()); } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualRelations(vertex,baseQuery); }
private Iterable<TitanRelation> executeIndividualRelations(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { VertexCentricQuery query = constructQuery(vertex, baseQuery); if (useSimpleQueryProcessor(query,vertex)) return new SimpleVertexQueryProcessor(query,tx).relations(); else return new QueryProcessor<VertexCentricQuery,TitanRelation,SliceQuery>(query, tx.edgeProcessor); }
private Query relations(RelationCategory returnType) { // if (name==null) { // if (hasSingleType()) name = getSingleType().name(); // else if (!requiresName) name = QUERY_NAME_PREFIX + queries.size(); // else throw new IllegalStateException("Need to specify an explicit name for this query"); // } BaseVertexCentricQuery vq = super.constructQuery(returnType); List<SliceQuery> slices = new ArrayList<>(vq.numSubQueries()); for (int i = 0; i < vq.numSubQueries(); i++) { BackendQueryHolder<SliceQuery> bq = vq.getSubQuery(i); SliceQuery sq = bq.getBackendQuery(); slices.add(sq.updateLimit(bq.isFitted() ? vq.getLimit() : hardQueryLimit)); } Query q = new Query(slices, returnType); synchronized (queries) { Preconditions.checkArgument(!queries.contains(q), "Query has already been added: %s", q); queries.add(q); for (SliceQuery sq : slices) { inverseQueries.put(sq, q); } } return q; }
if (!hasTypes()) { BackendQueryHolder<SliceQuery> query = new BackendQueryHolder<SliceQuery>(serializer.getQuery(returnType, querySystem), ((dir == Direction.BOTH || (returnType == RelationCategory.PROPERTY && dir == Direction.OUT)) sliceLimit *= 2; query.getBackendQuery().setLimit(computeLimit(conditions.size(),sliceLimit)); queries = ImmutableList.of(query); conditions.add(returnType); queries = new ArrayList<BackendQueryHolder<SliceQuery>>(types.length + 2); Map<RelationType,Interval> intervalConstraints = new HashMap<RelationType, Interval>(conditions.size()); final boolean isIntervalFittedConditions = compileConstraints(conditions,intervalConstraints); for (Interval pint : intervalConstraints.values()) { //Check if one of the constraints leads to an empty result set if (pint.isEmpty()) return BaseVertexCentricQuery.emptyQuery(); PropertyKey[] extendedSortKey = getExtendedSortKey(candidate,direction,tx); PropertyKey[] extendedSortKey = getExtendedSortKey(bestCandidate,direction,tx); EdgeSerializer.TypedInterval[] sortKeyConstraints = new EdgeSerializer.TypedInterval[extendedSortKey.length]; constructSliceQueries(extendedSortKey,sortKeyConstraints,0,bestCandidate,direction,intervalConstraints, sliceLimit,isIntervalFittedConditions,bestCandidateSupportsOrder,queries); return BaseVertexCentricQuery.emptyQuery(); conditions.add(getTypeCondition(ts));
public Iterable<TitanVertex> executeVertices(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { //If there is a sort order, we need to first merge the relations (and sort) and then compute vertices if (!orders.isEmpty()) return edges2VertexIds((Iterable) executeRelations(vertex,baseQuery), vertex); if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); Iterable<TitanVertex> merge = null; for (InternalVertex rep : representatives) { Iterable<TitanVertex> iter = executeIndividualVertices(rep,baseQuery); if (merge==null) merge = iter; else merge = ResultMergeSortIterator.mergeSort(merge,iter,VertexArrayList.VERTEX_ID_COMPARATOR,false); } return ResultSetIterator.wrap(merge,baseQuery.getLimit()); } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualVertices(vertex,baseQuery); }
public VertexList executeVertexIds(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { //If there is a sort order, we need to first merge the relations (and sort) and then compute vertices if (!orders.isEmpty()) return edges2VertexIds((Iterable) executeRelations(vertex,baseQuery), vertex); if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); VertexListInternal merge = null; for (InternalVertex rep : representatives) { if (merge!=null && merge.size()>=baseQuery.getLimit()) break; VertexList vlist = executeIndividualVertexIds(rep,baseQuery); if (merge==null) merge = (VertexListInternal)vlist; else merge.addAll(vlist); } if (merge.size()>baseQuery.getLimit()) merge = (VertexListInternal)merge.subList(0,baseQuery.getLimit()); return merge; } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualVertexIds(vertex,baseQuery); }
protected Iterable<TitanRelation> executeRelations(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); Iterable<TitanRelation> merge = null; for (InternalVertex rep : representatives) { Iterable<TitanRelation> iter = executeIndividualRelations(rep,baseQuery); if (merge==null) merge = iter; else merge = ResultMergeSortIterator.mergeSort(merge,iter,(Comparator)orders,false); } return ResultSetIterator.wrap(merge,baseQuery.getLimit()); } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualRelations(vertex,baseQuery); }
private Iterable<TitanRelation> executeIndividualRelations(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { VertexCentricQuery query = constructQuery(vertex, baseQuery); if (useSimpleQueryProcessor(query,vertex)) return new SimpleVertexQueryProcessor(query,tx).relations(); else return new QueryProcessor<VertexCentricQuery,TitanRelation,SliceQuery>(query, tx.edgeProcessor); }
Preconditions.checkArgument(!vertices.isEmpty(), "Need to add at least one vertex to query"); Map<TitanVertex, Q> result = new HashMap<TitanVertex, Q>(vertices.size()); BaseVertexCentricQuery bq = super.constructQuery(returnType); profiler.setAnnotation(QueryProfiler.MULTIQUERY_ANNOTATION,true); profiler.setAnnotation(QueryProfiler.NUMVERTICES_ANNOTATION,vertices.size());
if (!hasTypes()) { BackendQueryHolder<SliceQuery> query = new BackendQueryHolder<SliceQuery>(serializer.getQuery(returnType, querySystem), ((dir == Direction.BOTH || (returnType == RelationCategory.PROPERTY && dir == Direction.OUT)) sliceLimit *= 2; query.getBackendQuery().setLimit(computeLimit(conditions.size(),sliceLimit)); queries = ImmutableList.of(query); conditions.add(returnType); queries = new ArrayList<BackendQueryHolder<SliceQuery>>(types.length + 2); Map<RelationType,Interval> intervalConstraints = new HashMap<RelationType, Interval>(conditions.size()); final boolean isIntervalFittedConditions = compileConstraints(conditions,intervalConstraints); for (Interval pint : intervalConstraints.values()) { //Check if one of the constraints leads to an empty result set if (pint.isEmpty()) return BaseVertexCentricQuery.emptyQuery(); RelationType[] extendedSortKey = getExtendedSortKey(candidate,direction,tx); RelationType[] extendedSortKey = getExtendedSortKey(bestCandidate,direction,tx); EdgeSerializer.TypedInterval[] sortKeyConstraints = new EdgeSerializer.TypedInterval[extendedSortKey.length]; constructSliceQueries(extendedSortKey,sortKeyConstraints,0,bestCandidate,direction,intervalConstraints, sliceLimit,isIntervalFittedConditions,bestCandidateSupportsOrder,queries); return BaseVertexCentricQuery.emptyQuery(); conditions.add(getTypeCondition(ts));
public Iterable<TitanVertex> executeVertices(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { //If there is a sort order, we need to first merge the relations (and sort) and then compute vertices if (!orders.isEmpty()) return edges2VertexIds((Iterable) executeRelations(vertex,baseQuery), vertex); if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); Iterable<TitanVertex> merge = null; for (InternalVertex rep : representatives) { Iterable<TitanVertex> iter = executeIndividualVertices(rep,baseQuery); if (merge==null) merge = iter; else merge = ResultMergeSortIterator.mergeSort(merge,iter,VertexArrayList.VERTEX_ID_COMPARATOR,false); } return ResultSetIterator.wrap(merge,baseQuery.getLimit()); } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualVertices(vertex,baseQuery); }
public VertexList executeVertexIds(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { if (isPartitionedVertex(vertex)) { //If there is a sort order, we need to first merge the relations (and sort) and then compute vertices if (!orders.isEmpty()) return edges2VertexIds((Iterable) executeRelations(vertex,baseQuery), vertex); if (!hasAllCanonicalTypes()) { InternalVertex[] representatives = tx.getAllRepresentatives(vertex,restrict2Partitions); VertexListInternal merge = null; for (InternalVertex rep : representatives) { if (merge!=null && merge.size()>=baseQuery.getLimit()) break; VertexList vlist = executeIndividualVertexIds(rep,baseQuery); if (merge==null) merge = (VertexListInternal)vlist; else merge.addAll(vlist); } if (merge.size()>baseQuery.getLimit()) merge = (VertexListInternal)merge.subList(0,baseQuery.getLimit()); return merge; } else vertex = tx.getCanonicalVertex(vertex); } return executeIndividualVertexIds(vertex,baseQuery); }
private VertexList executeIndividualVertexIds(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { VertexCentricQuery query = constructQuery(vertex, baseQuery); if (useSimpleQueryProcessor(query, vertex)) return new SimpleVertexQueryProcessor(query,tx).vertexIds(); return edges2VertexIds((Iterable) executeIndividualRelations(vertex,baseQuery), vertex); }
private Iterable<TitanVertex> executeIndividualVertices(InternalVertex vertex, BaseVertexCentricQuery baseQuery) { VertexCentricQuery query = constructQuery(vertex, baseQuery); if (useSimpleQueryProcessor(query, vertex)) return new SimpleVertexQueryProcessor(query,tx).vertexIds(); else return edges2Vertices((Iterable) executeIndividualRelations(vertex,baseQuery), query.getVertex()); }