arunkumarucet opened a new pull request, #20448:
URL: https://github.com/apache/pinot/pull/20448
When a realtime segment is sealed,
`MutableNoDictColumnStatistics#getTotalNumberOfEntries` returns the number of
docs instead of the number of values. Every raw (no-dictionary) multi-value
column sealed from a realtime segment therefore records `totalNumberOfEntries =
numDocs`. The dictionary-encoded sibling, `MutableColumnStatistics`, already
returns `getNumValues()`, as does `CompactedNoDictColumnStatistics` on the
compaction path.
**Symptoms**
1. **Seal fails when a raw MV column has a range index.**
`RangeIndexCreator` sizes its value buffer from `totalNumberOfEntries`, then
receives every value. Sealing throws `IndexOutOfBoundsException` from
`RangeIndexCreator.add` (`FloatValueBuffer.put`).
2. **Vector search on sealed segments silently loses
`vectorApproximateDistance`.** `VectorTransformFunctions` only reuses HNSW
scores for `cosineDistance` when `numValues == numDocs * dimension`. Sealed
segments failed that check, so every candidate's distance was recomputed by
decompressing the forward index.
- Example: Cohere 100K x 768 force-committed. The segment recorded
`totalNumberOfEntries = 100000` instead of `76800000`.
- Median query latency on the sealed segment, before → after:
| k | Before | After |
|---|---|---|
| 100 | 72.6 ms | **2.3 ms** |
| 400 | 186.9 ms | **3.0 ms** |
- Recall is identical before and after.
3. Bloom filters on raw MV columns are sized from this value (raw columns
have unknown cardinality), so they were undersized and missed their configured
FPP. After the fix they are sized by the number of values.
Single-value columns are unchanged: `getNumValues()` equals `getNumDocs()`
for them. The dictionary heuristics (`ignoreDictionaryOverride`) only read this
value for single-value columns.
**Change**
`MutableNoDictColumnStatistics#getTotalNumberOfEntries` returns
`getNumValues()`.
**Already-sealed segments**
The fix applies to segments sealed after upgrade. No reload path rewrites
`totalNumberOfEntries` for a raw column, so existing segments keep the old
value until they are rebuilt, e.g. by a refresh or a minion task. Recomputing
it on reload is a possible follow-up.
**Testing**
- New
`RealtimeSegmentConverterTest#testSealedMultiValueColumnCountsAllEntries`:
- Seals a FLOAT MV column holding 1 + 2 + 3 values, raw and
dictionary-encoded, with both the row-major and column-major builders.
- Asserts `totalNumberOfEntries == 6` in the segment metadata and from the
loaded data source.
- For the raw case, builds a range index and checks that it still finds
the last doc's values.
- Updated `MutableNoDictColumnStatisticsTest`. The MV cases now use a value
count that differs from the doc count, instead of asserting `numDocs`.
- Without the fix, the raw seal cases fail: the entry count assertions get
`3 != 6`, and the range index build throws `IndexOutOfBoundsException`. The 9
MV stats cases also fail.
- All 238 tests in `RealtimeSegmentConverterTest` and 33 in
`MutableNoDictColumnStatisticsTest` pass.
Labels: `bugfix`, `performance`
--
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]