public static final GraphCentricQuery emptyQuery(ElementCategory resultType) { Condition<TitanElement> cond = new FixedCondition<TitanElement>(false); return new GraphCentricQuery(resultType, cond, OrderList.NO_ORDER, new BackendQueryHolder<JointIndexQuery>(new JointIndexQuery(), true, false), 0); }
List<BackendQueryHolder<SliceQuery>> queries; if (!hasTypes()) { BackendQueryHolder<SliceQuery> query = new BackendQueryHolder<SliceQuery>(serializer.getQuery(returnType, querySystem), ((dir == Direction.BOTH || (returnType == RelationCategory.PROPERTY && dir == Direction.OUT)) && !conditions.hasChildren()), orders.isEmpty()); sliceLimit *= 2; query.getBackendQuery().setLimit(computeLimit(conditions.size(),sliceLimit)); queries = ImmutableList.of(query); conditions.add(returnType); queries.add(new BackendQueryHolder<SliceQuery>(q, isIntervalFittedConditions, true)); } else {
public SimpleVertexQueryProcessor(VertexCentricQuery query, StandardTitanTx tx) { Preconditions.checkArgument(query.isSimple()); this.query=query; this.tx=tx; BackendQueryHolder<SliceQuery> bqh = query.getSubQuery(0); this.sliceQuery=bqh.getBackendQuery(); this.profiler=bqh.getProfiler(); this.vertex=query.getVertex(); this.edgeSerializer=tx.getEdgeSerializer(); }
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; }
@Override public Iterator<TitanElement> getNew(final GraphCentricQuery query) { if (query.numSubQueries()==1 && query.getSubQuery(0).getBackendQuery().isEmpty()) return Collections.emptyIterator(); Preconditions.checkArgument(query.getCondition().hasChildren(),"If the query is non-empty it needs to have a condition");
@Override public void observeWith(QueryProfiler profiler) { profiler.setAnnotation(QueryProfiler.CONDITION_ANNOTATION,condition); profiler.setAnnotation(QueryProfiler.ORDERS_ANNOTATION,orders); if (hasLimit()) profiler.setAnnotation(QueryProfiler.LIMIT_ANNOTATION,getLimit()); queries.forEach(bqh -> bqh.observeWith(profiler)); } }
tx.executeMultiQuery(adjVertices, sq.getBackendQuery(), sq.getProfiler());
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; }
public SimpleVertexQueryProcessor(VertexCentricQuery query, StandardTitanTx tx) { Preconditions.checkArgument(query.isSimple()); this.query=query; this.tx=tx; this.sliceQuery=query.getSubQuery(0).getBackendQuery(); this.vertex=query.getVertex(); this.edgeSerializer=tx.getEdgeSerializer(); }
@Override public void observeWith(QueryProfiler profiler) { profiler.setAnnotation(QueryProfiler.CONDITION_ANNOTATION,condition); profiler.setAnnotation(QueryProfiler.ORDERS_ANNOTATION,orders); if (hasLimit()) profiler.setAnnotation(QueryProfiler.LIMIT_ANNOTATION,getLimit()); indexQuery.observeWith(profiler); } }
SliceQuery q = serializer.getQuery(bestCandidate, direction, sortKeyConstraints); q.setLimit(computeLimit(intervalConstraints.size()-position, sliceLimit)); queries.add(new BackendQueryHolder<SliceQuery>(q, isFitted, bestCandidateSupportsOrder));
for (int i = query.numSubQueries() - 1; i >= 0; i--) { BackendQueryHolder<B> subq = query.getSubQuery(i); Iterator<R> subqiter = getFilterIterator((subq.isSorted()) ? new LimitAdjustingIterator(subq) : new PreSortingIterator(subq), hasDeletions, !subq.isFitted()); BackendQueryHolder<B> subq = query.getSubQuery(i); Iterator<R> subiter = new LimitAdjustingIterator(subq); subiter = getFilterIterator(subiter, hasDeletions, !subq.isFitted()); if (!allNew.isEmpty()) { subiter = Iterators.filter(subiter, new Predicate<R>() {
List<BackendQueryHolder<SliceQuery>> queries; if (!hasTypes()) { BackendQueryHolder<SliceQuery> query = new BackendQueryHolder<SliceQuery>(serializer.getQuery(returnType, querySystem), ((dir == Direction.BOTH || (returnType == RelationCategory.PROPERTY && dir == Direction.OUT)) && !conditions.hasChildren()), orders.isEmpty()); sliceLimit *= 2; query.getBackendQuery().setLimit(computeLimit(conditions.size(),sliceLimit)); queries = ImmutableList.of(query); conditions.add(returnType); queries.add(new BackendQueryHolder<SliceQuery>(q, isIntervalFittedConditions, true)); } else {
protected<Q> Q execute(RelationCategory returnType, ResultConstructor<Q> resultConstructor) { BaseVertexCentricQuery bq = super.constructQuery(returnType); if (bq.isEmpty()) return resultConstructor.emptyResult(); if (returnType==RelationCategory.PROPERTY && hasSingleType() && !hasQueryOnlyLoaded() && tx.getConfiguration().hasPropertyPrefetching()) { //Preload properties vertex.query().properties().iterator().hasNext(); } if (isPartitionedVertex(vertex) && !hasQueryOnlyGivenVertex()) { //If it's a preloaded vertex we shouldn't preload data explicitly List<InternalVertex> vertices = allRequiredRepresentatives(vertex); profiler.setAnnotation(QueryProfiler.PARTITIONED_VERTEX_ANNOTATION,true); profiler.setAnnotation(QueryProfiler.NUMVERTICES_ANNOTATION,vertices.size()); if (vertices.size()>1) { for (BackendQueryHolder<SliceQuery> sq : bq.getQueries()) { tx.executeMultiQuery(vertices, sq.getBackendQuery(),sq.getProfiler()); } } } else profiler.setAnnotation(QueryProfiler.NUMVERTICES_ANNOTATION,1); return resultConstructor.getResult(vertex,bq); }
private static List<StandardSubQuery> convert(GraphCentricQuery query) { List<StandardSubQuery> result = new ArrayList<StandardSubQuery>(query.numSubQueries()); for (int i=0;i<query.numSubQueries();i++) { BackendQueryHolder<JointIndexQuery> sq = query.getSubQuery(i); JointIndexQuery iq = sq.getBackendQuery(); List<String> indexes = new ArrayList<String>(iq.size()); for (int j=0;j<iq.size();j++) indexes.add(iq.getQuery(j).getIndex().getName()); result.add(new StandardSubQuery(sq,indexes)); } return result; }
@Override public void observeWith(QueryProfiler profiler) { profiler.setAnnotation(QueryProfiler.CONDITION_ANNOTATION,condition); profiler.setAnnotation(QueryProfiler.ORDERS_ANNOTATION,orders); if (hasLimit()) profiler.setAnnotation(QueryProfiler.LIMIT_ANNOTATION,getLimit()); queries.forEach(bqh -> bqh.observeWith(profiler)); } }
query = new BackendQueryHolder<JointIndexQuery>(jointQuery, coveredClauses.size()==conditions.numChildren(), isSorted); } else { query = new BackendQueryHolder<JointIndexQuery>(new JointIndexQuery(), false, isSorted);
List<BackendQueryHolder<SliceQuery>> queries; if (!hasTypes()) { BackendQueryHolder<SliceQuery> query = new BackendQueryHolder<SliceQuery>(serializer.getQuery(returnType, querySystem), ((dir == Direction.BOTH || (returnType == RelationCategory.PROPERTY && dir == Direction.OUT)) && !conditions.hasChildren()), orders.isEmpty(), null); sliceLimit *= 2; query.getBackendQuery().setLimit(computeLimit(conditions.size(),sliceLimit)); queries = ImmutableList.of(query); conditions.add(returnType); queries.add(new BackendQueryHolder<SliceQuery>(q, isIntervalFittedConditions, true, null)); } else {