You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "leaves12138 (via GitHub)" <gi...@apache.org> on 2025/12/05 06:26:07 UTC

[PR] [WIP] [core] Enable global index scan in core [paimon]

leaves12138 opened a new pull request, #6752:
URL: https://github.com/apache/paimon/pull/6752

   <!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Related pip: https://cwiki.apache.org/confluence/display/PAIMON/PIP-38%3A+Introduce+Global+Index+for+Paimon+Table?src=contextnavpagetreemode
   
   Enable global index auto-search in ReadBuilder.
   
   <!-- What is the purpose of the change -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on PR #6752:
URL: https://github.com/apache/paimon/pull/6752#issuecomment-4168966395

   closed


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2608918301


##########
paimon-common/src/main/java/org/apache/paimon/globalindex/GlobalIndexResult.java:
##########
@@ -55,16 +69,53 @@ static GlobalIndexResult createEmpty() {
 
     /** Returns a new {@link GlobalIndexResult} from supplier. */
     static GlobalIndexResult create(Supplier<RoaringNavigableMap64> supplier) {
+        return create(supplier, null);
+    }
+
+    /** Returns a new {@link GlobalIndexResult} from supplier. */
+    static GlobalIndexResult create(
+            Supplier<RoaringNavigableMap64> supplier, @Nullable ScoreFunction scoreFunction) {
         LazyField<RoaringNavigableMap64> lazyField = new LazyField<>(supplier);
-        return lazyField::get;
+        return new GlobalIndexResult() {
+            @Override
+            public RoaringNavigableMap64 results() {
+                return lazyField.get();
+            }
+
+            @Nullable
+            @Override
+            public ScoreFunction scoreFunction() {
+                return scoreFunction;
+            }
+        };
     }
 
     /** Returns a new {@link GlobalIndexResult} from {@link Range}. */
     static GlobalIndexResult fromRange(Range range) {
         return create(
                 () -> {
                     RoaringNavigableMap64 result64 = new RoaringNavigableMap64();
-                    result64.addRange(range);
+                    if (range.from == range.to) {
+                        result64.add(range.from);
+                    } else {
+                        result64.addRange(range);
+                    }

Review Comment:
   Good idea



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi closed pull request #6752: [core] Enable global index scan in core
URL: https://github.com/apache/paimon/pull/6752


-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2605511488


##########
paimon-core/src/main/java/org/apache/paimon/table/source/ReadBuilderImpl.java:
##########
@@ -231,6 +239,12 @@ private InnerTableScan configureScan(InnerTableScan scan) {
         return scan;
     }
 
+    private boolean searchGlobalIndex(Table table) {

Review Comment:
   If there is no filter, we don't need to search global index.



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2605511488


##########
paimon-core/src/main/java/org/apache/paimon/table/source/ReadBuilderImpl.java:
##########
@@ -231,6 +239,12 @@ private InnerTableScan configureScan(InnerTableScan scan) {
         return scan;
     }
 
+    private boolean searchGlobalIndex(Table table) {

Review Comment:
   If there is no filter, we don't need to search global index.



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2605504910


##########
paimon-core/src/main/java/org/apache/paimon/table/source/ReadBuilderImpl.java:
##########
@@ -183,7 +186,11 @@ public ReadBuilder dropStats() {
 
     @Override
     public TableScan newScan() {
-        InnerTableScan tableScan = configureScan(table.newScan());
+        InnerTableScan scan = table.newScan();

Review Comment:
   tableScan



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "jerry-024 (via GitHub)" <gi...@apache.org>.
jerry-024 commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2605489752


##########
paimon-common/src/main/java/org/apache/paimon/globalindex/GlobalIndexResult.java:
##########
@@ -55,16 +69,53 @@ static GlobalIndexResult createEmpty() {
 
     /** Returns a new {@link GlobalIndexResult} from supplier. */
     static GlobalIndexResult create(Supplier<RoaringNavigableMap64> supplier) {
+        return create(supplier, null);
+    }
+
+    /** Returns a new {@link GlobalIndexResult} from supplier. */
+    static GlobalIndexResult create(
+            Supplier<RoaringNavigableMap64> supplier, @Nullable ScoreFunction scoreFunction) {
         LazyField<RoaringNavigableMap64> lazyField = new LazyField<>(supplier);
-        return lazyField::get;
+        return new GlobalIndexResult() {
+            @Override
+            public RoaringNavigableMap64 results() {
+                return lazyField.get();
+            }
+
+            @Nullable
+            @Override
+            public ScoreFunction scoreFunction() {
+                return scoreFunction;
+            }
+        };
     }
 
     /** Returns a new {@link GlobalIndexResult} from {@link Range}. */
     static GlobalIndexResult fromRange(Range range) {
         return create(
                 () -> {
                     RoaringNavigableMap64 result64 = new RoaringNavigableMap64();
-                    result64.addRange(range);
+                    if (range.from == range.to) {
+                        result64.add(range.from);
+                    } else {
+                        result64.addRange(range);
+                    }

Review Comment:
   move this logic to addRange?



##########
paimon-core/src/main/java/org/apache/paimon/globalindex/IndexedSplitReadUtil.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.paimon.globalindex;
+
+import org.apache.paimon.table.SpecialFields;
+import org.apache.paimon.types.RowType;
+import org.apache.paimon.utils.ProjectedRow;
+import org.apache.paimon.utils.Range;
+
+import javax.annotation.Nullable;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/** Utils to read IndexSplit. */
+public class IndexedSplitReadUtil {
+
+    public static Info readInfo(RowType readRowType, IndexedSplit indexedSplit) {
+        Map<Long, Float> rowIdToScore = null;
+        if (indexedSplit.scores() != null) {
+            rowIdToScore = new HashMap<>();

Review Comment:
   rowIdToScore = new HashMap<>(indexedSplit.scores().size) ?



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2605508938


##########
paimon-core/src/main/java/org/apache/paimon/table/source/ReadBuilderImpl.java:
##########
@@ -243,9 +257,6 @@ public TableRead newRead() {
         if (limit != null) {
             read.withLimit(limit);
         }
-        if (rowRanges != null) {
-            read.withRowRanges(rowRanges);

Review Comment:
   Why remove this?



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "leaves12138 (via GitHub)" <gi...@apache.org>.
leaves12138 commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2597054995


##########
paimon-api/src/main/java/org/apache/paimon/CoreOptions.java:
##########
@@ -2091,6 +2091,13 @@ public InlineElement getDescription() {
                     .defaultValue(100000L)
                     .withDescription("Row count per shard for global index.");
 
+    public static final ConfigOption<Boolean> GLOBAL_INDEX_ENABLED_IN_CORE =
+            key("global-index.enabled-in-core")

Review Comment:
   OK



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [core] Enable global index scan in core [paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #6752:
URL: https://github.com/apache/paimon/pull/6752#discussion_r2605505393


##########
paimon-core/src/main/java/org/apache/paimon/table/source/ReadBuilderImpl.java:
##########
@@ -206,6 +213,7 @@ private InnerTableScan configureScan(InnerTableScan scan) {
                 .withReadType(readType)
                 .withPartitionFilter(partitionFilter)
                 .withRowRanges(rowRanges);
+

Review Comment:
   remove this



-- 
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: issues-unsubscribe@paimon.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org