Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1156,13 +1156,20 @@ public GridCloseableIterator indexQueryLocal(final CacheQuery qry) throws Ignite
GridCloseableIterator<IgniteBiTuple<K, V>> iter = idxQryRes.iter();

return new GridCloseableIteratorAdapter() {
/** */
private int cnt;

@Override protected Object onNext() throws IgniteCheckedException {
IgniteBiTuple<K, V> entry = iter.nextX();
cnt++;

return new CacheEntryImpl<>(entry.getKey(), entry.getValue());
}

@Override protected boolean onHasNext() throws IgniteCheckedException {
if (qry.limit() > 0 && qry.limit() <= cnt)
return false;

return iter.hasNextX();
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ public void testSetLimit() {
assertEquals(limit, qry.getLimit());
}

/** */
@Test
public void testLocalQueryLimit() {
insertData(1);

IndexQuery<Long, Person> qry = new IndexQuery<Long, Person>(Person.class, IDX).setLimit(3);

qry.setLocal(true);

assertEquals(3, crd.cache(CACHE).query(qry).getAll().size());
}

/** */
private void checkRangeQueries(int duplicates) throws Exception {
// Add data
Expand Down
Loading