public Object execute(Iterator iterator, OCommandContext ctx) { if (star) { return null; } List<Object> result = new ArrayList<>(); while (iterator.hasNext()) { result.add(execute(iterator.next(), ctx)); } if (iterator instanceof OResultSet) { try { ((OResultSet) iterator).reset(); } catch (Exception ignore) { } } return result; }
private void fetchNextRecord(int level) { OResultSet currentRs = resultSets.get(level); if (!currentRs.hasNext()) { if (level <= 0) { nextRecord = null; currentTuple = null; return; } currentRs = preFetches.get(level); currentRs.reset(); resultSets.set(level, currentRs); currentTuple.set(level, currentRs.next()); fetchNextRecord(level - 1); } else { currentTuple.set(level, currentRs.next()); } buildNextRecord(); }
rsRight.reset(); while (((OResultSet) iRight).hasNext()) { if (OQueryOperatorEquals.equals(iLeft, rsRight.next())) {
@Override public OResultSet executeSimple(OCommandContext ctx) { OInternalResultSet rs = new OInternalResultSet(); Object result = expression == null ? null : expression.execute((OResult) null, ctx); if (result instanceof OResult) { rs.add((OResult) result); } else if (result instanceof OIdentifiable) { OResultInternal res = new OResultInternal(); res.setElement((OIdentifiable) result); rs.add(res); } else if (result instanceof OResultSet) { if (!((OResultSet) result).hasNext()) { try { ((OResultSet) result).reset(); } catch (UnsupportedOperationException ignore) { // just try to reset the RS, in case it was already used during the script execution already // You can have two cases here: // - a result stored in a LET, that is always resettable, as it's copied // - a result from a direct query (eg. RETURN SELECT...), that is new or just empty, so this operation does not hurt } } return (OResultSet) result; } else { OResultInternal res = new OResultInternal(); res.setProperty("value", result); rs.add(res); } return rs; }