Skip to content

Commit

Permalink
Fix IgniteCacheIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ivasilinets committed Jan 29, 2015
1 parent 4535322 commit 9900ae4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 14 deletions.
Expand Up @@ -3887,10 +3887,10 @@ IgniteInternalFuture<?> globalLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p
} }


/** /**
* @param prj Projection. * @param delegate Cache proxy.
* @return Distributed ignite cache iterator. * @return Distributed ignite cache iterator.
*/ */
public Iterator<Cache.Entry<K, V>> igniteIterator(final GridCacheProjectionImpl<K, V> prj) { public Iterator<Cache.Entry<K, V>> igniteIterator(final IgniteCacheProxy<K, V> delegate) {
CacheQueryFuture<Map.Entry<K, V>> fut = queries().createScanQuery(null) CacheQueryFuture<Map.Entry<K, V>> fut = queries().createScanQuery(null)
.keepAll(false) .keepAll(false)
.execute(); .execute();
Expand All @@ -3901,17 +3901,7 @@ public Iterator<Cache.Entry<K, V>> igniteIterator(final GridCacheProjectionImpl<
} }


@Override protected void remove(Cache.Entry<K, V> item) { @Override protected void remove(Cache.Entry<K, V> item) {
GridCacheProjectionImpl<K, V> prev = ctx.gate().enter(prj); delegate.remove(item.getKey());

try {
GridCacheAdapter.this.removex(item.getKey());
}
catch (IgniteCheckedException e) {
throw new CacheException(e);
}
finally {
ctx.gate().leave(prev);
}
} }
}); });
} }
Expand Down
Expand Up @@ -943,7 +943,7 @@ else if (clazz.equals(Ignite.class))
GridCacheProjectionImpl<K, V> prev = gate.enter(prj); GridCacheProjectionImpl<K, V> prev = gate.enter(prj);


try { try {
return ((GridCacheAdapter)delegate).igniteIterator(prj); return ctx.cache().igniteIterator(this);
} }
finally { finally {
gate.leave(prev); gate.leave(prev);
Expand Down
Expand Up @@ -614,6 +614,56 @@ public void testSkipStoreFlag() throws Exception {
assertEquals(100500, (Object) cache().get("kk1")); assertEquals(100500, (Object) cache().get("kk1"));
} }


/**
* @throws Exception if failed.
*/
public void testSkipStoreIterator() throws Exception {
assertNull(cache().put("1", 100500));

IgniteCache<String, Integer> c = jcache().withSkipStore();

Iterator i = c.iterator();

assertTrue(i.hasNext());

i.next();

i.remove();

i = c.iterator();

assertFalse(i.hasNext());

assertNull(c.get("1"));

assertEquals(100500, map.get("1"));
}

/**
* @throws Exception if failed.
*/
public void testNotSkipStoreIterator() throws Exception {
assertNull(cache().put("1", 100500));

IgniteCache<String, Integer> c = jcache();

Iterator i = c.iterator();

assertTrue(i.hasNext());

i.next();

i.remove();

i = c.iterator();

assertFalse(i.hasNext());

assertNull(c.get("1"));

assertNull(map.get("1"));
}

/** /**
* @throws Exception if failed. * @throws Exception if failed.
*/ */
Expand Down

0 comments on commit 9900ae4

Please sign in to comment.