ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/6] incubator-ignite git commit: #ignite-51: GridCacheMapEntry.memorySize
Date Thu, 05 Mar 2015 11:33:19 GMT
#ignite-51: GridCacheMapEntry.memorySize


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

Branch: refs/heads/ignite-user-req
Commit: 121ce6ba642ab42a152f0e804de7fe9069bdb0e9
Parents: 814fae3
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Thu Mar 5 11:41:32 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Thu Mar 5 11:41:32 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     | 59 +++++++-------------
 1 file changed, 21 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/121ce6ba/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 0caf1f9..92654e3 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
@@ -76,7 +76,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
      * </ul>
      */
     // 7 * 8 /*references*/  + 2 * 8 /*long*/  + 1 * 4 /*int*/ + 1 * 1 /*byte*/ = 77
-    private static final int SIZE_OVERHEAD = 77 /*entry*/ + 32 /* version */;
+    private static final int SIZE_OVERHEAD = 77 /*entry*/ + 32 /* version */ + 4 * 7 /* key
+ val */;
 
     /** Static logger to avoid re-creation. Made static for test purpose. */
     protected static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
@@ -276,43 +276,26 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx
{
 
     /** {@inheritDoc} */
     @Override public int memorySize() throws IgniteCheckedException {
-// TODO IGNITE-51
-//        byte[] kb;
-//        GridCacheValueBytes vb;
-//
-//        CacheObject v;
-//
-//        int extrasSize;
-//
-//        synchronized (this) {
-//            kb = keyBytes;
-//            vb = valueBytesUnlocked();
-//
-//            v = val;
-//
-//            extrasSize = extrasSize();
-//        }
-//
-//        if (kb == null || (vb.isNull() && v != null)) {
-//            if (kb == null)
-//                kb = CU.marshal(cctx.shared(), key);
-//
-//            if (vb.isNull())
-//                vb = (v != null && v instanceof byte[]) ? GridCacheValueBytes.plain(v)
:
-//                    GridCacheValueBytes.marshaled(CU.marshal(cctx.shared(), v));
-//
-//            synchronized (this) {
-//                if (keyBytes == null)
-//                    keyBytes = kb;
-//
-//                // If value didn't change.
-//                if (!isOffHeapValuesOnly() && valBytes == null && val ==
v && cctx.config().isStoreValueBytes())
-//                    valBytes = vb.isPlain() ? null : vb.get();
-//            }
-//        }
-//
-//        return SIZE_OVERHEAD + extrasSize + kb.length + (vb.isNull() ? 0 : vb.get().length);
-        return 0;
+        byte[] kb;
+        byte[] vb = null;
+
+        int extrasSize;
+
+        synchronized (this) {
+            key.prepareMarshal(cctx.cacheObjectContext());
+
+            kb = key.valueBytes(cctx.cacheObjectContext());
+
+            if (val != null) {
+                val.prepareMarshal(cctx.cacheObjectContext());
+
+                vb = val.valueBytes(cctx.cacheObjectContext());
+            }
+
+           extrasSize = extrasSize();
+        }
+
+        return SIZE_OVERHEAD + extrasSize + kb.length + (vb == null ? 1 : vb.length);
     }
 
     /** {@inheritDoc} */


Mime
View raw message