Berkof commented on a change in pull request #9392:
URL: https://github.com/apache/ignite/pull/9392#discussion_r745523382



##########
File path: 
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/stat/StatisticsUtils.java
##########
@@ -172,4 +174,61 @@ public static StatisticsTarget 
statisticsTarget(StatisticsKeyMessage msg) {
         String[] cols = (msg.colNames() == null) ? null : 
msg.colNames().toArray(new String[0]);
         return new StatisticsTarget(msg.schema(), msg.obj(), cols);
     }
+
+    /**
+     * Test if specified statistics is fit to all required versions.
+     * It means that specified statistics contains all columns with at least 
versions
+     * from specified map.
+     *
+     * @param stat Statistics to check. Can be {@code null}.
+     * @param versions Map of column name to required version.
+     * @return {@code true} if it is, {@code false} otherwise.
+     */
+    public static int compareVersions(
+        ObjectStatisticsImpl stat,
+        Map<String, Long> versions
+    ) {
+        if (stat == null)
+            return -1;
+
+        for (Map.Entry<String, Long> version : versions.entrySet()) {
+            ColumnStatistics colStat = 
stat.columnsStatistics().get(version.getKey());
+
+            if (colStat == null || colStat.version() < version.getValue())

Review comment:
       It cannot compare statistics from two different branches (col1v=1, 
col2v=2) and (col1v=2, col2v=1). I mean - if one cannot be calculated from 
other just by adding versions for some column. And such situation is impossible 
because of global meta storage and tombstones. But for statistics from the same 
"branch" it is enough to find first non equal version to get the result.




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