private Object toResult(OIdentifiable nextElement) { OResultInternal result = new OResultInternal(); result.setElement(nextElement); return result; }
protected Object toResult(OIdentifiable nextElement) { OResultInternal result = new OResultInternal(); result.setElement(nextElement); return result; }
@Override public OResult next() { if (!hasNext()) { throw new IllegalStateException(); } OEdge edge = nextEdge; fetchNextEdge(); OResultInternal result = new OResultInternal(); result.setElement(edge); return result; }
@Override public OResult next() { if (!hasNext()) { throw new IllegalStateException(); } OEdge edge = nextEdge; fetchNextEdge(); OResultInternal result = new OResultInternal(); result.setElement(edge); return result; }
@Override public OResult next() { long begin = profilingEnabled ? System.nanoTime() : 0; try { if (txEntries == null) { throw new IllegalStateException(); } if (currentElement >= nRecords) { throw new IllegalStateException(); } if (!txEntries.hasNext()) { throw new IllegalStateException(); } ORecord record = txEntries.next(); currentElement++; OResultInternal result = new OResultInternal(); result.setElement(record); ctx.setVariable("$current", result); return result; } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } }
@Override public OResult next() { Object val = iterator.next(); if (val instanceof OResult) { return (OResult) val; } OResultInternal result = new OResultInternal(); if (val instanceof OIdentifiable) { result.setElement((OIdentifiable) val); } else { result.setProperty("value", val); } return result; }
@Override public OResult transform(OrientElement element) { OResultInternal internal = new OResultInternal(); internal.setElement(element.getRawElement()); return internal; } }
private void fetchNext() { if (nextResult != null) { return; } while (iterator.hasNext()) { ORecordId nextRid = iterator.next(); if (nextRid == null) { continue; } OIdentifiable nextDoc = (OIdentifiable) ctx.getDatabase().load(nextRid); if (nextDoc == null) { continue; } nextResult = new OResultInternal(); ((OResultInternal) nextResult).setElement(nextDoc); return; } return; }
@Override protected Collection<OResult> unroll(OResult doc, OCommandContext iContext) { List<OResult> result = new ArrayList<>(); for (String s : doc.getPropertyNames()) { if (!s.startsWith(OMatchExecutionPlanner.DEFAULT_ALIAS_PREFIX)) { Object elem = doc.getProperty(s); if (elem instanceof OIdentifiable) { OResultInternal newelem = new OResultInternal(); newelem.setElement((OIdentifiable) elem); elem = newelem; } if (elem instanceof OResult) { result.add((OResult) elem); } //else...? TODO } } return result; }
@Override protected Collection<OResult> unroll(OResult doc, OCommandContext iContext) { List<OResult> result = new ArrayList<>(); for (String s : doc.getPropertyNames()) { Object elem = doc.getProperty(s); if (elem instanceof OIdentifiable) { OResultInternal newelem = new OResultInternal(); newelem.setElement((OIdentifiable) elem); elem = newelem; } if (elem instanceof OResult) { result.add((OResult) elem); } //else...? TODO } return result; }
@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() { OResult result = upstream.next(); if (result instanceof OResultInternal) { if (!(result.getElement().orElse(null) instanceof ODocument)) { ((OResultInternal) result).setElement(result.getElement().get().getRecord()); } if (!(result.getElement().orElse(null) instanceof ODocument)) { return result; } handleMerge((ODocument) result.getElement().orElse(null), ctx); } return result; }
@Override public OResult next() { OResult result = upstream.next(); if (result instanceof OResultInternal) { if (!(result.getElement().get() instanceof OElement)) { ((OResultInternal) result).setElement(result.getElement().get().getRecord()); } if (!(result.getElement().get() instanceof OElement)) { return result; } handleContent((OElement) result.getElement().get(), ctx); } return result; }
@Override public OResult next() { OResult result = upstream.next(); long begin = profilingEnabled ? System.nanoTime() : 0; try { if (result.getElement().orElse(null) instanceof OEdge) { return result; } if (result.isEdge()) { if (result instanceof OResultInternal) { ((OResultInternal) result).setElement(result.getElement().get().asEdge().get()); } else { OResultInternal r = new OResultInternal(); r.setElement(result.getElement().get().asEdge().get()); result = r; } } else { throw new OCommandExecutionException("Current element is not a vertex: " + result); } return result; } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } }
@Override public OResult next() { OResult result = upstream.next(); long begin = profilingEnabled ? System.nanoTime() : 0; try { if (result.getElement().orElse(null) instanceof OVertex) { return result; } if (result.isVertex()) { if (result instanceof OResultInternal) { ((OResultInternal) result).setElement(result.getElement().get().asVertex().get()); } else { OResultInternal r = new OResultInternal(); r.setElement(result.getElement().get().asVertex().get()); result = r; } } else { throw new OCommandExecutionException("Current element is not a vertex: " + result); } return result; } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } }
private void fetchNext(OCommandContext ctx) { this.nextResult = null; while (true) { while (currentIterator == null || !currentIterator.hasNext()) { if (!clusterIterators.hasNext()) { return; } currentIterator = clusterIterators.next(); } ORecord rec = currentIterator.next(); if (rec instanceof ODocument) { OResultInternal x = new OResultInternal(); x.setElement(rec); for (ORID rid : ridsToFind) { List<String> resultForRecord = checkObject(Collections.singleton(rid), x, rec, ""); if (resultForRecord.size() > 0) { nextResult = new OResultInternal(); nextResult.setProperty("rid", rid); nextResult.setProperty("referredBy", rec); nextResult.setProperty("fields", resultForRecord); return; } } } } }
@Override public OResult next() { OResult result = upstream.next(); if (result.isElement()) { OIdentifiable element = result.getElement().get().getRecord(); if (element instanceof ODocument) { ODocument doc = (ODocument) element; doc.setClassName(targetClass); if (!(result instanceof OResultInternal)) { result = new OUpdatableResult(doc); } else { ((OResultInternal) result).setElement(doc); } } } return result; }
if (element != null && element instanceof ODocument) { nextItem = new OResultInternal(); ((OResultInternal) nextItem).setElement(element);
@Override public OResult next() { OResult toCopy = upstream.next(); long begin = profilingEnabled ? System.nanoTime() : 0; try { ORecord resultDoc = null; if (toCopy.isElement()) { ORecord docToCopy = toCopy.getElement().get().getRecord(); if (docToCopy instanceof ODocument) { resultDoc = ((ODocument) docToCopy).copy(); resultDoc.getIdentity().reset(); ((ODocument) resultDoc).setClassName(null); resultDoc.setDirty(); } else if (docToCopy instanceof OBlob) { ORecordBytes newBlob = ((ORecordBytes) docToCopy).copy(); OResultInternal result = new OResultInternal(); result.setElement(newBlob); return result; } } else { resultDoc = toCopy.toElement().getRecord(); } return new OUpdatableResult((ODocument) resultDoc); } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } }
@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; }