You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2021/01/28 10:10:22 UTC

[ignite] branch ignite-14067 created (now afa2314)

This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a change to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git.


      at afa2314  cleanup

This branch includes the following new commits:

     new 275040a  add test
     new a0050d1  add test
     new a7a2cbe  add failing test
     new 973fc801 Add PutAllTxTest (remove later)
     new 9879c15  Add localCandidatesMax to reduce allocations
     new 96b3d9a  Add localCandidatesMax to reduce allocations
     new 66ef7de  Improve IgniteTxStateImpl.validateTopology for single cache scenario
     new 8460677  TODOs
     new afa2314  cleanup

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[ignite] 01/09: add test

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 275040a37bc43ac7379992c64126c410bd2fcacc
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Wed Jan 27 18:28:50 2021 +0300

    add test
---
 .../Binary/BinarySelfTest.cs                       | 65 +++++++++++++++-------
 1 file changed, 44 insertions(+), 21 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index bf3b474..b167c46 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -45,7 +45,7 @@ namespace Apache.Ignite.Core.Tests.Binary
     /// Binary tests.
     /// </summary>
     [TestFixture]
-    public class BinarySelfTest { 
+    public class BinarySelfTest {
         /** */
         private Marshaller _marsh;
 
@@ -59,7 +59,7 @@ namespace Apache.Ignite.Core.Tests.Binary
         };
 
         /// <summary>
-        /// 
+        ///
         /// </summary>
         [TestFixtureSetUp]
         public void BeforeTest()
@@ -86,7 +86,7 @@ namespace Apache.Ignite.Core.Tests.Binary
         {
             return BinaryBasicNameMapper.FullNameInstance;
         }
-        
+
         /**
          * <summary>Check write of primitive boolean.</summary>
          */
@@ -627,7 +627,7 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             Assert.AreEqual(vals, newVals);
         }
-        
+
         /// <summary>
         /// Test object with dates.
         /// </summary>
@@ -650,7 +650,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
 
             Assert.AreEqual(obj.Utc, otherObj.Utc);
-            Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);            
+            Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
             Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
 
             Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
@@ -723,7 +723,7 @@ namespace Apache.Ignite.Core.Tests.Binary
                 },
                 Objects = new object[] {1, 2, "3", 4.4}
             };
-            
+
             var data = marsh.Marshal(obj);
 
             var result = marsh.Unmarshal<GenericCollectionsType<PrimitiveFieldType, SerializableObject>>(data);
@@ -786,7 +786,7 @@ namespace Apache.Ignite.Core.Tests.Binary
         [Test]
         public void TestProperty()
         {
-            ICollection<BinaryTypeConfiguration> typeCfgs = 
+            ICollection<BinaryTypeConfiguration> typeCfgs =
                 new List<BinaryTypeConfiguration>();
 
             typeCfgs.Add(new BinaryTypeConfiguration(typeof(PropertyType)));
@@ -1080,7 +1080,7 @@ namespace Apache.Ignite.Core.Tests.Binary
                 },
                 CompactFooter = GetCompactFooter()
             });
-            
+
             var obj = new CollectionsType
             {
                 Hashtable = new Hashtable {{1, 2}, {3, 4}},
@@ -1571,7 +1571,7 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             PropertyType[,] objs = {{new PropertyType {Field1 = 123}}};
             Assert.AreEqual(123, TestUtils.SerializeDeserialize(objs)[0, 0].Field1);
-            
+
             var obj = new MultidimArrays { MultidimInt = ints, MultidimUInt = uints };
             var resObj = TestUtils.SerializeDeserialize(obj);
             Assert.AreEqual(obj.MultidimInt, resObj.MultidimInt);
@@ -1615,7 +1615,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             };
 
             var res = TestUtils.SerializeDeserialize(ptrs, raw);
-            
+
             Assert.IsTrue(ptrs.ByteP == res.ByteP);
             Assert.IsTrue(ptrs.IntP == res.IntP);
             Assert.IsTrue(ptrs.VoidP == res.VoidP);
@@ -1645,18 +1645,36 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             IBinaryObject innerObject = _marsh.Unmarshal<IBinaryObject>(dataInner, BinaryMode.ForceBinary);
             BinaryObjectWrapper inner = innerObject.Deserialize<BinaryObjectWrapper>();
