ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [13/50] [abbrv] incubator-ignite git commit: ignite-96 added lazy value
Date Thu, 12 Feb 2015 09:44:38 GMT
ignite-96 added lazy value


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/aa455763
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/aa455763
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/aa455763

Branch: refs/heads/sprint-1
Commit: aa455763d9ea454cc99b327cdb52abc434ebfa08
Parents: 636667d
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Tue Feb 10 18:47:39 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Tue Feb 10 18:47:39 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheConcurrentMap.java           |  6 +-
 .../processors/cache/GridCacheContext.java      |  2 +-
 .../processors/cache/GridCacheEntryEx.java      |  7 +++
 .../cache/GridCacheEvictionManager.java         |  2 +-
 .../processors/cache/GridCacheKeySet.java       |  2 +-
 .../processors/cache/GridCacheMapEntry.java     | 59 +++++++++++++++++++-
 .../distributed/dht/GridDhtCacheAdapter.java    |  2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |  2 +-
 .../distributed/near/GridNearCacheAdapter.java  |  2 +-
 .../distributed/near/GridNearLockFuture.java    |  2 +-
 .../near/GridNearTransactionalCache.java        |  2 +-
 .../transactions/IgniteTxLocalAdapter.java      |  2 +-
 .../processors/cache/GridCacheTestEntryEx.java  |  5 ++
 13 files changed, 83 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
