leaves12138 commented on code in PR #6807:
URL: https://github.com/apache/paimon/pull/6807#discussion_r2618465155


##########
paimon-lucene/src/test/java/org/apache/paimon/lucene/index/LuceneVectorGlobalIndexScanTest.java:
##########
@@ -0,0 +1,224 @@
+/*
+ * 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.lucene.index;
+
+import org.apache.paimon.CoreOptions;
+import org.apache.paimon.data.BinaryRow;
+import org.apache.paimon.fs.FileIO;
+import org.apache.paimon.fs.Path;
+import org.apache.paimon.fs.local.LocalFileIO;
+import org.apache.paimon.globalindex.GlobalIndexScanBuilder;
+import org.apache.paimon.globalindex.GlobalIndexWriter;
+import org.apache.paimon.globalindex.RowRangeGlobalIndexScanner;
+import org.apache.paimon.globalindex.TopkGlobalIndexResult;
+import org.apache.paimon.globalindex.io.GlobalIndexFileWriter;
+import org.apache.paimon.index.GlobalIndexMeta;
+import org.apache.paimon.index.IndexFileMeta;
+import org.apache.paimon.io.CompactIncrement;
+import org.apache.paimon.io.DataIncrement;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.predicate.FieldRef;
+import org.apache.paimon.predicate.LeafPredicate;
+import org.apache.paimon.predicate.Predicate;
+import org.apache.paimon.predicate.TopK;
+import org.apache.paimon.predicate.TopKFunction;
+import org.apache.paimon.predicate.TopKRowIdFilter;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.schema.SchemaManager;
+import org.apache.paimon.schema.TableSchema;
+import org.apache.paimon.table.FileStoreTable;
+import org.apache.paimon.table.FileStoreTableFactory;
+import org.apache.paimon.table.sink.CommitMessage;
+import org.apache.paimon.table.sink.CommitMessageImpl;
+import org.apache.paimon.table.sink.StreamTableCommit;
+import org.apache.paimon.types.ArrayType;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.types.RowType;
+import org.apache.paimon.utils.RoaringNavigableMap64;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for scanning Lucene vector global index. */
+public class LuceneVectorGlobalIndexScanTest {
+
+    @TempDir java.nio.file.Path tempDir;
+
+    private FileStoreTable table;
+    private String commitUser;
+    private Path tablePath;
+    private FileIO fileIO;
+    private RowType rowType;
+
+    @BeforeEach
+    public void before() throws Exception {
+        tablePath = new Path(tempDir.toString());
+        fileIO = new LocalFileIO();
+        SchemaManager schemaManager = new SchemaManager(fileIO, tablePath);
+
+        // 1. Define Schema, including vector field (FLOAT ARRAY)
+        Schema schema =
+                Schema.newBuilder()
+                        .column("id", DataTypes.INT())
+                        .column("vec", new ArrayType(DataTypes.FLOAT()))
+                        .primaryKey("id")
+                        .option(CoreOptions.BUCKET.key(), "1")
+                        .option("vector.dim", "2")
+                        .option("vector.metric", "EUCLIDEAN")
+                        .build();
+
+        TableSchema tableSchema = schemaManager.createTable(schema);
+        table = FileStoreTableFactory.create(fileIO, tablePath, tableSchema);
+        rowType = table.rowType();
+        commitUser = UUID.randomUUID().toString();
+    }
+
+    @Test
+    public void testVectorIndexScanEndToEnd() throws Exception {
+        float[][] vectors =
+                new float[][] {
+                    new float[] {1.0f, 0.0f}, new float[] {0.95f, 0.1f}, new 
float[] {0.1f, 0.95f},
+                    new float[] {0.98f, 0.05f}, new float[] {0.0f, 1.0f}, new 
float[] {0.05f, 0.98f}
+                };
+
+        // 3. Manually build vector index
+        List<IndexFileMeta> indexFiles = buildIndexManually(vectors);
+
+        // 4. Commit index files to the Table (Update Index Manifest)
+        commitIndex(indexFiles);
+
+        // 5. Use GlobalIndexScanBuilder to get scanner
+        GlobalIndexScanBuilder scanBuilder = 
table.store().newGlobalIndexScanBuilder();
+        List<org.apache.paimon.utils.Range> ranges = scanBuilder.shardList();

Review Comment:
   just Range



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