/** * {@inheritDoc} */ @Override public void setPrefetchSize(int prefetchSize) { delegate.setPrefetchSize(prefetchSize); }
private boolean fetchValuesFromIndexCursor(final OIndexCursor cursor) { int needsToFetch; if (fetchLimit > 0) { needsToFetch = fetchLimit + skip; } else { needsToFetch = -1; } cursor.setPrefetchSize(needsToFetch); return fetchFromTarget(cursor); }
@Override @Guarded(by = STARTED) public <T> List<Entry<T, EntityId>> getNextPage(final OIndexCursor cursor, final int limit) { List<Entry<T, EntityId>> page = new ArrayList<>(limit); // For reasons unknown Orient needs the connection despite the code not using it try (ODatabaseDocumentTx db = databaseInstance.get().acquire()) { cursor.setPrefetchSize(limit); while (page.size() < limit) { Entry<Object, OIdentifiable> entry = cursor.nextEntry(); if (entry == null) { break; } @SuppressWarnings("unchecked") T key = (T) entry.getKey(); EntityId value = new AttachedEntityId(entityAdapter, entry.getValue().getIdentity()); page.add(new SimpleEntry<>(key, value)); } } return page; }
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(); } }