nizhikov commented on code in PR #11438:
URL: https://github.com/apache/ignite/pull/11438#discussion_r1758545786


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/IndexScan.java:
##########
@@ -507,4 +596,64 @@ protected TreeIndexWrapper(InlineIndex idx) {
             }
         }
     }
+
+    /**
+     * @param entries Entries changed in transaction.
+     * @param cacheId Cache id.
+     * @param parts Partitions set.
+     * @param mapper Mapper to specific data type.
+     * @return First, set of object changed in transaction, second, list of 
transaction data in required format.
+     * @param <R> Required type.
+     */
+    public static <R> IgniteBiTuple<Set<KeyCacheObject>, List<R>> 
transactionData(
+        Collection<IgniteTxEntry> entries,
+        int cacheId,
+        int[] parts,
+        Function<CacheDataRow, R> mapper
+    ) {
+        if (F.isEmpty(entries))
+            return F.t(Collections.emptySet(), Collections.emptyList());
+
+        // Expecting parts are sorted or almost sorted and amount of 
transaction entries are relatively small.
+        if (parts != null)
+            Arrays.sort(parts);
+
+        Set<KeyCacheObject> changedKeys = new HashSet<>(entries.size());
+        List<R> newAndUpdatedRows = new ArrayList<>(entries.size());
+
+        for (IgniteTxEntry e : entries) {
+            int part = e.key().partition();
+
+            assert part != -1;
+
+            if (e.cacheId() != cacheId)
+                continue;
+
+            if (parts != null && Arrays.binarySearch(parts, part) < 0)

Review Comment:
   Parts are always sorted, already in my tests.
   I doubt if there are cases where `parts` not sorted here.
   Added explicit check `F.isSorted` to omit `Arrays.sort` when possible.



-- 
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: notifications-unsubscr...@ignite.apache.org

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

Reply via email to