public int usedIndexes(OGraph graph) { OExecutionPlan executionPlan = this.explain(graph).get(); if (target > 1) { return executionPlan.getSteps().stream().filter(step -> (step instanceof GlobalLetQueryStep)).map(s -> { GlobalLetQueryStep subStep = (GlobalLetQueryStep) s; return (int) subStep.getSubExecutionPlans().stream() .filter(plan -> plan.getSteps().stream().filter((step) -> step instanceof FetchFromIndexStep).count() > 0).count(); }).reduce(0, (a, b) -> a + b); } else { return (int) executionPlan.getSteps().stream().filter((step) -> step instanceof FetchFromIndexStep).count(); } }
@Override public OResult next() { if (!hasNext) { throw new IllegalStateException(); } OResultInternal result = new OResultInternal(); getExecutionPlan().ifPresent(x -> result.setProperty("executionPlan", x.toResult())); getExecutionPlan().ifPresent(x -> result.setProperty("executionPlanAsString", x.prettyPrint(0, 3))); hasNext = false; return result; }