@Override public OInternalExecutionPlan copy(OCommandContext ctx) { OSelectExecutionPlan copy = new OSelectExecutionPlan(ctx); copyOn(copy, ctx); return copy; }
public OInternalExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { OSelectExecutionPlan plan = new OSelectExecutionPlan(ctx); handleRidSource(plan, ctx, enableProfiling); handleSubQuerySource(plan, ctx, enableProfiling); handleFindReferences(plan, ctx, enableProfiling); return plan; }
private OSelectExecutionPlan createExecutionPlan(OResult nextItem, OCommandContext ctx) { OSelectExecutionPlan plan = new OSelectExecutionPlan(ctx); plan.chain(new AbstractExecutionStep(ctx, profilingEnabled) { boolean executed = false; @Override public OResultSet syncPull(OCommandContext ctx, int nRecords) throws OTimeoutException { OInternalResultSet result = new OInternalResultSet(); if (!executed) { result.add(copy(nextItem)); executed = true; } return result; } private OResult copy(OResult nextItem) { OResultInternal result = new OResultInternal(); for (String prop : nextItem.getPropertyNames()) { result.setProperty(prop, nextItem.getProperty(prop)); } for (String md : nextItem.getMetadataKeys()) { result.setMetadata(md, nextItem.getMetadata(md)); } return result; } }); subSteps.stream().forEach(step -> plan.chain(step)); return plan; }
info.serverToClusters = new LinkedHashMap<>(); info.serverToClusters.put(localNode, clusterMap.get(localNode)); info.distributedFetchExecutionPlans.put(localNode, new OSelectExecutionPlan(ctx)); return; info.distributedFetchExecutionPlans.put(node, new OSelectExecutionPlan(ctx));
} else { DistributedExecutionStep step = new DistributedExecutionStep(entry.getValue(), entry.getKey(), ctx, enableProfiling); OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subPlan.chain(step); subPlans.add(subPlan);
private OInternalExecutionPlan createPlanForPattern(Pattern pattern, OCommandContext context, Map<String, Long> estimatedRootEntries, Set<String> prefetchedAliases, boolean profilingEnabled) { OSelectExecutionPlan plan = new OSelectExecutionPlan(context); List<EdgeTraversal> sortedEdges = getTopologicalSortedSchedule(estimatedRootEntries, pattern);
private List<OExecutionStepInternal> handleClassAsTargetWithIndexRecursive(String targetClass, Set<String> filterClusters, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { List<OExecutionStepInternal> result = handleClassAsTargetWithIndex(targetClass, filterClusters, info, ctx, profilingEnabled); if (result == null) { result = new ArrayList<>(); OClass clazz = ctx.getDatabase().getMetadata().getSchema().getClass(targetClass); if (clazz == null) { throw new OCommandExecutionException("Cannot find class " + targetClass); } if (clazz.count(false) != 0 || clazz.getSubclasses().size() == 0 || isDiamondHierarchy(clazz)) { return null; } Collection<OClass> subclasses = clazz.getSubclasses(); List<OInternalExecutionPlan> subclassPlans = new ArrayList<>(); for (OClass subClass : subclasses) { List<OExecutionStepInternal> subSteps = handleClassAsTargetWithIndexRecursive(subClass.getName(), filterClusters, info, ctx, profilingEnabled); if (subSteps == null || subSteps.size() == 0) { return null; } OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subSteps.stream().forEach(x -> subPlan.chain(x)); subclassPlans.add(subPlan); } if (subclassPlans.size() > 0) { result.add(new ParallelExecStep(subclassPlans, ctx, profilingEnabled)); } } return result.size() == 0 ? null : result; }
OSelectExecutionPlan stubPlan = new OSelectExecutionPlan(ctx); boolean prevCreatedDist = info.distributedPlanCreated; info.distributedPlanCreated = true; //little hack, check this!!!
private OExecutionStepInternal createParallelIndexFetch(List<IndexSearchDescriptor> indexSearchDescriptors, Set<String> filterClusters, OCommandContext ctx, boolean profilingEnabled) { List<OInternalExecutionPlan> subPlans = new ArrayList<>(); for (IndexSearchDescriptor desc : indexSearchDescriptors) { OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subPlan.chain(new FetchFromIndexStep(desc.idx, desc.keyCondition, desc.additionalRangeCondition, ctx, profilingEnabled)); int[] filterClusterIds = null; if (filterClusters != null) { filterClusterIds = filterClusters.stream().map(name -> ctx.getDatabase().getClusterIdByName(name)).mapToInt(i -> i) .toArray(); } subPlan.chain(new GetValueFromIndexEntryStep(ctx, filterClusterIds, profilingEnabled)); if (requiresMultipleIndexLookups(desc.keyCondition)) { subPlan.chain(new DistinctExecutionStep(ctx, profilingEnabled)); } if (desc.remainingCondition != null && !desc.remainingCondition.isEmpty()) { subPlan.chain(new FilterStep(createWhereFrom(desc.remainingCondition), ctx, profilingEnabled)); } subPlans.add(subPlan); } return new ParallelExecStep(subPlans, ctx, profilingEnabled); }
public OInternalExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { OSelectExecutionPlan result = new OSelectExecutionPlan(ctx); handleFetchFromTarger(result, ctx, enableProfiling); handleTraversal(result, ctx, enableProfiling); if (skip != null) { result.chain(new SkipExecutionStep(skip, ctx, enableProfiling)); } if (limit != null) { result.chain(new LimitExecutionStep(limit, ctx, enableProfiling)); } return result; }
return false; OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subSteps.stream().forEach(x -> subPlan.chain(x)); subclassPlans.add(subPlan);
List<OInternalExecutionPlan> plans = new ArrayList<>(); for (OInputParameter param : target.getInputParams()) { OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); handleInputParamAsTarget(subPlan, info.serverToClusters.get(shardedPlan.getKey()), info, param, ctx, profilingEnabled); plans.add(subPlan);
splitDisjointPatterns(context); OSelectExecutionPlan result = new OSelectExecutionPlan(context); Map<String, Long> estimatedRootEntries = estimateRootEntries(aliasClasses, aliasClusters, aliasRids, aliasFilters, context); Set<String> aliasesToPrefetch = estimatedRootEntries.entrySet().stream().filter(x -> x.getValue() < this.threshold)
@Override public OResultSet execute(ODatabase db, Object[] args, OCommandContext parentCtx) { OBasicCommandContext ctx = new OBasicCommandContext(); if (parentCtx != null) { ctx.setParentWithoutOverridingChild(parentCtx); } ctx.setDatabase(db); Map<Object, Object> params = new HashMap<>(); if (args != null) { for (int i = 0; i < args.length; i++) { params.put(i, args[i]); } } ctx.setInputParameters(params); OIfExecutionPlan executionPlan = createExecutionPlan(ctx, false); OExecutionStepInternal last = executionPlan.executeUntilReturn(); if (last == null) { last = new EmptyStep(ctx, false); } if (isIdempotent()) { OSelectExecutionPlan finalPlan = new OSelectExecutionPlan(ctx); finalPlan.chain(last); return new OLocalResultSet(finalPlan); } else { OUpdateExecutionPlan finalPlan = new OUpdateExecutionPlan(ctx); finalPlan.chain(last); finalPlan.executeInternal(); return new OLocalResultSet(finalPlan); } }
bestIndex.additionalRangeCondition, true, ctx, profilingEnabled); OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subPlan.chain(step); int[] filterClusterIds = null; FetchFromClassExecutionStep step = new FetchFromClassExecutionStep(clazz.getName(), filterClusters, ctx, true, profilingEnabled); OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subPlan.chain(step); if (!block.getSubBlocks().isEmpty()) { OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subPlan.chain(step); if (!block.getSubBlocks().isEmpty()) {
@Override public OResultSet execute(ODatabase db, Map params, OCommandContext parentCtx) { OBasicCommandContext ctx = new OBasicCommandContext(); if (parentCtx != null) { ctx.setParentWithoutOverridingChild(parentCtx); } ctx.setDatabase(db); ctx.setInputParameters(params); OIfExecutionPlan executionPlan = createExecutionPlan(ctx, false); OExecutionStepInternal last = executionPlan.executeUntilReturn(); if (last == null) { last = new EmptyStep(ctx, false); } if (isIdempotent()) { OSelectExecutionPlan finalPlan = new OSelectExecutionPlan(ctx); finalPlan.chain(last); return new OLocalResultSet(finalPlan); } else { OUpdateExecutionPlan finalPlan = new OUpdateExecutionPlan(ctx); finalPlan.chain(last); finalPlan.executeInternal(); return new OLocalResultSet(finalPlan); } }
OSelectExecutionPlan result = new OSelectExecutionPlan(ctx);