Copilot commented on code in PR #19230:
URL: https://github.com/apache/pinot/pull/19230#discussion_r3770454797
##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/store/TextIndexUtilsTest.java:
##########
@@ -49,4 +51,16 @@ public void testRoundTripProperties()
JsonUtils.stringToObject("{}", TextIndexConfig.class));
assertEquals(readConfig, config);
}
+
+ /// A directory that cannot be listed, including one that does not exist or
is not there at all, holds no index.
+ @Test
+ public void testUnlistableDirectoryHasNoColumnsWithIndex() {
+ List<String> columns = List.of("colA", "colB");
+ File missingDir = new File(TEMP_DIR, "doesNotExist");
+
+ assertEquals(TextIndexUtils.getColumnsWithTextIndex(missingDir, columns),
Set.of());
+
assertEquals(TextIndexUtils.getColumnsWithLegacyNativeTextIndex(missingDir,
columns), Set.of());
+ assertEquals(TextIndexUtils.getColumnsWithTextIndex(null, columns),
Set.of());
+ assertEquals(TextIndexUtils.getColumnsWithLegacyNativeTextIndex(null,
columns), Set.of());
Review Comment:
These assertions make null-directory handling part of the public utility
contract, but both public methods still declare `File segDir` as non-null; only
their private helper is annotated. Add `@Nullable` to the public `segDir`
parameters so callers and nullness tooling see the behavior being tested.
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/VectorIndexUtils.java:
##########
@@ -129,9 +129,9 @@ public static Set<String> getColumnsWithVectorIndex(File
segDir, Collection<Stri
}
/// Names of the entries directly inside `dir`, files and directories alike
(an HNSW vector index is
- /// a Lucene directory), or empty when it cannot be listed.
- private static Set<String> listEntryNames(File dir) {
- String[] names = dir.list();
+ /// a Lucene directory), or empty when `dir` is null or cannot be listed.
+ private static Set<String> listEntryNames(@Nullable File dir) {
+ String[] names = dir == null ? null : dir.list();
Review Comment:
The new null-directory branch is not covered by `VectorIndexUtilsTest`,
despite that class already testing this utility extensively. Add a focused
assertion that `getColumnsWithVectorIndex(null, columns)` returns an empty set
(and ideally cover an unlistable directory too), matching the text-index
regression coverage.
##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/invertedindex/TextIndexHandlerTest.java:
##########
@@ -0,0 +1,77 @@
+/**
+ * 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.pinot.segment.local.segment.index.loader.invertedindex;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import org.apache.pinot.segment.spi.creator.SegmentVersion;
+import org.apache.pinot.segment.spi.index.StandardIndexes;
+import org.apache.pinot.segment.spi.index.metadata.SegmentMetadataImpl;
+import org.apache.pinot.segment.spi.store.SegmentDirectory;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.FieldSpec.DataType;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertFalse;
+
+
+public class TextIndexHandlerTest {
Review Comment:
This new public test class is missing the class-level Javadoc required for
new classes in this repository. Add a brief class comment describing that it
covers `TextIndexHandler` behavior for segments without a local index directory.
This issue also appears on line 60 of the same file.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]