private void handleResultForReturnCount(OUpdateExecutionPlan result, OCommandContext ctx, boolean returnCount, boolean profilingEnabled) { if (returnCount) { result.chain(new CountStep(ctx, profilingEnabled)); } }
@Override public void reset(OCommandContext ctx) { result.clear(); next = 0; super.reset(ctx); executeInternal(); }
public OUpdateExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { OUpdateExecutionPlanner planner = new OUpdateExecutionPlanner(this); OUpdateExecutionPlan result = planner.createExecutionPlan(ctx, enableProfiling); result.setStatement(this.originalStatement); return result; }
@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); } }
public OUpdateExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { OUpdateExecutionPlan result = new OUpdateExecutionPlan(ctx); handleTarget(result, ctx, this.target, this.whereClause, this.timeout, enableProfiling); if(updateEdge){ result.chain(new CheckRecordTypeStep(ctx, "E", enableProfiling)); } handleUpsert(result, ctx, this.target, this.whereClause, this.upsert, enableProfiling); handleTimeout(result, ctx, this.timeout, enableProfiling); convertToModifiableResult(result, ctx, enableProfiling); handleLimit(result, ctx, this.limit, enableProfiling); handleReturnBefore(result, ctx, this.returnBefore, enableProfiling); handleOperations(result, ctx, this.operations, enableProfiling); handleLock(result, ctx, this.lockRecord); handleSave(result, ctx, enableProfiling); handleResultForReturnBefore(result, ctx, this.returnBefore, returnProjection, enableProfiling); handleResultForReturnAfter(result, ctx, this.returnAfter, returnProjection, enableProfiling); handleResultForReturnCount(result, ctx, this.returnCount, enableProfiling); return result; }
@Override public OResult toResult() { OResultInternal res = (OResultInternal) super.toResult(); res.setProperty("type", "DeleteExecutionPlan"); return res; }
public OUpdateExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { OUpdateExecutionPlan result = new OUpdateExecutionPlan(ctx); handleSource(result, ctx, this.source, enableProfiling); convertToModifiableResult(result, ctx, enableProfiling); handleTarget(result, targetClass, targetCluster, ctx, enableProfiling); handleOperations(result, ctx, this.updateOperations, enableProfiling); handleBatch(result, ctx, this.batch, enableProfiling); handleSave(result, ctx, enableProfiling); return result; }
@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); } }
private void handleReturnBefore(OUpdateExecutionPlan result, OCommandContext ctx, boolean returnBefore, boolean profilingEnabled) { if (returnBefore) { result.chain(new CopyRecordContentBeforeUpdateStep(ctx, profilingEnabled)); } }
@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); OUpdateExecutionPlan executionPlan = createExecutionPlan(ctx, false); executionPlan.executeInternal(); return new OLocalResultSet(executionPlan); }
@Override public OUpdateExecutionPlan createExecutionPlan(OCommandContext ctx, boolean enableProfiling) { OUpdateExecutionPlanner planner = new OUpdateExecutionPlanner(this); OUpdateExecutionPlan result = planner.createExecutionPlan(ctx, enableProfiling); result.setStatement(originalStatement); return result; }
private void handleUpsert(OUpdateExecutionPlan plan, OCommandContext ctx, OFromClause target, OWhereClause where, boolean upsert, boolean profilingEnabled) { if (upsert) { plan.chain(new UpsertStep(target, where, ctx, profilingEnabled)); } }
@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); OUpdateExecutionPlan executionPlan = createExecutionPlan(ctx, false); executionPlan.executeInternal(); return new OLocalResultSet(executionPlan); }
private void handleLimit(OUpdateExecutionPlan plan, OCommandContext ctx, OLimit limit, boolean profilingEnabled) { if (limit != null) { plan.chain(new LimitExecutionStep(limit, ctx, profilingEnabled)); } }
@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); OUpdateExecutionPlan executionPlan = createExecutionPlan(ctx, false); executionPlan.executeInternal(); return new OLocalResultSet(executionPlan); }
/** * add a step that transforms a normal OResult in a specific object that under setProperty() updates the actual OIdentifiable * * @param plan the execution plan * @param ctx the executino context */ private void convertToModifiableResult(OUpdateExecutionPlan plan, OCommandContext ctx, boolean profilingEnabled) { plan.chain(new ConvertToUpdatableResultStep(ctx, profilingEnabled)); }
@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); OUpdateExecutionPlan executionPlan = createExecutionPlan(ctx, false); executionPlan.executeInternal(); return new OLocalResultSet(executionPlan); }
private void handleResultForReturnCount(OUpdateExecutionPlan result, OCommandContext ctx, boolean returnCount, boolean profilingEnabled) { if (returnCount) { result.chain(new CountStep(ctx, profilingEnabled)); } }
@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); OUpdateExecutionPlan executionPlan = createExecutionPlan(ctx, false); executionPlan.executeInternal(); return new OLocalResultSet(executionPlan); }
private void handleResultForReturnAfter(OUpdateExecutionPlan result, OCommandContext ctx, boolean returnAfter, OProjection returnProjection, boolean profilingEnabled) { if (returnAfter) { //re-convert to normal step result.chain(new ConvertToResultInternalStep(ctx, profilingEnabled)); if (returnProjection != null) { result.chain(new ProjectionCalculationStep(returnProjection, ctx, profilingEnabled)); } } }