ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [05/10] ignite git commit: IGNITE-2706 - Fixed GridHandleTable.lookup()
Date Wed, 24 Feb 2016 05:59:33 GMT
IGNITE-2706 - Fixed GridHandleTable.lookup()


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

Branch: refs/heads/ignite-1232
Commit: 5436b62d9d0dc604c74e00ea80f31ec5ec41aec0
Parents: 57ac909
Author: Valentin Kulichenko <valentin.kulichenko@gmail.com>
Authored: Mon Feb 22 16:21:15 2016 -0800
Committer: Valentin Kulichenko <valentin.kulichenko@gmail.com>
Committed: Mon Feb 22 16:21:15 2016 -0800

----------------------------------------------------------------------
 .../ignite/internal/util/GridHandleTable.java   |  7 ++-
 .../internal/util/GridHandleTableSelfTest.java  | 50 ++++++++++++++++++++
 .../testsuites/IgniteBinaryBasicTestSuite.java  |  2 +
 .../IgniteMarshallerSelfTestSuite.java          |  6 ++-
 4 files changed, 61 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5436b62d/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
index dd85bcf..41a4da9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
@@ -92,9 +92,12 @@ public class GridHandleTable {
         if (size >= next.length)
             growEntries();
 
-        if (size >= threshold)
+        if (size >= threshold) {
             growSpine();
 
+            idx = hash(obj) % spine.length;
+        }
+
         insert(obj, size, idx);
 
         size++;
@@ -189,4 +192,4 @@ public class GridHandleTable {
     private int hash(Object obj) {
         return System.identityHashCode(obj) & 0x7FFFFFFF;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5436b62d/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java
new file mode 100644
index 0000000..bd6105f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/GridHandleTableSelfTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util;
+
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test for {@link GridHandleTable}.
+ */
+public class GridHandleTableSelfTest extends GridCommonAbstractTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testGrow() throws Exception {
+        GridHandleTable table = new GridHandleTable(8, 2);
+
+        for (int i = 0; i < 16; i++)
+            assertEquals(-1, table.lookup(i));
+
+        Object testObj = new Object();
+
+        assertEquals(-1, table.lookup(testObj));
+
+        assertEquals(16, table.lookup(testObj));
+
+        int cnt = 0;
+
+        for (Object obj : table.objects()) {
+            if (obj == testObj)
+                cnt++;
+        }
+
+        assertEquals(1, cnt);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5436b62d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
index e0c06dc..2aabf4f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingNe
 import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingRebalanceErrorTest;
 import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingTxErrorTest;
 import org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest;
+import org.apache.ignite.internal.util.GridHandleTableSelfTest;
 import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
 import org.apache.ignite.internal.util.IgniteUtilsSelfTest;
 import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
@@ -86,6 +87,7 @@ public class IgniteBinaryBasicTestSuite extends TestSuite {
         ignoredTests.add(GridVersionSelfTest.class);
         ignoredTests.add(GridDeploymentMessageCountSelfTest.class);
         ignoredTests.add(DynamicProxySerializationMultiJvmSelfTest.class);
+        ignoredTests.add(GridHandleTableSelfTest.class);
 
         // TODO: check and delete if pass.
         ignoredTests.add(IgniteDaemonNodeMarshallerCacheTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5436b62d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
index e4a2bee..33e7046 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
 import java.util.Set;
 import junit.framework.TestSuite;
 import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2ByteOrderSelfTest;
+import org.apache.ignite.internal.util.GridHandleTableSelfTest;
 import org.apache.ignite.internal.util.io.GridUnsafeDataInputOutputByteOrderSelfTest;
 import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
 import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest;
@@ -44,7 +45,7 @@ public class IgniteMarshallerSelfTestSuite extends TestSuite {
     }
 
     /**
-     * @param ignoredTests
+     * @param ignoredTests Ignored tests.
      * @return Test suite.
      * @throws Exception Thrown in case of the failure.
      */
@@ -61,7 +62,8 @@ public class IgniteMarshallerSelfTestSuite extends TestSuite {
         GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerNodeFailoverTest.class, ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerSerialPersistentFieldsSelfTest.class,
ignoredTests);
         GridTestUtils.addTestIfNeeded(suite, DirectByteBufferStreamImplV2ByteOrderSelfTest.class,
ignoredTests);
+        GridTestUtils.addTestIfNeeded(suite, GridHandleTableSelfTest.class, ignoredTests);
 
         return suite;
     }
-}
\ No newline at end of file
+}


Mime
View raw message