-            
+
             Assert.NotNull(inner);
 
             byte[] dataOuter = _marsh.Marshal(new BinaryObjectWrapper() { Val = innerObject });
 
             IBinaryObject outerObject = _marsh.Unmarshal<IBinaryObject>(dataOuter, BinaryMode.ForceBinary);
             BinaryObjectWrapper outer = outerObject.Deserialize<BinaryObjectWrapper>();
-            
+
             Assert.NotNull(outer);
             Assert.IsTrue(outer.Val.Equals(innerObject));
         }
 
+        /// <summary>
+        /// Tests serializing/deserializing object lists with nested lists.
+        /// </summary>
+        [Test]
+        public void TestNestedLists()
+        {
+            var list = new[]
+            {
+                new NestedList {Inner = new List<object>()},
+                new NestedList {Inner = new List<object>()}
+            };
+
+            var bytes = _marsh.Marshal(list);
+            var res = _marsh.Unmarshal<NestedList[]>(bytes);
+
+            Assert.AreEqual(2, res.Length);
+        }
+
         private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
         {
             if (cfg.TypeConfigurations == null)
@@ -1681,7 +1699,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.AreEqual(expKeep, deserialized1 == deserialized2);
         }
 
-        private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter, 
+        private void CheckHandlesConsistency(HandleOuter outer, HandleInner inner, HandleOuter newOuter,
             HandleInner newInner)
         {
             Assert.True(newOuter != null);
@@ -1698,7 +1716,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.AreEqual(inner.After, newInner.After);
             Assert.AreEqual(inner.RawBefore, newInner.RawBefore);
             Assert.True(newInner.RawOuter == newOuter);
-            Assert.AreEqual(inner.RawAfter, newInner.RawAfter);            
+            Assert.AreEqual(inner.RawAfter, newInner.RawAfter);
         }
 
         private static void CheckObject(Marshaller marsh, OuterObjectType outObj, InnerObjectType inObj)
@@ -1728,7 +1746,7 @@ namespace Apache.Ignite.Core.Tests.Binary
                     return true;
 
                 var type = obj as OuterObjectType;
-                
+
                 return type != null && Equals(InObj, type.InObj);
             }
 
@@ -1775,7 +1793,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             public ICollection Col1 { get; set; }
 
             public ArrayList Col2 { get; set; }
-            
+
             public TestList Col3 { get; set; }
 
             public Hashtable Hashtable { get; set; }
@@ -1798,8 +1816,8 @@ namespace Apache.Ignite.Core.Tests.Binary
 
                 var that = obj as CollectionsType;
 
-                return that != null 
-                    && CompareCollections(Col1, that.Col1) 
+                return that != null
+                    && CompareCollections(Col1, that.Col1)
                     && CompareCollections(Col2, that.Col2)
                     && CompareCollections(Hashtable, that.Hashtable)
                     && CompareCollections(Dict, that.Dict)
@@ -1972,7 +1990,7 @@ namespace Apache.Ignite.Core.Tests.Binary
         }
 
         [Serializable]