index 0e94d6e..889f73e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
@@ -1855,7 +1855,9 @@ public class GridCacheConcurrentMap<K, V> {
             GridCacheEntryEx<K, V> e = ctx.cache().peekEx(k);
 
             try {
-                return e != null && !e.obsolete() && (!e.deleted() || e.lockedByThread())
&& F.isAll(e.wrap(), filter);
+                return e != null && !e.obsolete() &&
+                    (!e.deleted() || e.lockedByThread()) &&
+                    F.isAll(e.wrapLazyValue(), filter);
             }
             catch (GridCacheEntryRemovedException ignore) {
                 return false;
@@ -2012,7 +2014,7 @@ public class GridCacheConcurrentMap<K, V> {
             CacheFlag[] oldFlags = ctx.forceFlags(forcedFlags);
 
             try {
-                return it.next().wrap();
+                return it.next().wrapLazyValue();
             }
             finally {
                 ctx.projectionPerCall(oldPrj);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index 492b90d..91a092e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1009,7 +1009,7 @@ public class GridCacheContext<K, V> implements Externalizable
{
         GridCacheEntryEx<K1, V1> e,
         @Nullable IgnitePredicate<Cache.Entry<K1, V1>>[] p
     ) throws IgniteCheckedException {
-        return F.isEmpty(p) || isAll(e.wrap(), p);
+        return F.isEmpty(p) || isAll(e.wrapLazyValue(), p);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index dff1b9d..145627f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -141,6 +141,13 @@ public interface GridCacheEntryEx<K, V> {
     public Cache.Entry<K, V> wrap();
 
     /**
+     * Wraps entry to an entry with lazy value get.
+     *
+     * @return Entry.
+     */
+    public Cache.Entry<K, V> wrapLazyValue();
+
+    /**
      * Wraps this map entry into cache entry for filter evaluation inside entry lock.
      *
      * @return Wrapped entry.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index b3ef296..0c4fe61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -1317,7 +1317,7 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K,
V
         if (log.isDebugEnabled())
             log.debug("Notifying eviction policy with entry: " + e);
 
-        if (filter == null || filter.evictAllowed(e.wrap()))
+        if (filter == null || filter.evictAllowed(e.wrapLazyValue()))
             plc.onEntryAccessed(e.obsoleteOrDeleted(), e.wrapEviction());
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
index 0f2f369..df1bc8e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheKeySet.java
@@ -49,7 +49,7 @@ public class GridCacheKeySet<K, V> extends GridSerializableSet<K>
{
      */
     public GridCacheKeySet(GridCacheContext<K, V> ctx, Collection<? extends Cache.Entry<K,
V>> c,
         IgnitePredicate<Cache.Entry<K, V>>[] filter) {
-        map = new HashMap<>(c.size(), 1.0f);
+        map = new HashMap<>();
 
         assert ctx != null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 40bac37..5802227 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -3718,6 +3718,11 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
         }
     }
 
+    /** {@inheritDoc} */
+    @Override public Cache.Entry<K, V> wrapLazyValue() {
+        return new IteratorEntry(key);
+    }
+
         /** {@inheritDoc} */
     @Override public Cache.Entry<K, V> wrapFilterLocked() throws IgniteCheckedException
{
         return new CacheEntryImpl<>(key, rawGetOrUnmarshal(true));
@@ -3904,7 +3909,8 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
      */
     public boolean visitable(IgnitePredicate<Cache.Entry<K, V>>[] filter) {
         try {
-            if (obsoleteOrDeleted() || (filter != CU.<K, V>empty() && !cctx.isAll(wrap(),
filter)))
+            if (obsoleteOrDeleted() || (filter != CU.<K, V>empty() &&
+                !cctx.isAll(wrapLazyValue(), filter)))
                 return false;
         }
         catch (IgniteCheckedException e) {
@@ -4322,4 +4328,55 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
     @Override public synchronized String toString() {
         return S.toString(GridCacheMapEntry.class, this);
     }
+
+    /**
+     *
+     */
+    private class IteratorEntry implements Cache.Entry<K, V> {
+        /** */
+        private final K key;
+
+        /**
+         * @param key Key.
+         */
+        private IteratorEntry(K key) {
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public K getKey() {
+            return key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public V getValue() {
+            for (;;) {
+                GridCacheEntryEx<K, V> e = cctx.cache().peekEx(key);
+
+                if (e == null)
+                    return null;
+
+                try {
+                    return e.peek(GridCachePeekMode.GLOBAL, CU.<K, V>empty());
+                }
+                catch (GridCacheEntryRemovedException ignored) {
+                    // No-op.
+                }
+            }
+        }
+
+        /** {@inheritDoc} */
+        @SuppressWarnings("unchecked")
+        @Override public <T> T unwrap(Class<T> cls) {
+            if (!cls.equals(getClass()))
+                throw new IllegalArgumentException("Unwrapping to class is not supported:
" + cls);
+
+            return (T)this;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "IteratorEntry [key=" + key + ']';
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 483016d..641651c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -1050,7 +1050,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
                     if (next.isInternal() || !next.visitable(CU.<K, V>empty()))
                         continue;
 
-                    entry = next.wrap();
+                    entry = next.wrapLazyValue();
 
                     return;
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 932a040..57811e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -436,7 +436,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
             for (K key : keys) {
                 GridDistributedCacheEntry<K, V> entry = peekExx(key);
 
-                Cache.Entry<K, V> Entry = entry == null ? entry(key) : entry.wrap();
+                Cache.Entry<K, V> Entry = entry == null ? entry(key) : entry.wrapLazyValue();
 
                 if (!ctx.isAll(Entry, filter))
                     break; // While.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index f198994..00fa5e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -390,7 +390,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
                                 p.entries(),
                                 new C1<GridDhtCacheEntry<K, V>, Cache.Entry<K,
V>>() {
                                     @Override public Cache.Entry<K, V> apply(GridDhtCacheEntry<K,
V> e) {
-                                        return e.wrap();
+                                        return e.wrapLazyValue();
                                     }
                                 },
                                 new P1<GridDhtCacheEntry<K, V>>() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 43bb8f0..23d3f78 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -796,7 +796,7 @@ public final class GridNearLockFuture<K, V> extends GridCompoundIdentityFuture<B
                         try {
                             entry = cctx.near().entryExx(key, topVer);
 
-                            if (!cctx.isAll(entry.wrap(), filter)) {
+                            if (!cctx.isAll(entry.wrapLazyValue(), filter)) {
                                 if (log.isDebugEnabled())
                                     log.debug("Entry being locked did not pass filter (will
not lock): " + entry);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index 33affeb..c9a9cc0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -486,7 +486,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K,
V>
                 while (true) {
                     GridDistributedCacheEntry<K, V> entry = peekExx(key);
 
-                    if (entry == null || !ctx.isAll(entry.wrap(), filter))
+                    if (entry == null || !ctx.isAll(entry.wrapLazyValue(), filter))
                         break; // While.
 
                     try {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 4563ce1..1e5c9b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -295,7 +295,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
             // We should look at tx entry previous value. If this is a user peek then previous
             // value is the same as value. If this is a filter evaluation peek then previous
value holds
             // value visible to filter while value contains value enlisted for write.
-            if (!F.isEmpty(filter) && !F.isAll(e.cached().wrap(), filter))
+            if (!F.isEmpty(filter) && !F.isAll(e.cached().wrapLazyValue(), filter))
                 return e.hasPreviousValue() ? F.t(CU.<V>failed(failFast, e.previousValue()))
: null;
 
             return e.hasPreviousValue() ? F.t(e.previousValue()) : null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aa455763/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index 670958c..7b6e335 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -342,6 +342,11 @@ public class GridCacheTestEntryEx<K, V> extends GridMetadataAwareAdapter
impleme
         assert false; return null;
     }
 
+    /** @inheritDoc */
+    @Override public Cache.Entry<K, V> wrapLazyValue() {
+        assert false; return null;
+    }
+
     /** {@inheritDoc} */
     @Override public CacheVersionedEntryImpl<K, V> wrapVersioned() {
         assert false; return null;


Mime
View raw message