You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/03/09 19:34:31 UTC

[GitHub] [ignite] ptupitsyn opened a new pull request #8866: IGNITE-14293 .NET: Fix AffinityKey metadata in QueryEntity.KeyType

ptupitsyn opened a new pull request #8866:
URL: https://github.com/apache/ignite/pull/8866


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] ptupitsyn merged pull request #8866: IGNITE-14293 .NET: Fix AffinityKey metadata in QueryEntity.KeyType

Posted by GitBox <gi...@apache.org>.
ptupitsyn merged pull request #8866:
URL: https://github.com/apache/ignite/pull/8866


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] ptupitsyn commented on a change in pull request #8866: IGNITE-14293 .NET: Fix AffinityKey metadata in QueryEntity.KeyType

Posted by GitBox <gi...@apache.org>.
ptupitsyn commented on a change in pull request #8866:
URL: https://github.com/apache/ignite/pull/8866#discussion_r591528126



##########
File path: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityTest.cs
##########
@@ -121,6 +121,45 @@ public void TestAffinityKeyMappedWithQueryEntitySpringXml()
             }
         }
 
+        /// <summary>
+        /// Tests that <see cref="AffinityKey"/> works when used as <see cref="QueryEntity.KeyType"/>.
+        /// </summary>
+        [Test]
+        public void TestAffinityKeyWithQueryEntity()
+        {
+            var cacheCfg = new CacheConfiguration(TestUtils.TestName)
+            {
+                QueryEntities = new List<QueryEntity>
+                {
+                    new QueryEntity(typeof(AffinityKey), typeof(QueryEntityValue))
+                }
+            };
+
+            var ignite = Ignition.GetIgnite("grid-0");
+            var cache = ignite.GetOrCreateCache<AffinityKey, QueryEntityValue>(cacheCfg);
+            var aff = ignite.GetAffinity(cache.Name);
+
+            var ignite2 = Ignition.GetIgnite("grid-1");
+            var cache2 = ignite2.GetOrCreateCache<AffinityKey, QueryEntityValue>(cacheCfg);
+            var aff2 = ignite2.GetAffinity(cache2.Name);
+
+            // Check mapping.
+            for (var i = 0; i < 100; i++)
+            {
+                Assert.AreEqual(aff.GetPartition(i), aff.GetPartition(new AffinityKey("foo", i)));

Review comment:
       Fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] isapego commented on a change in pull request #8866: IGNITE-14293 .NET: Fix AffinityKey metadata in QueryEntity.KeyType

Posted by GitBox <gi...@apache.org>.
isapego commented on a change in pull request #8866:
URL: https://github.com/apache/ignite/pull/8866#discussion_r591514865



##########
File path: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityTest.cs
##########
@@ -121,6 +121,45 @@ public void TestAffinityKeyMappedWithQueryEntitySpringXml()
             }
         }
 
+        /// <summary>
+        /// Tests that <see cref="AffinityKey"/> works when used as <see cref="QueryEntity.KeyType"/>.
+        /// </summary>
+        [Test]
+        public void TestAffinityKeyWithQueryEntity()
+        {
+            var cacheCfg = new CacheConfiguration(TestUtils.TestName)
+            {
+                QueryEntities = new List<QueryEntity>
+                {
+                    new QueryEntity(typeof(AffinityKey), typeof(QueryEntityValue))
+                }
+            };
+
+            var ignite = Ignition.GetIgnite("grid-0");
+            var cache = ignite.GetOrCreateCache<AffinityKey, QueryEntityValue>(cacheCfg);
+            var aff = ignite.GetAffinity(cache.Name);
+
+            var ignite2 = Ignition.GetIgnite("grid-1");
+            var cache2 = ignite2.GetOrCreateCache<AffinityKey, QueryEntityValue>(cacheCfg);
+            var aff2 = ignite2.GetAffinity(cache2.Name);
+
+            // Check mapping.
+            for (var i = 0; i < 100; i++)
+            {
+                Assert.AreEqual(aff.GetPartition(i), aff.GetPartition(new AffinityKey("foo", i)));
+                Assert.AreEqual(aff2.GetPartition(i), aff2.GetPartition(new AffinityKey("bar", i)));
+                Assert.AreEqual(aff.GetPartition(i), aff2.GetPartition(i));
+            }
+
+            // Check put/get.
+            var key = new AffinityKey("x", 123);
+            cache[key] = new QueryEntityValue {Name = "y", AffKey = 321};
+
+            var val = cache2[key];
+            Assert.AreEqual("y", val.Name);
+            Assert.AreEqual(321, val.AffKey);

Review comment:
       Not critical, but there is duplication.
   ```suggestion
               var key = new AffinityKey("x", 123);
               var expected = new QueryEntityValue {Name = "y", AffKey = 321};
               cache[key] = expected;
   
               var val = cache2[key];
               Assert.AreEqual(expected.Name, val.Name);
               Assert.AreEqual(expected.AffKey, val.AffKey);
   ```

##########
File path: modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Affinity/AffinityTest.cs
##########
@@ -121,6 +121,45 @@ public void TestAffinityKeyMappedWithQueryEntitySpringXml()
             }
         }
 
+        /// <summary>
+        /// Tests that <see cref="AffinityKey"/> works when used as <see cref="QueryEntity.KeyType"/>.
+        /// </summary>
+        [Test]
+        public void TestAffinityKeyWithQueryEntity()
+        {
+            var cacheCfg = new CacheConfiguration(TestUtils.TestName)
+            {
+                QueryEntities = new List<QueryEntity>
+                {
+                    new QueryEntity(typeof(AffinityKey), typeof(QueryEntityValue))
+                }
+            };
+
+            var ignite = Ignition.GetIgnite("grid-0");
+            var cache = ignite.GetOrCreateCache<AffinityKey, QueryEntityValue>(cacheCfg);
+            var aff = ignite.GetAffinity(cache.Name);
+
+            var ignite2 = Ignition.GetIgnite("grid-1");
+            var cache2 = ignite2.GetOrCreateCache<AffinityKey, QueryEntityValue>(cacheCfg);
+            var aff2 = ignite2.GetAffinity(cache2.Name);
+
+            // Check mapping.
+            for (var i = 0; i < 100; i++)
+            {
+                Assert.AreEqual(aff.GetPartition(i), aff.GetPartition(new AffinityKey("foo", i)));

Review comment:
       I think we test is going to be more robust if we add variability to the string field as well. How about `"foo" + i`?
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org