alex-plekhanov commented on code in PR #11645:
URL: https://github.com/apache/ignite/pull/11645#discussion_r1832196985


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/ScanQueryIterator.java:
##########
@@ -0,0 +1,460 @@
+/*
+ * 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.processors.cache.query;
+
+import java.util.NoSuchElementException;
+import java.util.UUID;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.events.CacheQueryReadEvent;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheMetricsImpl;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.CacheObjectUtils;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import 
org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
+import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import 
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
+import 
org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
+import 
org.apache.ignite.internal.processors.platform.cache.PlatformCacheEntryFilter;
+import org.apache.ignite.internal.processors.security.SecurityUtils;
+import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
+import org.apache.ignite.internal.util.GridConcurrentHashSet;
+import org.apache.ignite.internal.util.lang.GridIterator;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.lang.IgniteClosure;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.events.EventType.EVT_CACHE_QUERY_OBJECT_READ;
+import static 
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager.injectResources;
+import static 
org.apache.ignite.internal.processors.security.SecurityUtils.securitySubjectId;
+
+/** */
+public final class ScanQueryIterator<K, V, R> extends 
GridCloseableIteratorAdapter<R> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** */
+    private final GridDhtCacheAdapter<K, V> dht;
+
+    /** */
+    private final GridDhtLocalPartition locPart;
+
+    /** */
+    private final IgniteBiPredicate<K, V> filter;
+
+    /** */
+    private final Runnable closeFilterClo;
+
+    /** */
+    private final boolean statsEnabled;
+
+    /** */
+    private final GridIterator<CacheDataRow> it;
+
+    /** */
+    private final GridCacheAdapter<K, V> cache;
+
+    /** */
+    private final AffinityTopologyVersion topVer;
+
+    /** */
+    private final boolean keepBinary;
+
+    /** */
+    private final boolean readEvt;
+
+    /** */
+    private final String cacheName;
+
+    /** */
+    private final UUID subjId;
+
+    /** */
+    private final String taskName;
+
+    /** */
+    private final IgniteClosure<Cache.Entry<K, V>, R> transform;
+
+    /** */
+    private final CacheObjectContext objCtx;
+
+    /** */
+    private final GridCacheContext<K, V> cctx;
+
+    /** */
+    private final IgniteLogger log;
+
+    /** */
+    private R next;
+
+    /** */
+    private boolean needAdvance;
+
+    /** */
+    private IgniteCacheExpiryPolicy expiryPlc;
+
+    /** */
+    private final boolean locNode;
+
+    /** */
+    private final boolean incBackups;
+
+    /** */
+    private final long startTime;
+
+    /** */
+    private final int pageSize;
+
+    /** */
+    @Nullable private final GridConcurrentHashSet<ScanQueryIterator<K, V, R>> 
locIters;
+
+    /**
+     * @param it Iterator.
+     * @param qry Query.
+     * @param topVer Topology version.
+     * @param locPart Local partition.
+     * @param transformer Transformer.
+     * @param locNode Local node flag.
+     * @param locIters Local iterators set.
+     * @param cctx Cache context.
+     * @param log Logger.
+     */
+    ScanQueryIterator(
+        GridIterator<CacheDataRow> it,
+        CacheQuery<R> qry,
+        AffinityTopologyVersion topVer,
+        GridDhtLocalPartition locPart,
+        IgniteClosure<Cache.Entry<K, V>, R> transformer,
+        boolean locNode,
+        @Nullable GridConcurrentHashSet<ScanQueryIterator<K, V, R>> locIters,
+        GridCacheContext<K, V> cctx,
+        IgniteLogger log) throws IgniteCheckedException {
+        assert !locNode || locIters != null : "Local iterators can't be null 
for local query.";
+
+        this.it = it;
+        this.topVer = topVer;
+        this.locPart = locPart;
+        this.cctx = cctx;
+
+        this.log = log;
+        this.locNode = locNode;
+        this.locIters = locIters;
+
+        incBackups = qry.includeBackups();
+
+        statsEnabled = cctx.statisticsEnabled();
+
+        readEvt = cctx.events().isRecordable(EVT_CACHE_QUERY_OBJECT_READ) &&
+            cctx.gridEvents().hasListener(EVT_CACHE_QUERY_OBJECT_READ);
+
+        taskName = readEvt ? 
cctx.kernalContext().task().resolveTaskName(qry.taskHash()) : null;
+
+        subjId = securitySubjectId(cctx);
+
+        dht = cctx.isNear() ? cctx.near().dht() : cctx.dht();
+        cache = dht != null ? dht : cctx.cache();
+        objCtx = cctx.cacheObjectContext();
+        cacheName = cctx.name();
+
+        needAdvance = true;
+        expiryPlc = this.cctx.cache().expiryPolicy(null);
+
+        startTime = U.currentTimeMillis();
+        pageSize = qry.pageSize();
+        transform = SecurityUtils.sandboxedProxy(cctx.kernalContext(), 
IgniteClosure.class, injectResources(transformer, cctx));
+        closeFilterClo = qry.scanFilter() instanceof PlatformCacheEntryFilter
+            ? ((PlatformCacheEntryFilter)qry.scanFilter())::onClose
+            : null;

Review Comment:
   `closeFilterClo = () -> closeFilter(qry.scanFilter());` ?



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java:
##########
@@ -1433,9 +1392,6 @@ protected GridCloseableIterator scanQueryLocal(final 
CacheQuery qry,
             return it;
         }
         catch (Exception e) {
-            if (intFilter != null)

Review Comment:
   Here we should keep closeFilter too



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