Skip to content

Commit

Permalink
#IGNITE-53: Move implementation from IgniteCacheProxy to GridCacheAda…
Browse files Browse the repository at this point in the history
…pter.
  • Loading branch information
ivasilinets committed Jan 23, 2015
1 parent 11db95b commit bdff6c5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
Expand Up @@ -827,19 +827,7 @@ else if (clazz.equals(Ignite.class))
GridCacheProjectionImpl<K, V> prev = gate.enter(prj);

try {
GridCacheQueryFuture<Map.Entry<K, V>> fut = delegate.queries().createScanQuery(null)
.keepAll(false)
.execute();

return ctx.itHolder().iterator(fut, new CacheIteratorConverter<Entry<K, V>, Map.Entry<K, V>>() {
@Override protected Entry<K, V> convert(Map.Entry<K, V> e) {
return new CacheEntryImpl<>(e.getKey(), e.getValue());
}

@Override protected void remove(Entry<K, V> item) {
IgniteCacheProxy.this.remove(item.getKey());
}
});
return ((GridCacheAdapter)delegate).igniteIterator();
}
finally {
gate.leave(prev);
Expand Down
Expand Up @@ -22,7 +22,6 @@
import org.apache.ignite.cluster.*;
import org.apache.ignite.compute.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.dataload.*;
import org.apache.ignite.fs.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.plugin.security.*;
Expand Down Expand Up @@ -52,6 +51,7 @@
import org.jdk8.backport.*;
import org.jetbrains.annotations.*;

import javax.cache.*;
import javax.cache.expiry.*;
import javax.cache.processor.*;
import java.io.*;
Expand Down Expand Up @@ -3618,6 +3618,30 @@ public void localLoad(Collection<? extends K> keys) throws IgniteCheckedExceptio
return entrySet().iterator();
}

/**
* @return Distributed ignite cache iterator.
*/
public Iterator<Cache.Entry<K, V>> igniteIterator() {
GridCacheQueryFuture<Map.Entry<K, V>> fut = queries().createScanQuery(null)
.keepAll(false)
.execute();

return ctx.itHolder().iterator(fut, new CacheIteratorConverter<Cache.Entry<K, V>, Map.Entry<K, V>>() {
@Override protected Cache.Entry<K, V> convert(Map.Entry<K, V> e) {
return new CacheEntryImpl<>(e.getKey(), e.getValue());
}

@Override protected void remove(Cache.Entry<K, V> item) {
try {
GridCacheAdapter.this.removex(item.getKey());
}
catch (IgniteCheckedException e) {
throw new CacheException(e);
}
}
});
}

/** {@inheritDoc} */
@Nullable @Override public V promote(K key) throws IgniteCheckedException {
return promote(key, true);
Expand Down

0 comments on commit bdff6c5

Please sign in to comment.