-        public class PrimitiveFieldType 
+        public class PrimitiveFieldType
         {
             public PrimitiveFieldType()
             {
@@ -2456,7 +2474,7 @@ namespace Apache.Ignite.Core.Tests.Binary
                 writer.WriteString("before", Before);
 
                 writer0.WriteObject("inner", Inner);
-                
+
                 writer.WriteString("after", After);
 
                 IBinaryRawWriter rawWriter = writer.GetRawWriter();
@@ -2738,7 +2756,7 @@ namespace Apache.Ignite.Core.Tests.Binary
 
             public int[,] MultidimInt { get; set; }
             public uint[,,] MultidimUInt { get; set; }
-            
+
             public void WriteBinary(IBinaryWriter writer)
             {
                 writer.WriteObject("JaggedInt", JaggedInt);
@@ -2773,5 +2791,10 @@ namespace Apache.Ignite.Core.Tests.Binary
         {
             public IBinaryObject Val;
         }
+
+        private class NestedList
+        {
+            public IList<object> Inner { get; set; }
+        }
     }
 }


[ignite] 07/09: Improve IgniteTxStateImpl.validateTopology for single cache scenario

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 66ef7decf714a845d85b892e49ce42d3a6357702
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jan 28 12:52:15 2021 +0300

    Improve IgniteTxStateImpl.validateTopology for single cache scenario
---
 .../cache/transactions/IgniteTxStateImpl.java      | 46 +++++++++++++++-------
 .../processors/cache/GridCacheTestEntryEx.java     |  6 +++
 2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
index 00d4817..b331a71 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxStateImpl.java
@@ -30,6 +30,7 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.cache.CacheInterceptor;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheInvalidStateException;
 import org.apache.ignite.internal.processors.cache.CacheStoppedException;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -138,36 +139,53 @@ public class IgniteTxStateImpl extends IgniteTxLocalStateAdapter {
         boolean read,
         GridDhtTopologyFuture topFut
     ) {
-        Map<Integer, Set<KeyCacheObject>> keysByCacheId = new HashMap<>();
+        if (activeCacheIds.size() == 1) {
+            IgniteTxKey anyKey = txMap.keySet().iterator().next();
+
+            int cacheId = anyKey.cacheId();
+            GridCacheContext ctx = cctx.cacheContext(cacheId);
 
-        for (IgniteTxKey key : txMap.keySet()) {
-            Set<KeyCacheObject> set = keysByCacheId.get(key.cacheId());
+            assert ctx != null : cacheId;
 
-            if (set == null)
-                keysByCacheId.put(key.cacheId(), set = new HashSet<>());
+            CacheInvalidStateException err = topFut.validateCache(ctx, recovery(), read, null, txMap.keySet());
 
-            set.add(key.key());
+            if (err != null)
+                return err;
         }
+        else {
+            Map<Integer, Set<KeyCacheObject>> keysByCacheId = new HashMap<>();
 
-        for (Map.Entry<Integer, Set<KeyCacheObject>> e : keysByCacheId.entrySet()) {
-            int cacheId = e.getKey();
+            for (IgniteTxKey key : txMap.keySet()) {
+                Set<KeyCacheObject> set = keysByCacheId.get(key.cacheId());
 
-            GridCacheContext ctx = cctx.cacheContext(cacheId);
+                if (set == null)
+                    keysByCacheId.put(key.cacheId(), set = new HashSet<>());
 
-            assert ctx != null : cacheId;
+                set.add(key.key());
+            }
 
-            CacheInvalidStateException err = topFut.validateCache(ctx, recovery(), read, null, e.getValue());
+            for (Map.Entry<Integer, Set<KeyCacheObject>> e : keysByCacheId.entrySet()) {
+                int cacheId = e.getKey();
 
-            if (err != null)
-                return err;
+                GridCacheContext ctx = cctx.cacheContext(cacheId);
+
+                assert ctx != null : cacheId;
+
+                CacheInvalidStateException err = topFut.validateCache(ctx, recovery(), read, null, e.getValue());
+
+                if (err != null)
+                    return err;
+            }
         }
 
+        AffinityTopologyVersion topVer = topFut.topologyVersion();
+
         for (int i = 0; i < activeCacheIds.size(); i++) {
             int cacheId = activeCacheIds.get(i);
 
             GridCacheContext<?, ?> cacheCtx = cctx.cacheContext(cacheId);
 
-            if (CU.affinityNodes(cacheCtx, topFut.topologyVersion()).isEmpty()) {
+            if (CU.affinityNodes(cacheCtx, topVer).isEmpty()) {
                 return new ClusterTopologyServerNotFoundException("Failed to map keys for cache (all " +
                     "partition nodes left the grid): " + cacheCtx.name());
             }
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 c406054..f024c16 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
@@ -800,6 +800,12 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
         return mvcc.localCandidates(exclude);
     }
 
+    @Override
+    public Collection<GridCacheMvccCandidate> localCandidatesMax(GridCacheVersion maxVer) throws GridCacheEntryRemovedException {
+        // TODO
+        return null;
+    }
+
     /** @inheritDoc */
     Collection<GridCacheMvccCandidate> localCandidates(boolean reentries, GridCacheVersion... exclude) {
         return mvcc.localCandidates(reentries, exclude);


[ignite] 09/09: cleanup

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit afa2314e0c77d1bf548cc89e71f0bfd627f8f7c1
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jan 28 13:09:32 2021 +0300

    cleanup
---
 .../Binary/BinarySelfTest.cs                       | 25 -----------
 .../Binary/NestedListsTest.cs                      | 52 ----------------------
 2 files changed, 77 deletions(-)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index bf75ae5..74e5413 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -1657,25 +1657,6 @@ namespace Apache.Ignite.Core.Tests.Binary
             Assert.IsTrue(outer.Val.Equals(innerObject));
         }
 
-        /// <summary>
-        /// Tests serializing/deserializing object lists with nested lists.
-        /// </summary>
-        [Test]
-        public void TestNestedLists()
-        {
-            var list = new[]
-            {
-                new NestedList {Inner = new List<object>()},
-                new NestedList {Inner = new List<object>()}
-            };
-
-            var bytes = _marsh.Marshal(list);
-            var res = _marsh.Unmarshal<NestedList[]>(bytes);
-
-            Assert.AreEqual(2, res.Length);
-            Assert.AreEqual(0, res[0].Inner.Count);
-        }
-
         private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
         {
             if (cfg.TypeConfigurations == null)
@@ -2792,11 +2773,5 @@ namespace Apache.Ignite.Core.Tests.Binary
         {
             public IBinaryObject Val;
         }
-
-        private class NestedList
-        {
-            // ReSharper disable once CollectionNeverUpdated.Local
-            public IList<object> Inner { get; set; }
-        }
     }
 }
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/NestedListsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/NestedListsTest.cs
deleted file mode 100644
index ed060f7..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/NestedListsTest.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.
- */
-
-namespace Apache.Ignite.Core.Tests.Binary
-{
-    using System.Collections.Generic;
-    using NUnit.Framework;
-
-    /// <summary>
-    /// TODO
-    /// </summary>
-    public class NestedListsTest
-    {
-        /// <summary>
-        /// TODO
-        /// </summary>
-        [Test]
-        public void Test()
-        {
-            // TODO: Why does not this fail offline in BinarySelfTest?
-            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());
-            var cache = ignite.GetOrCreateCache<int, Entity[]>("c");
-
-            cache.Put(1, new[]
-            {
-                new Entity {Inner = new List<object>()},
-                new Entity {Inner = new List<object>()}
-            });
-
-            cache.Get(1);
-        }
-
-        private class Entity
-        {
-            public IList<object> Inner { get; set; }
-        }
-    }
-}


[ignite] 08/09: TODOs

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 846067782791d0f80271e8757d059201ceb8df61
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jan 28 13:08:28 2021 +0300

    TODOs
---
 .../processors/cache/distributed/dht/GridDhtTxPrepareFuture.java        | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 79d68c9..6be9eed 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -1757,6 +1757,8 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite
 
         for (IgniteTxEntry entry : entries) {
             try {
+                // TODO: Make it even better - pass lessPending to localCandidatesMax so it adds the items directly,
+                // without allocating another list.
                 Collection<GridCacheMvccCandidate> candidates = entry.cached().localCandidatesMax(baseVer);
                 for (GridCacheMvccCandidate cand : candidates) {
                     lessPending.add(cand.version());


[ignite] 03/09: add failing test

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit a7a2cbebe88e748cb0e55a154a43052e2136d3a9
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Wed Jan 27 18:35:00 2021 +0300

    add failing test
---
 .../Binary/NestedListsTest.cs                      | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/NestedListsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/NestedListsTest.cs
new file mode 100644
index 0000000..ed060f7
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/NestedListsTest.cs
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Binary
+{
+    using System.Collections.Generic;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// TODO
+    /// </summary>
+    public class NestedListsTest
+    {
+        /// <summary>
+        /// TODO
+        /// </summary>
+        [Test]
+        public void Test()
+        {
+            // TODO: Why does not this fail offline in BinarySelfTest?
+            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());
+            var cache = ignite.GetOrCreateCache<int, Entity[]>("c");
+
+            cache.Put(1, new[]
+            {
+                new Entity {Inner = new List<object>()},
+                new Entity {Inner = new List<object>()}
+            });
+
+            cache.Get(1);
+        }
+
+        private class Entity
+        {
+            public IList<object> Inner { get; set; }
+        }
+    }
+}


[ignite] 06/09: Add localCandidatesMax to reduce allocations

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 96b3d9a01aefa9f58e2d9b255a85f1caa53e2559
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jan 28 12:39:43 2021 +0300

    Add localCandidatesMax to reduce allocations
---
 .../ignite/internal/processors/cache/GridCacheMvcc.java      | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
index ca4a66e..99cea01 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
@@ -1448,12 +1448,20 @@ public final class GridCacheMvcc {
 
         assert !col.isEmpty();
 
-        List<GridCacheMvccCandidate> cands = new ArrayList<>(col.size());
+        List<GridCacheMvccCandidate> cands = null;
 
         for (GridCacheMvccCandidate c : col) {
             // Don't include reentries.
-            if ((reentries || !c.reentry()) && c.version().isLess(maxVers))
+            if ((reentries || !c.reentry()) && c.version().isLess(maxVers)) {
+                if (cands == null)
+                    cands = new ArrayList<>(col.size());
+
                 cands.add(c);
+            }
+        }
+
+        if (cands == null) {
+            cands = Collections.emptyList();
         }
 
         return cands;


[ignite] 05/09: Add localCandidatesMax to reduce allocations

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 9879c15722625bf60bf9aacc7a04ccbeae82025f
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jan 28 12:38:33 2021 +0300

    Add localCandidatesMax to reduce allocations
---
 .../processors/cache/GridCacheEntryEx.java         | 10 +++++++
 .../processors/cache/GridCacheMapEntry.java        | 17 +++++++++++
 .../internal/processors/cache/GridCacheMvcc.java   | 33 ++++++++++++++++++++++
 .../distributed/dht/GridDhtTxPrepareFuture.java    |  6 ++--
 .../java/org/apache/ignite/cache/PutAllTxTest.java | 11 ++++----
 5 files changed, 68 insertions(+), 9 deletions(-)

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 fb68256..cf765a5 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
@@ -987,6 +987,16 @@ public interface GridCacheEntryEx {
         throws GridCacheEntryRemovedException;
 
     /**
+     * Gets all local candidates.
+     *
+     * @param maxVer Exclusive upper version boundary.
+     * @return All local candidates.
+     * @throws GridCacheEntryRemovedException If entry was removed.
+     */
+    public Collection<GridCacheMvccCandidate> localCandidatesMax(GridCacheVersion maxVer)
+        throws GridCacheEntryRemovedException;
+
+    /**
      * Gets all remote versions.
      *
      * @param exclude Exclude version.
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 5f39b50..523d65f 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
@@ -3925,6 +3925,23 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /** {@inheritDoc} */
+    @Override public Collection<GridCacheMvccCandidate> localCandidatesMax(GridCacheVersion maxVer)
+            throws GridCacheEntryRemovedException {
+        lockEntry();
+
+        try {
+            checkObsolete();
+
+            GridCacheMvcc mvcc = mvccExtras();
+
+            return mvcc == null ? Collections.<GridCacheMvccCandidate>emptyList() : mvcc.localCandidatesMax(maxVer);
+        }
+        finally {
+            unlockEntry();
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public Collection<GridCacheMvccCandidate> remoteMvccSnapshot(GridCacheVersion... exclude) {
         return Collections.emptyList();
     }
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
index be28ae7..ca4a66e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
@@ -1381,6 +1381,14 @@ public final class GridCacheMvcc {
     }
 
     /**
+     * @param maxVers TODO.
+     * @return Collection of local candidates.
+     */
+    public Collection<GridCacheMvccCandidate> localCandidatesMax(GridCacheVersion maxVers) {
+        return candidates(locs, false, true, maxVers);
+    }
+
+    /**
      * @param reentries Flag to include reentries.
      * @param excludeVers Exclude versions.
      * @return Collection of local candidates.
@@ -1427,6 +1435,31 @@ public final class GridCacheMvcc {
     }
 
     /**
+     * @param col Collection of candidates.
+     * @param reentries Reentry flag.
+     * @param cp Whether to copy or not.
+     * @param maxVers TODO.
+     * @return Collection of candidates minus the exclude versions.
+     */
+    private List<GridCacheMvccCandidate> candidates(List<GridCacheMvccCandidate> col,
+        boolean reentries, boolean cp, GridCacheVersion maxVers) {
+        if (col == null)
+            return Collections.emptyList();
+
+        assert !col.isEmpty();
+
+        List<GridCacheMvccCandidate> cands = new ArrayList<>(col.size());
+
+        for (GridCacheMvccCandidate c : col) {
+            // Don't include reentries.
+            if ((reentries || !c.reentry()) && c.version().isLess(maxVers))
+                cands.add(c);
+        }
+
+        return cands;
+    }
+
+    /**
      * @param threadId Thread ID to check.
      * @param exclude Versions to ignore.
      * @return {@code True} if lock is owned by the thread with given ID.
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 5afa379..79d68c9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -1757,9 +1757,9 @@ public final class GridDhtTxPrepareFuture extends GridCacheCompoundFuture<Ignite
 
         for (IgniteTxEntry entry : entries) {
             try {
-                for (GridCacheMvccCandidate cand : entry.cached().localCandidates()) {
-                    if (cand.version().isLess(baseVer))
-                        lessPending.add(cand.version());
+                Collection<GridCacheMvccCandidate> candidates = entry.cached().localCandidatesMax(baseVer);
+                for (GridCacheMvccCandidate cand : candidates) {
+                    lessPending.add(cand.version());
                 }
             }
             catch (GridCacheEntryRemovedException ignored) {
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/PutAllTxTest.java b/modules/core/src/test/java/org/apache/ignite/cache/PutAllTxTest.java
index ccebf8c..da2be14 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/PutAllTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/PutAllTxTest.java
@@ -18,16 +18,15 @@ public class PutAllTxTest extends GridCommonAbstractTest {
         Ignition.start(getConfiguration("server2"));
         Ignite ignite = Ignition.start(getConfiguration("client").setClientMode(true));
 
-        IgniteCache<Integer, String> cache = ignite.createCache(
-                new CacheConfiguration<Integer, String>("c")
+        IgniteCache<Integer, Integer> cache = ignite.createCache(
+                new CacheConfiguration<Integer, Integer>("c")
                         .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
 
-        int count = 40000;
-        int valSize = 1000;
+        int count = 50000;
 
-        Map<Integer, String> data = new TreeMap<>();
+        Map<Integer, Integer> data = new TreeMap<>();
         for (int i = 0; i < count; i++)
-            data.put(i, new String(new char[valSize]) + UUID.randomUUID());
+            data.put(i, i);
 
         long begin = System.nanoTime();
 


[ignite] 02/09: add test

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit a0050d1189f4df1cef5343b19689424edbfc972b
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Wed Jan 27 18:29:32 2021 +0300

    add test
---
 .../platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs  | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index b167c46..bf75ae5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -1673,6 +1673,7 @@ namespace Apache.Ignite.Core.Tests.Binary
             var res = _marsh.Unmarshal<NestedList[]>(bytes);
 
             Assert.AreEqual(2, res.Length);
+            Assert.AreEqual(0, res[0].Inner.Count);
         }
 
         private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
@@ -2794,6 +2795,7 @@ namespace Apache.Ignite.Core.Tests.Binary
 
         private class NestedList
         {
+            // ReSharper disable once CollectionNeverUpdated.Local
             public IList<object> Inner { get; set; }
         }
     }


[ignite] 04/09: Add PutAllTxTest (remove later)

Posted by pt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ptupitsyn pushed a commit to branch ignite-14067
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 973fc801c4017e618ab978cd9a4233fd61cf4386
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Thu Jan 28 11:29:03 2021 +0300

    Add PutAllTxTest (remove later)
---
 .../java/org/apache/ignite/cache/PutAllTxTest.java | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/modules/core/src/test/java/org/apache/ignite/cache/PutAllTxTest.java b/modules/core/src/test/java/org/apache/ignite/cache/PutAllTxTest.java
new file mode 100644
index 0000000..ccebf8c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/PutAllTxTest.java
@@ -0,0 +1,39 @@
+package org.apache.ignite.cache;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.UUID;
+
+public class PutAllTxTest extends GridCommonAbstractTest {
+    @Test
+    public void testPutAll() throws Exception {
+        Ignition.start(getConfiguration("server1"));
+        Ignition.start(getConfiguration("server2"));
+        Ignite ignite = Ignition.start(getConfiguration("client").setClientMode(true));
+
+        IgniteCache<Integer, String> cache = ignite.createCache(
+                new CacheConfiguration<Integer, String>("c")
+                        .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
+
+        int count = 40000;
+        int valSize = 1000;
+
+        Map<Integer, String> data = new TreeMap<>();
+        for (int i = 0; i < count; i++)
+            data.put(i, new String(new char[valSize]) + UUID.randomUUID());
+
+        long begin = System.nanoTime();
+
+        cache.putAll(data);
+
+        long dur = System.nanoTime() - begin;
+        System.out.println(">>>>> " + dur / 1000000);
+    }
+}