public static boolean checkInterruption(final OCommandContext iContext) { if (OExecutionThreadLocal.isInterruptCurrentOperation()) throw new OCommandInterruptedException("The command has been interrupted"); if (iContext != null && !iContext.checkTimeout()) return false; return true; }
@Override public OResult next() { if (localCount % 100 == 0 && OExecutionThreadLocal.isInterruptCurrentOperation()) { throw new OCommandInterruptedException("The command has been interrupted"); } long begin = profilingEnabled ? System.nanoTime() : 0; try { if (localCount >= nRecords) { throw new IllegalStateException(); } if (!fullResult.hasNext()) { throw new IllegalStateException(); } OResultInternal result = new OResultInternal(); result.setElement(fullResult.next()); ctx.setVariable("$current", result); localCount++; return result; } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } }
@Override public OResult next() { if (!hasNext()) { throw new IllegalStateException(); } if (localCount % 100 == 0 && OExecutionThreadLocal.isInterruptCurrentOperation()) { throw new OCommandInterruptedException("The command has been interrupted"); } long begin = profilingEnabled ? System.nanoTime() : 0; try { Object key = nextEntry.getKey(); OIdentifiable value = nextEntry.getValue(); nextEntry = null; localCount++; OResultInternal result = new OResultInternal(); result.setProperty("key", convertKey(key)); result.setProperty("rid", value); ctx.setVariable("$current", result); return result; } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } }
@Override public OResult next() { if (nFetched % 100 == 0 && OExecutionThreadLocal.isInterruptCurrentOperation()) { throw new OCommandInterruptedException("The command has been interrupted");
@Override public OResultSet syncPull(OCommandContext ctx, int nRecords) throws OTimeoutException { prev.get().syncPull(ctx, nRecords); if (finalResult != null) { return finalResult.syncPull(ctx, nRecords); } init(ctx); while (iterator.hasNext()) { if (OExecutionThreadLocal.isInterruptCurrentOperation()) { throw new OCommandInterruptedException("The command has been interrupted"); } ctx.setVariable(loopVariable.getStringValue(), iterator.next()); OScriptExecutionPlan plan = initPlan(ctx); OExecutionStepInternal result = plan.executeFull(); if (result != null) { this.finalResult = result; return result.syncPull(ctx, nRecords); } } finalResult = new EmptyStep(ctx, false); return finalResult.syncPull(ctx, nRecords); }
@Override public OResultSet syncPull(OCommandContext ctx, int nRecords) throws OTimeoutException { prev.ifPresent(x -> x.syncPull(ctx, nRecords)); if (finalResult != null) { return finalResult.syncPull(ctx, nRecords); } while (condition.evaluate(new OResultInternal(), ctx)) { if (OExecutionThreadLocal.isInterruptCurrentOperation()) throw new OCommandInterruptedException("The command has been interrupted"); OScriptExecutionPlan plan = initPlan(ctx); OExecutionStepInternal result = plan.executeFull(); if (result != null) { this.finalResult = result; return result.syncPull(ctx, nRecords); } } finalResult = new EmptyStep(ctx, false); return finalResult.syncPull(ctx, nRecords); }