Commit 6dd6f03
Fix MatrixStatsAggregator reuse when mode parameter changes (#18254)
* Fix matrix_stats aggregation cache conflict by including multiValueMode in equals/hashCode
- Added multiValueMode to equals() and hashCode() of MatrixStatsAggregationBuilder
- Added serialization/deserialization logic for multiValueMode in writeTo/readFrom
- Prevents incorrect aggregator reuse when aggregation mode changes (e.g. AVG ↔ MIN)
Signed-off-by: Jinwoo Lee <[email protected]>
* test: add unit test to verify multiValueMode affects matrix_stats result
- Verifies that different multiValueMode settings (e.g., AVG vs MIN) produce different results
- Prevents regression of incorrect aggregator reuse due to missing mode in equals/hashCode
- Ensures matrix_stats behavior reflects requested aggregation mode
Signed-off-by: Jinwoo Lee <[email protected]>
* Make multiValueMode serialization aware of version differences in MatrixStats
- Add version check before serializing multiValueMode to maintain backward compatibility
- Use AVG as default fallback when reading from pre-3.1.0 versions
Signed-off-by: Jinwoo Lee <[email protected]>
* Add roundtrip test to verify serialization and deserialization of MatrixStatsAggregationBuilder
- This test ensures that MatrixStatsAggregationBuilder can be correctly
- serialized and deserialized when using version >= 3.1.0.
- It validates field name and multiValueMode consistency across versions.
Signed-off-by: Jinwoo Lee <[email protected]>
* Ensure deserialization fallback to AVG for versions earlier than 2.4.0
- MatrixStatsAggregationBuilder did not serialize multiValueMode before v2.4.0.
- This test verifies that deserialization correctly falls back to AVG mode for older versions.
Signed-off-by: Jinwoo Lee <[email protected]>
* Verify that equals and hashCode behave correctly for MatrixStatsAggregationBuilder
- Adds equality and hashCode consistency checks for different configurations of MatrixStatsAggregationBuilder, including changes in multiValueMode.
Signed-off-by: Jinwoo Lee <[email protected]>
* Align deserialization version check for multiValueMode with 3.1.0
Updates the version check in MatrixStatsAggregationBuilder's constructor to use Version.V_3_1_0
when reading multiValueMode from StreamInput. For earlier versions, the fallback defaults to AVG,
ensuring compatibility with pre-3.1.0 serialized streams.
Signed-off-by: Jinwoo Lee <[email protected]>
* Add matrix stats test for MultiValueMode differences
Added SearchIT.testMatrixStatsMultiValueModeEffect to verify that different
MultiValueMode settings (AVG vs MIN) produce different matrix stats results
for multi-valued fields.
Signed-off-by: Jinwoo Lee <[email protected]>
* Add matrix stats multi-value mode test to IndicesRequestCacheIT
Signed-off-by: Jinwoo Lee <[email protected]>
* test: move matrix_stats multiValueMode request cache test to IndicesRequestCacheIT
The integration test for verifying request cache behavior of matrix_stats
(MultiValueMode.AVG vs MultiValueMode.MIN) was moved from SearchIT to
IndicesRequestCacheIT as it directly relates to the caching layer.
Also added assertions to verify that:
- The first AVG aggregation request triggers a cache miss
- The second AVG request hits the cache
- The first MIN request is treated as a different query and causes a second miss
- The second MIN request results in a hit
This aligns with the review suggestion to group request cache-specific tests together
and validate distinct cache keys for different MultiValueMode settings.
Signed-off-by: Jinwoo Lee <[email protected]>
* Remove matrix-stats module test dependency from server build
Removed `testImplementation project(path: ':modules:aggs-matrix-stats')` from `server/build.gradle` to avoid introducing a dependency from core to plugin modules.
Tests for matrix-stats should reside within the plugin module itself to maintain proper modular boundaries.
Signed-off-by: Jinwoo Lee <[email protected]>
* Add integration test for matrix stats multi-value mode behavior
Signed-off-by: Jinwoo Lee <[email protected]>
* Remove matrix stats integration test from core-level test suite
Signed-off-by: Jinwoo Lee <[email protected]>
* Restore server/build.gradle to match reactor-netty upgrade commit
Restored server/build.gradle to its state at commit c060f92, before test dependencies on aggs-matrix-stats were introduced.
This aligns with the modular boundaries that prevent the core server from depending on plugin modules.
Signed-off-by: Jinwoo Lee <[email protected]>
* Add changelog entry
Signed-off-by: Andrew Ross <[email protected]>
---------
Signed-off-by: Jinwoo Lee <[email protected]>
Signed-off-by: Andrew Ross <[email protected]>
Co-authored-by: Andrew Ross <[email protected]>1 parent d723db8 commit 6dd6f03
File tree
4 files changed
+208
-2
lines changed- modules/aggs-matrix-stats/src
- main/java/org/opensearch/search/aggregations/matrix/stats
- test/java/org/opensearch/search/aggregations/matrix
- stats
4 files changed
+208
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
Lines changed: 25 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
77 | 84 | | |
78 | 85 | | |
79 | 86 | | |
80 | | - | |
81 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
| |||
110 | 119 | | |
111 | 120 | | |
112 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
113 | 136 | | |
Lines changed: 93 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
Lines changed: 89 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
129 | 218 | | |
130 | 219 | | |
131 | 220 | | |
| |||
0 commit comments