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


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/warmup/LoadAllWarmUpStrategy.java:
##########
@@ -99,12 +105,32 @@ public LoadAllWarmUpStrategy(IgniteLogger log, 
Supplier<Collection<CacheGroupCon
                 
loadDataInfo.keySet().stream().map(CacheGroupContext::cacheOrGroupName).collect(toList())
 + ']');
         }
 
-        long loadedPageCnt = 0;
+        AtomicLong loadedPageCnt = new AtomicLong();
 
         for (Map.Entry<CacheGroupContext, List<LoadPartition>> e : 
loadDataInfo.entrySet()) {
             CacheGroupContext grp = e.getKey();
             List<LoadPartition> parts = e.getValue();
 
+            LoadPartition idxPart = parts.get(0);
+
+            int avgPartPagesCnt = parts.stream()
+                .filter(p -> p.part() != INDEX_PARTITION)
+                .map(LoadPartition::pages)
+                .collect(averagingInt(i -> i)).intValue();
+
+            if (avgPartPagesCnt != 0 && idxPart.pages() > avgPartPagesCnt) {
+                List<LoadPartition> idxParts = new ArrayList<>(idxPart.pages() 
/ avgPartPagesCnt + 1);
+
+                for (int i = 0; i < idxPart.pages(); i += avgPartPagesCnt)
+                    idxParts.add(new LoadPartition(idxPart.part(), 
Math.min(idxPart.pages() - i, avgPartPagesCnt), i));
+
+                parts.remove(0);
+
+                idxParts.addAll(parts);

Review Comment:
   `newParts.addAll(parts.subList(1, parts.size()));`?
   



##########
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/warmup/LoadAllWarmUpStrategyWithIndexingTest.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.warmup;
+
+/**
+ * Test for {@link LoadAllWarmUpStrategy} with indexing.
+ *
+ * In particular it tests case when size of index partition is greater than 
average size of data
+ * partition which is a usual case if indexing is enabled.
+ */
+public class LoadAllWarmUpStrategyWithIndexingTest extends 
LoadAllWarmUpStrategySelfTest {

Review Comment:
   Maybe just add LoadAllWarmUpStrategySelfTest to indexing suite?



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/warmup/LoadAllWarmUpStrategy.java:
##########
@@ -99,12 +105,32 @@ public LoadAllWarmUpStrategy(IgniteLogger log, 
Supplier<Collection<CacheGroupCon
                 
loadDataInfo.keySet().stream().map(CacheGroupContext::cacheOrGroupName).collect(toList())
 + ']');
         }
 
-        long loadedPageCnt = 0;
+        AtomicLong loadedPageCnt = new AtomicLong();
 
         for (Map.Entry<CacheGroupContext, List<LoadPartition>> e : 
loadDataInfo.entrySet()) {
             CacheGroupContext grp = e.getKey();
             List<LoadPartition> parts = e.getValue();
 
+            LoadPartition idxPart = parts.get(0);
+
+            int avgPartPagesCnt = parts.stream()
+                .filter(p -> p.part() != INDEX_PARTITION)
+                .map(LoadPartition::pages)
+                .collect(averagingInt(i -> i)).intValue();
+
+            if (avgPartPagesCnt != 0 && idxPart.pages() > avgPartPagesCnt) {
+                List<LoadPartition> idxParts = new ArrayList<>(idxPart.pages() 
/ avgPartPagesCnt + 1);

Review Comment:
   `idxParts` -> `newParts`?
   `idxPart.pages() / avgPartPagesCnt + 1` -> `idxPart.pages() / 
avgPartPagesCnt + parts.size()`



##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/warmup/LoadAllWarmUpStrategy.java:
##########
@@ -99,12 +105,32 @@ public LoadAllWarmUpStrategy(IgniteLogger log, 
Supplier<Collection<CacheGroupCon
                 
loadDataInfo.keySet().stream().map(CacheGroupContext::cacheOrGroupName).collect(toList())
 + ']');
         }
 
-        long loadedPageCnt = 0;
+        AtomicLong loadedPageCnt = new AtomicLong();
 
         for (Map.Entry<CacheGroupContext, List<LoadPartition>> e : 
loadDataInfo.entrySet()) {
             CacheGroupContext grp = e.getKey();
             List<LoadPartition> parts = e.getValue();
 
+            LoadPartition idxPart = parts.get(0);
+
+            int avgPartPagesCnt = parts.stream()
+                .filter(p -> p.part() != INDEX_PARTITION)
+                .map(LoadPartition::pages)
+                .collect(averagingInt(i -> i)).intValue();
+
+            if (avgPartPagesCnt != 0 && idxPart.pages() > avgPartPagesCnt) {

Review Comment:
   Let's add comment that we split here index partition into chunks to balance 
threads load.



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