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


##########
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/schema/CacheIndexImpl.java:
##########
@@ -153,60 +164,133 @@ public Index queryIndex() {
 
     /** {@inheritDoc} */
     @Override public long count(ExecutionContext<?> ectx, ColocationGroup grp, 
boolean notNull) {
+        if (idx == null || !grp.nodeIds().contains(ectx.localNodeId()))
+            return 0L;
+
+        int[] locParts = grp.partitions(ectx.localNodeId());
+
+        IndexingQueryFilter filter = new 
IndexingQueryFilterImpl(tbl.descriptor().cacheContext().kernalContext(),
+            ectx.topologyVersion(), locParts);
+
+        InlineIndex iidx = idx.unwrap(InlineIndex.class);
+
+        TreeRowClosure<IndexRow, IndexRow> rowFilter = countRowFilter(notNull, 
iidx);
+
         long cnt = 0;
 
-        if (idx != null && grp.nodeIds().contains(ectx.localNodeId())) {
-            IndexingQueryFilter filter = new 
IndexingQueryFilterImpl(tbl.descriptor().cacheContext().kernalContext(),
-                ectx.topologyVersion(), grp.partitions(ectx.localNodeId()));
+        if (!F.isEmpty(ectx.getTxWriteEntries())) {
+            IgniteBiTuple<Set<KeyCacheObject>, List<CacheDataRow>> txChanges = 
transactionData(
+                ectx.getTxWriteEntries(),
+                iidx.indexDefinition().cacheInfo().cacheId(),
+                locParts,
+                Function.identity()
+            );
 
-            InlineIndex iidx = idx.unwrap(InlineIndex.class);
+            if (!txChanges.get1().isEmpty()) {
+                // This call will change `txChanges.get1()` content.
+                // Removing found key from set more efficient so we break some 
rules here.
+                rowFilter = transactionAwareCountRowFilter(rowFilter, 
txChanges.get1());
 
-            BPlusTree.TreeRowClosure<IndexRow, IndexRow> rowFilter = null;
+                cnt = countTransactionRows(iidx, txChanges.get2());
+            }
+        }
 
-            boolean checkExpired = 
!tbl.descriptor().cacheContext().config().isEagerTtl();
+        try {
+            for (int i = 0; i < iidx.segmentsCount(); ++i)
+                cnt += iidx.count(i, new IndexQueryContext(filter, rowFilter));

Review Comment:
   Will be fixed in another ticket



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