tkalkirill commented on code in PR #800:
URL: https://github.com/apache/ignite-3/pull/800#discussion_r870122209


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/checkpoint/GridConcurrentMultiPairQueue.java:
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.pagememory.persistence.checkpoint;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.internal.tostring.S;
+import org.apache.ignite.lang.IgniteBiTuple;
+
+/**
+ * Concurrent queue that wraps collection of {@code Pair<K, V[]>}.
+ *
+ * <p>The only guarantee {@link #next} provided is sequentially emptify values 
per key array. i.e. input like:
+ *
+ * <br> p1 = new Pair<1, [1, 3, 5, 7]>
+ * <br> p2 = new Pair<2, [2, 3]>
+ * <br> p3 = new Pair<3, [200, 100]>
+ * <br> and further sequence of {@code poll} or {@code forEach} calls may 
produce output like:
+ * <br> [3, 200], [3, 100], [1, 1], [1, 3], [1, 5], [1, 7], [2, 2], [2, 3]
+ *
+ * @param <K> The type of key in input pair collection.
+ * @param <V> The type of value array.
+ */
+public class GridConcurrentMultiPairQueue<K, V> {
+    /** Empty pair queue. */
+    public static final GridConcurrentMultiPairQueue EMPTY = new 
GridConcurrentMultiPairQueue<>(Map.of());
+
+    /** Inner holder. */
+    private final V[][] vals;
+
+    /** Storage for every array length. */
+    private final int[] lenSeq;
+
+    /** Current absolute position. */
+    private final AtomicInteger pos = new AtomicInteger();
+
+    /** Precalculated max position. */
+    private final int maxPos;
+
+    /** Keys array. */
+    private final K[] keysArr;
+
+    /**
+     * Constructor.
+     *
+     * @param items Items.
+     */
+    public GridConcurrentMultiPairQueue(Map<K, ? extends Collection<V>> items) 
{
+        int pairCnt = (int) 
items.entrySet().stream().map(Map.Entry::getValue).filter(k -> k.size() > 
0).count();

Review Comment:
   Correct it.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to