Skip to content

perf: Descending vector cursors. - #19947

Open
gianm wants to merge 3 commits into
apache:masterfrom
gianm:time-desc-vector-cursors
Open

perf: Descending vector cursors.#19947
gianm wants to merge 3 commits into
apache:masterfrom
gianm:time-desc-vector-cursors

Conversation

@gianm

@gianm gianm commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This patch adds descending-order vector cursors, enabling faster execution for timeseries, timeBoundary, and scan queries that run in descending order.

Benchmark                                      (descending)  (numSegments)  (queryGranularity)  (rowsPerSegment)         (schemaAndQuery)  (vectorize)  Mode  Cnt      Score     Error  Units
TimeseriesBenchmark.querySingleQueryableIndex          true              1                hour            750000  basic.timeFilterNumeric        false  avgt   15  11877.122 ±  89.831  us/op
TimeseriesBenchmark.querySingleQueryableIndex          true              1                hour            750000  basic.timeFilterNumeric         true  avgt   15   2620.778 ±  18.603  us/op
TimeseriesBenchmark.querySingleQueryableIndex         false              1                hour            750000  basic.timeFilterNumeric        false  avgt   15  12219.221 ± 106.745  us/op
TimeseriesBenchmark.querySingleQueryableIndex         false              1                hour            750000  basic.timeFilterNumeric         true  avgt   15   2468.444 ±  57.393  us/op

This patch adds descending-order vector cursors, enabling faster
execution for timeseries, timeBoundary, and scan queries that run in
descending order.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 26 of 26 changed files.

Validation: git diff --check passed; no builds or tests were run.


This is an automated review by Codex GPT-5.6-Luna(max)

* batches in internally-ascending order. This allows them to be simpler, as they do not need to have handling for
* both ascending and descending order.
*/
public class ReverseVectorColumnSelectorFactory implements VectorColumnSelectorFactory

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Reverse factory bypasses virtual-column group-by handling

The wrapper inherits the generic makeGroupByVectorColumnSelector implementation instead of preserving the underlying factory's virtual-column specialization. A descending vectorized group-by using an ExpressionVirtualColumn can therefore reach the generic ARRAY processor and fail with UnsupportedOperationException instead of using the supported deferred expression selector. Add a reverse-aware group-by override and regression coverage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeGroupByVectorColumnSelector won't be called anyway since groupBy doesn't use descending cursors. I'll add an explicit override that throws NotYetImplemented.

@gianm gianm changed the title feat: Descending vector cursors. perf: Descending vector cursors. Aug 10, 2026

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

Reviewed 26 of 26 changed files.


This is an automated review by Codex GPT-5.6-Luna(max)

* it advances as long as the next value is larger than the given value, i.e., it is the reverse-order
* analog of the forward iterator's behavior.
*/
public static PeekableIntIterator getReverseBitmapOffsetIterator(ImmutableBitmap bitmapIndex)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve the reverse-iterator binary signature

Changing the public method return type from IntIterator to PeekableIntIterator changes its JVM descriptor. Precompiled callers using the previous processing artifact can fail with NoSuchMethodError at runtime. Preserve the IntIterator-returning method and expose the peekable iterator under a new method name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not worried about this, this function is an internal API.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 26 of 26 changed files. The follow-up concern is handled: normal groupBy cursor specs do not request descending ordering, and the explicit NotYetImplemented guard addresses the original concern. No further inline reply is needed.


This is an automated review by Codex GPT-5.6-Luna(max)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants