timoninmaxim commented on code in PR #11317:
URL: https://github.com/apache/ignite/pull/11317#discussion_r1580903864


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java:
##########
@@ -607,7 +611,7 @@ private <R> CacheQueryFuture<R> execute0(@Nullable 
IgniteReducer<T, R> rmtReduce
                 }
             }
 
-            return new GridEmptyCloseableIterator();
+            throw new IgniteException(new ClusterGroupEmptyException());

Review Comment:
   Why do you change the behavior here?



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java:
##########
@@ -579,21 +580,24 @@ private <R> CacheQueryFuture<R> execute0(@Nullable 
IgniteReducer<T, R> rmtReduce
     }
 
     /** {@inheritDoc} */
-    @Override public GridCloseableIterator executeScanQuery() throws 
IgniteCheckedException {
-        assert type == SCAN : "Wrong processing of query: " + type;
+    @Override public GridCloseableIterator executeQueryWithIterator() throws 
IgniteCheckedException {
+        assert type == SCAN || type == INDEX : "Wrong processing of query: " + 
type;
 
         GridDhtCacheAdapter<?, ?> cacheAdapter = cctx.isNear() ? 
cctx.near().dht() : cctx.dht();
 
         Set<Integer> lostParts = cacheAdapter.topology().lostPartitions();
 
         if (!lostParts.isEmpty()) {
             if (part == null || lostParts.contains(part)) {
-                throw new CacheException(new 
CacheInvalidStateException("Failed to execute query because cache partition " +

Review Comment:
   Let's revert these changes



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryAdapter.java:
##########
@@ -625,7 +629,7 @@ private <R> CacheQueryFuture<R> execute0(@Nullable 
IgniteReducer<T, R> rmtReduce
         GridCloseableIterator it;
 
         if (loc)
-            it = qryMgr.scanQueryLocal(this, true);
+            it = qryMgr.queryLocal(this, true);

Review Comment:
   It looks strange for non-local query we call `scanQueryDistributed` while 
for local it calls generic method. Let's separate `scanQueryLocal` and 
`indexQueryLocal`.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java:
##########
@@ -818,8 +840,8 @@ private QueryCursor<Cache.Entry<K, V>> 
queryContinuous(AbstractContinuousQuery q
                 return 
(FieldsQueryCursor<R>)ctx.kernalContext().query().querySqlFields(ctx, 
(SqlFieldsQuery)qry,
                     null, keepBinary, true).get(0);
 
-            if (qry instanceof ScanQuery)
-                return query((ScanQuery)qry, null, projection(qry.isLocal()));
+            if (qry instanceof ScanQuery || (qry instanceof IndexQuery && 
qry.isLocal()))

Review Comment:
   Looks like `if` for `IndexQuery` can be moved inside the call on the 846L. 



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java:
##########
@@ -475,23 +475,45 @@ private <T, R> QueryCursor<R> query(
 
         boolean isKeepBinary = opCtxCall != null && opCtxCall.isKeepBinary();
 
-        IgniteBiPredicate<K, V> p = scanQry.getFilter();
+        GridCacheQueryType qryType = null;
+
+        CacheQuery cacheQry = null;
+
+        if (qry instanceof ScanQuery) {
+            ScanQuery scanQry = (ScanQuery)qry;
+
+            qryType = GridCacheQueryType.SCAN;
+
+            IgniteBiPredicate<K, V> p = scanQry.getFilter();
+
+            cacheQry = ctx.queries().createScanQuery(
+                p, transformer, scanQry.getPartition(), isKeepBinary, 
qry.isLocal(), null);
+        }
+        else {
+            IndexQuery idxQryLoc = (IndexQuery)qry;

Review Comment:
   This logic is already specified in `IgniteCacheProxyImpl#qyery(Query, 
ClusterGroup)`. Let's move handle of IndexQuery in the method.



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java:
##########
@@ -1411,17 +1411,19 @@ else if (rmvIter)
     }
 
     /**
-     * Process local scan query.
+     * Process local query with results returned in an iterator.
      *
      * @param qry Query.
      * @param updateStatistics Update statistics flag.
      */
     @SuppressWarnings({"unchecked"})
-    protected GridCloseableIterator scanQueryLocal(final GridCacheQueryAdapter 
qry,
+    protected GridCloseableIterator queryLocal(final GridCacheQueryAdapter qry,

Review Comment:
   Let's create 2 methods - `scanQueryLocal` and `indexQueryLocal`. They should 
reuse some common code.



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