Copilot commented on code in PR #18090:
URL: https://github.com/apache/pinot/pull/18090#discussion_r3038717000


##########
pinot-segment-spi/src/test/java/org/apache/pinot/segment/spi/index/creator/VectorIndexConfigValidatorTest.java:
##########
@@ -467,4 +608,89 @@ public void testJsonConfigWithExplicitIvfFlat()
     assertEquals(config.resolveBackendType(), VectorBackendType.IVF_FLAT);
     VectorIndexConfigValidator.validate(config);
   }
+
+  @Test
+  public void testJsonConfigWithExplicitIvfPq()
+      throws Exception {
+    String confStr = "{"
+        + "\"disabled\": false,"
+        + "\"vectorIndexType\": \"IVF_PQ\","
+        + "\"vectorDimension\": 768,"
+        + "\"version\": 1,"
+        + "\"vectorDistanceFunction\": \"COSINE\","
+        + "\"properties\": {"
+        + "  \"nlist\": \"128\","
+        + "  \"pqM\": \"32\","
+        + "  \"pqNbits\": \"8\","
+        + "  \"trainSampleSize\": \"10000\""
+        + "}"
+        + "}";
+    VectorIndexConfig config =
+        org.apache.pinot.spi.utils.JsonUtils.stringToObject(confStr, 
VectorIndexConfig.class);
+
+    assertEquals(config.resolveBackendType(), VectorBackendType.IVF_PQ);
+    VectorIndexConfigValidator.validate(config);
+  }
+
+  // ============================================================
+  // Recommended defaults helper tests (Item 4)
+  // ============================================================
+
+  @Test
+  public void testRecommendedIvfPqDefaultsForDim128() {
+    Map<String, String> defaults = 
VectorIndexConfigValidator.recommendedIvfPqDefaults(128, "EUCLIDEAN");
+    assertEquals(defaults.get("vectorIndexType"), "IVF_PQ");
+    assertEquals(defaults.get("vectorDimension"), "128");
+    assertEquals(defaults.get("vectorDistanceFunction"), "EUCLIDEAN");
+    assertEquals(defaults.get("nlist"), "128");
+    assertEquals(defaults.get("pqNbits"), "8");
+
+    int pqM = Integer.parseInt(defaults.get("pqM"));
+    assertNotNull(defaults.get("pqM"));
+    assert pqM > 0 : "pqM must be positive";
+    assert 128 % pqM == 0 : "pqM must evenly divide dimension";
+
+    int trainSampleSize = Integer.parseInt(defaults.get("trainSampleSize"));
+    int nlist = Integer.parseInt(defaults.get("nlist"));
+    assert trainSampleSize >= nlist : "trainSampleSize must be >= nlist";
+

Review Comment:
   These checks use Java `assert` statements, which are skipped unless the JVM 
is started with `-ea`, so the test can silently pass even if the conditions are 
false. Please replace these with TestNG assertions (e.g., 
`Assert.assertTrue(...)` / `assertNotNull(...)`) so they always execute in CI.



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

Reply via email to