private void handleFindReferences(OSelectExecutionPlan plan, OCommandContext ctx, boolean profilingEnabled) { List<OIdentifier> classes = targets == null ? null : targets.stream().filter(x -> x instanceof OIdentifier).map(y -> ((OIdentifier) y)).collect(Collectors.toList()); List<OCluster> clusters = targets == null ? null : targets.stream().filter(x -> x instanceof OCluster).map(y -> ((OCluster) y)).collect(Collectors.toList()); plan.chain(new FindReferencesStep(classes, clusters, ctx, profilingEnabled)); }
public static void handleUnwind(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { if (info.unwind != null) { result.chain(new UnwindStep(info.unwind, ctx, profilingEnabled)); } }
private static void handleDistinct(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { if (info.distinct) { result.chain(new DistinctExecutionStep(ctx, profilingEnabled)); } }
private static void handleExpand(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { if (info.expand) { result.chain(new ExpandStep(ctx, profilingEnabled)); } }
private void handleTraversal(OSelectExecutionPlan result, OCommandContext ctx, boolean profilingEnabled) { switch (strategy) { case BREADTH_FIRST: result.chain(new BreadthFirstTraverseStep(this.projections, this.whileClause, maxDepth, ctx, profilingEnabled)); break; case DEPTH_FIRST: result.chain(new DepthFirstTraverseStep(this.projections, this.whileClause, maxDepth, ctx, profilingEnabled)); break; } //TODO }
private void handleLockRecord(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx, boolean enableProfiling) { if (info.lockRecord != null) { result.chain(new LockRecordStep(info.lockRecord, ctx, enableProfiling)); } }
private void handleNoTarget(OSelectExecutionPlan result, OCommandContext ctx, boolean profilingEnabled) { result.chain(new EmptyDataGeneratorStep(1, ctx, profilingEnabled)); }
private void handleNoTarget(OSelectExecutionPlan result, OCommandContext ctx, boolean profilingEnabled) { result.chain(new EmptyDataGeneratorStep(1, ctx, profilingEnabled)); }
private void handleWhere(OSelectExecutionPlan plan, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { if (info.whereClause != null) { if (info.distributedPlanCreated) { plan.chain(new FilterStep(info.whereClause, ctx, profilingEnabled)); } else { for (OSelectExecutionPlan shardedPlan : info.distributedFetchExecutionPlans.values()) { shardedPlan.chain(new FilterStep(info.whereClause.copy(), ctx, profilingEnabled)); } } } }
private void handleRidsAsTarget(OSelectExecutionPlan plan, List<ORid> rids, OCommandContext ctx, boolean profilingEnabled) { List<ORecordId> actualRids = new ArrayList<>(); for (ORid rid : rids) { actualRids.add(rid.toRecordId((OResult) null, ctx)); } plan.chain(new FetchFromRidsStep(actualRids, ctx, profilingEnabled)); }
private void handleRidSource(OSelectExecutionPlan plan, OCommandContext ctx, boolean profilingEnabled) { if (rid != null) { plan.chain(new FetchFromRidsStep(Collections.singleton(rid.toRecordId((OResult) null, ctx)), ctx, profilingEnabled)); } }
private void handleRidsAsTarget(OSelectExecutionPlan plan, List<ORid> rids, OCommandContext ctx, boolean profilingEnabled) { List<ORecordId> actualRids = new ArrayList<>(); for (ORid rid : rids) { actualRids.add(rid.toRecordId((OResult) null, ctx)); } plan.chain(new FetchFromRidsStep(actualRids, ctx, profilingEnabled)); }
private void addPrefetchSteps(OSelectExecutionPlan result, Set<String> aliasesToPrefetch, OCommandContext context, boolean profilingEnabled) { for (String alias : aliasesToPrefetch) { String targetClass = aliasClasses.get(alias); String targetCluster = aliasClusters.get(alias); ORid targetRid = aliasRids.get(alias); OWhereClause filter = aliasFilters.get(alias); OSelectStatement prefetchStm = createSelectStatement(targetClass, targetCluster, targetRid, filter); MatchPrefetchStep step = new MatchPrefetchStep(context, prefetchStm.createExecutionPlan(context, profilingEnabled), alias, profilingEnabled); result.chain(step); } }
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; }
public void deserialize(OResult serializedExecutionPlan) { List<OResult> serializedSteps = serializedExecutionPlan.getProperty("steps"); for (OResult serializedStep : serializedSteps) { try { String className = serializedStep.getProperty(JAVA_TYPE); OExecutionStepInternal step = (OExecutionStepInternal) Class.forName(className).newInstance(); step.deserialize(serializedStep); chain(step); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException("Cannot deserialize execution step:" + serializedStep), e); } } }
private void handleClassAsTarget(OSelectExecutionPlan plan, OFromClause queryTarget, OCommandContext ctx, boolean profilingEnabled) { OIdentifier identifier = queryTarget.getItem().getIdentifier(); Boolean orderByRidAsc = null;//null: no order. true: asc, false:desc FetchFromClassExecutionStep fetcher = new FetchFromClassExecutionStep(identifier.getStringValue(), null, ctx, orderByRidAsc, profilingEnabled); plan.chain(fetcher); }
private void handleGlobalLet(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { if (info.globalLetClause != null) { List<OLetItem> items = info.globalLetClause.getItems(); for (OLetItem item : items) { if (item.getExpression() != null) { result.chain(new GlobalLetExpressionStep(item.getVarName(), item.getExpression(), ctx, profilingEnabled)); } else { result.chain(new GlobalLetQueryStep(item.getVarName(), item.getQuery(), ctx, profilingEnabled)); } info.globalLetPresent = true; } } }
private void handleMetadataAsTarget(OSelectExecutionPlan plan, OMetadataIdentifier metadata, OCommandContext ctx, boolean profilingEnabled) { ODatabaseInternal db = (ODatabaseInternal) ctx.getDatabase(); String schemaRecordIdAsString = null; if (metadata.getName().equalsIgnoreCase(OCommandExecutorSQLAbstract.METADATA_SCHEMA)) { schemaRecordIdAsString = db.getStorage().getConfiguration().getSchemaRecordId(); } else if (metadata.getName().equalsIgnoreCase(OCommandExecutorSQLAbstract.METADATA_INDEXMGR)) { schemaRecordIdAsString = db.getStorage().getConfiguration().getIndexMgrRecordId(); } else { throw new UnsupportedOperationException("Invalid metadata: " + metadata.getName()); } ORecordId schemaRid = new ORecordId(schemaRecordIdAsString); plan.chain(new FetchFromRidsStep(Collections.singleton(schemaRid), ctx, profilingEnabled)); }
private void handleSubqueryAsTarget(OSelectExecutionPlan plan, OStatement subQuery, OCommandContext ctx, boolean profilingEnabled) { OBasicCommandContext subCtx = new OBasicCommandContext(); subCtx.setDatabase(ctx.getDatabase()); subCtx.setParent(ctx); OInternalExecutionPlan subExecutionPlan = subQuery.createExecutionPlan(subCtx, profilingEnabled); plan.chain(new SubQueryStep(subExecutionPlan, ctx, subCtx, profilingEnabled)); }
private void handleSubqueryAsTarget(OSelectExecutionPlan plan, OStatement subQuery, OCommandContext ctx, boolean profilingEnabled) { OBasicCommandContext subCtx = new OBasicCommandContext(); subCtx.setDatabase(ctx.getDatabase()); subCtx.setParent(ctx); OInternalExecutionPlan subExecutionPlan = subQuery.createExecutionPlan(subCtx, profilingEnabled); plan.chain(new SubQueryStep(subExecutionPlan, ctx, subCtx, profilingEnabled)); }