public static ODocument getResult(final ODocument iValue, final Map<String, Object> iProjections) { if (iValue != null) { boolean canExcludeResult = false; for (Entry<String, Object> projection : iProjections.entrySet()) { if (!iValue.containsField(projection.getKey())) { // ONLY IF NOT ALREADY CONTAINS A VALUE, OTHERWISE HAS BEEN SET MANUALLY (INDEX?) final Object v = projection.getValue(); if (v instanceof OSQLFunctionRuntime) { final OSQLFunctionRuntime f = (OSQLFunctionRuntime) v; canExcludeResult = f.filterResult(); Object fieldValue = f.getResult(); if (fieldValue != null) iValue.field(projection.getKey(), fieldValue); } } } if (canExcludeResult && iValue.isEmpty()) // RESULT EXCLUDED FOR EMPTY RECORD return null; // AVOID SAVING OF TEMP RECORD ORecordInternal.unsetDirty(iValue); } return iValue; }
private static ODocument createIndexEntryAsDocument(final Object iKey, final OIdentifiable iValue) { final ODocument doc = new ODocument().setOrdered(true); doc.field("key", iKey); doc.field("rid", iValue); ORecordInternal.unsetDirty(doc); return doc; }
doc.field("key", (Object) null); doc.field("rid", ((OIdentifiable) item).getIdentity()); ORecordInternal.unsetDirty(doc);
private void fetchEntriesFromIndexCursor(final OIndexCursor cursor) { int needsToFetch; if (fetchLimit > 0) { needsToFetch = fetchLimit + skip; } else { needsToFetch = -1; } cursor.setPrefetchSize(needsToFetch); Entry<Object, OIdentifiable> entryRecord = cursor.nextEntry(); if (needsToFetch > 0) { needsToFetch--; } while (entryRecord != null) { final ODocument doc = new ODocument().setOrdered(true); doc.field("key", entryRecord.getKey()); doc.field("rid", entryRecord.getValue().getIdentity()); ORecordInternal.unsetDirty(doc); applyGroupBy(doc, context); if (!handleResult(doc, context)) { // LIMIT REACHED break; } if (needsToFetch > 0) { needsToFetch--; cursor.setPrefetchSize(needsToFetch); } entryRecord = cursor.nextEntry(); } }
ORecordInternal.unsetDirty(rec);