This is an automated email from the ASF dual-hosted git repository.
Jackie-Jiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new a6457514843 Fix JsonIndexConfig equals/hashCode missing _indexPaths
and _maxBytesSize (#18959)
a6457514843 is described below
commit a6457514843c4968f72c929a54735d5320a12ca4
Author: Akanksha kedia <[email protected]>
AuthorDate: Fri Jul 10 21:44:13 2026 +0530
Fix JsonIndexConfig equals/hashCode missing _indexPaths and _maxBytesSize
(#18959)
---
.../pinot/spi/config/table/JsonIndexConfig.java | 7 +--
.../spi/config/table/JsonIndexConfigTest.java | 59 ++++++++++++++++++++++
2 files changed, 63 insertions(+), 3 deletions(-)
diff --git
a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/JsonIndexConfig.java
b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/JsonIndexConfig.java
index 1753bc46d1f..6fa05bf9cc9 100644
---
a/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/JsonIndexConfig.java
+++
b/pinot-spi/src/main/java/org/apache/pinot/spi/config/table/JsonIndexConfig.java
@@ -212,13 +212,14 @@ public class JsonIndexConfig extends IndexConfig {
return _maxLevels == config._maxLevels && _excludeArray ==
config._excludeArray
&& _disableCrossArrayUnnest == config._disableCrossArrayUnnest &&
Objects.equals(_includePaths,
config._includePaths) && Objects.equals(_excludePaths,
config._excludePaths) && Objects.equals(_excludeFields,
- config._excludeFields) && _maxValueLength == config._maxValueLength
- && _skipInvalidJson == config._skipInvalidJson;
+ config._excludeFields) && Objects.equals(_indexPaths,
config._indexPaths)
+ && _maxValueLength == config._maxValueLength && _skipInvalidJson ==
config._skipInvalidJson
+ && Objects.equals(_maxBytesSize, config._maxBytesSize);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), _maxLevels, _excludeArray,
_disableCrossArrayUnnest, _includePaths,
- _excludePaths, _excludeFields, _maxValueLength, _skipInvalidJson);
+ _excludePaths, _excludeFields, _indexPaths, _maxValueLength,
_skipInvalidJson, _maxBytesSize);
}
}
diff --git
a/pinot-spi/src/test/java/org/apache/pinot/spi/config/table/JsonIndexConfigTest.java
b/pinot-spi/src/test/java/org/apache/pinot/spi/config/table/JsonIndexConfigTest.java
index 706a8f71a40..80f13359cf1 100644
---
a/pinot-spi/src/test/java/org/apache/pinot/spi/config/table/JsonIndexConfigTest.java
+++
b/pinot-spi/src/test/java/org/apache/pinot/spi/config/table/JsonIndexConfigTest.java
@@ -19,6 +19,7 @@
package org.apache.pinot.spi.config.table;
import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.Set;
import org.apache.pinot.spi.utils.JsonUtils;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
@@ -106,4 +107,62 @@ public class JsonIndexConfigTest {
assertEquals(config.getExcludePaths(), Lists.newArrayList("b"),
"Unexpected excludePaths");
assertEquals(config.getExcludeFields(), Lists.newArrayList("c"),
"Unexpected excludeFields");
}
+
+ //
---------------------------------------------------------------------------
+ // equals / hashCode — _indexPaths and _maxBytesSize must be included
+ //
---------------------------------------------------------------------------
+
+ @Test
+ public void testEqualsIgnoresDifferentIndexPathsWithoutFix() {
+ // Two configs that differ only in indexPaths must NOT be equal.
+ JsonIndexConfig a = new JsonIndexConfig();
+ JsonIndexConfig b = new JsonIndexConfig();
+ b.setIndexPaths(Set.of("a.**"));
+
+ assertNotEquals(a, b, "Configs with different indexPaths must not be
equal");
+ }
+
+ @Test
+ public void testEqualsIgnoresDifferentMaxBytesSizeWithoutFix() {
+ // Two configs that differ only in maxBytesSize must NOT be equal.
+ JsonIndexConfig a = new JsonIndexConfig();
+ JsonIndexConfig b = new JsonIndexConfig();
+ b.setMaxBytesSize(1024L);
+
+ assertNotEquals(a, b, "Configs with different maxBytesSize must not be
equal");
+ }
+
+ @Test
+ public void testEqualsIdenticalConfigs() {
+ JsonIndexConfig a = new JsonIndexConfig();
+ a.setIndexPaths(Set.of("a.**"));
+ a.setMaxBytesSize(512L);
+
+ JsonIndexConfig b = new JsonIndexConfig();
+ b.setIndexPaths(Set.of("a.**"));
+ b.setMaxBytesSize(512L);
+
+ assertEquals(a, b, "Identical configs must be equal");
+ assertEquals(a.hashCode(), b.hashCode(), "Equal configs must have the same
hashCode");
+ }
+
+ @Test
+ public void testHashCodeIncludesIndexPaths() {
+ JsonIndexConfig a = new JsonIndexConfig();
+ JsonIndexConfig b = new JsonIndexConfig();
+ b.setIndexPaths(Set.of("x.**"));
+
+ assertNotEquals(a.hashCode(), b.hashCode(),
+ "hashCode must differ when indexPaths differ");
+ }
+
+ @Test
+ public void testHashCodeIncludesMaxBytesSize() {
+ JsonIndexConfig a = new JsonIndexConfig();
+ JsonIndexConfig b = new JsonIndexConfig();
+ b.setMaxBytesSize(2048L);
+
+ assertNotEquals(a.hashCode(), b.hashCode(),
+ "hashCode must differ when maxBytesSize differs");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]