@Override public boolean canBeCached() { for (OExecutionStepInternal step : steps) { if (!step.canBeCached()) { return false; } } return true; }
@Override public void close() { lastStep.close(); }
protected void copyOn(OSelectExecutionPlan copy, OCommandContext ctx) { OExecutionStep lastStep = null; for (OExecutionStep step : this.steps) { OExecutionStepInternal newStep = (OExecutionStepInternal) ((OExecutionStepInternal) step).copy(ctx); newStep.setPrevious((OExecutionStepInternal) lastStep); if (lastStep != null) { ((OExecutionStepInternal) lastStep).setNext(newStep); } lastStep = newStep; copy.getSteps().add(newStep); } copy.lastStep = copy.steps.size() == 0 ? null : copy.steps.get(copy.steps.size() - 1); copy.location = this.location; copy.statement = this.statement; }
@Override public String prettyPrint(int depth, int indent) { String spaces = OExecutionStepInternal.getIndent(depth, indent); return spaces + "+ RETURN $paths"; }
static OResultInternal basicSerialize(OExecutionStepInternal step) { OResultInternal result = new OResultInternal(); result.setProperty(OInternalExecutionPlan.JAVA_TYPE, step.getClass().getName()); if (step.getSubSteps() != null && step.getSubSteps().size() > 0) { List<OResult> serializedSubsteps = new ArrayList<>(); for (OExecutionStep substep : step.getSubSteps()) { serializedSubsteps.add(((OExecutionStepInternal) substep).serialize()); } result.setProperty("subSteps", serializedSubsteps); } if (step.getSubExecutionPlans() != null && step.getSubExecutionPlans().size() > 0) { List<OResult> serializedSubPlans = new ArrayList<>(); for (OExecutionPlan substep : step.getSubExecutionPlans()) { serializedSubPlans.add(((OInternalExecutionPlan) substep).serialize()); } result.setProperty("subExecutionPlans", serializedSubPlans); } return result; }
static void basicDeserialize(OResult serialized, OExecutionStepInternal step) throws ClassNotFoundException, IllegalAccessException, InstantiationException { List<OResult> serializedSubsteps = serialized.getProperty("subSteps"); if (serializedSubsteps != null) { for (OResult serializedSub : serializedSubsteps) { String className = serializedSub.getProperty(OInternalExecutionPlan.JAVA_TYPE); OExecutionStepInternal subStep = (OExecutionStepInternal) Class.forName(className).newInstance(); subStep.deserialize(serializedSub); step.getSubSteps().add(subStep); } } List<OResult> serializedPlans = serialized.getProperty("subExecutionPlans"); if (serializedSubsteps != null) { for (OResult serializedSub : serializedPlans) { String className = serializedSub.getProperty(OInternalExecutionPlan.JAVA_TYPE); OInternalExecutionPlan subStep = (OInternalExecutionPlan) Class.forName(className).newInstance(); subStep.deserialize(serializedSub); step.getSubExecutionPlans().add(subStep); } } }
@Override public OResult serialize() { OResultInternal result = OExecutionStepInternal.basicSerialize(this); if (clusters != null) { result.setProperty("clusters", clusters); } return result; }
@Override public void deserialize(OResult fromResult) { try { OExecutionStepInternal.basicDeserialize(fromResult, this); if (fromResult.getProperty("rids") != null) { List<String> ser = fromResult.getProperty("rids"); rids = ser.stream().map(x -> new ORecordId(x)).collect(Collectors.toList()); } reset(); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException(""), e); } } }
@Override public String prettyPrint(int depth, int indent) { StringBuilder builder = new StringBuilder(); String ind = OExecutionStepInternal.getIndent(depth, indent); builder.append(ind); builder.append("+ FETCH FROM CLUSTERS"); if (profilingEnabled) { builder.append(" (" + getCostFormatted() + ")"); } builder.append("\n"); for (int i = 0; i < subSteps.size(); i++) { OExecutionStepInternal step = (OExecutionStepInternal) subSteps.get(i); builder.append(step.prettyPrint(depth + 1, indent)); if (i < subSteps.size() - 1) { builder.append("\n"); } } return builder.toString(); }
default String getDescription() { return prettyPrint(0, 3); }
@Override public OExecutionStep copy(OCommandContext ctx) { FetchFromClassExecutionStep result = new FetchFromClassExecutionStep(ctx, profilingEnabled); result.className = this.className; result.orderByRidAsc = this.orderByRidAsc; result.orderByRidDesc = this.orderByRidDesc; result.subSteps = this.subSteps.stream().map(x -> ((OExecutionStepInternal) x).copy(ctx)).collect(Collectors.toList()); 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); } } }
@Override public String prettyPrint(int depth, int indent) { String spaces = OExecutionStepInternal.getIndent(depth, indent); return spaces + "+ LET (for each record)\n" + spaces + " " + varname + " = " + expression; }
@Override public OResult serialize() { OResultInternal result = OExecutionStepInternal.basicSerialize(this); result.setProperty("className", className); return result; }
@Override public void deserialize(OResult fromResult) { try { OExecutionStepInternal.basicDeserialize(fromResult, this); className = fromResult.getProperty("className"); } catch (Exception e) { throw OException.wrapException(new OCommandExecutionException(""), e); } }
@Override public String prettyPrint(int depth, int indent) { StringBuilder builder = new StringBuilder(); String ind = OExecutionStepInternal.getIndent(depth, indent); builder.append(ind); builder.append("+ FETCH FROM CLASS " + className); if (profilingEnabled) { builder.append(" (" + getCostFormatted() + ")"); } builder.append("\n"); for (int i = 0; i < getSubSteps().size(); i++) { OExecutionStepInternal step = (OExecutionStepInternal) getSubSteps().get(i); builder.append(step.prettyPrint(depth + 1, indent)); if (i < getSubSteps().size() - 1) { builder.append("\n"); } } return builder.toString(); }
@Override public String prettyPrint(int depth, int indent) { StringBuilder result = new StringBuilder(); for (int i = 0; i < steps.size(); i++) { OExecutionStepInternal step = steps.get(i); result.append(step.prettyPrint(depth, indent)); if (i < steps.size() - 1) { result.append("\n"); } } return result.toString(); }
@Override public String prettyPrint(int depth, int indent) { String spaces = OExecutionStepInternal.getIndent(depth, indent); return spaces + "+ UNROLL $elements"; } }
@Override public OResult serialize() { OResultInternal result = OExecutionStepInternal.basicSerialize(this); if (rids != null) { result.setProperty("rids", rids.stream().map(x -> x.toString()).collect(Collectors.toList())); } return result; }
@Override public void close() { lastStep.close(); }