Skip to content

[POC] Introduce selection vector for hash aggregate #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 41 commits into
base: feat/selection-vector-partition
Choose a base branch
from

Conversation

goldmedal
Copy link
Owner

@goldmedal goldmedal commented Apr 20, 2025

Which issue does this PR close?

  • Closes #.

Rationale for this change

This PR only implements some of the hash aggregations:

  • The group by value is a primitive type.
  • count and the agg function, which uses GroupsAccumulator.

Benchmakr Result

  • Only run the query 4 and 7 of Clickbench.
--------------------
Benchmark clickbench_1.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Query        ┃ feat_hash-agg-sv-disable ┃ feat_hash-agg-sv ┃    Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ QQuery 4     │                 311.74ms │         320.72ms │ no change │
│ QQuery 7     │                  30.28ms │          29.01ms │ no change │
└──────────────┴──────────────────────────┴──────────────────┴───────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ Benchmark Summary                       ┃          ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ Total Time (feat_hash-agg-sv-disable)   │ 342.02ms │
│ Total Time (feat_hash-agg-sv)           │ 349.74ms │
│ Average Time (feat_hash-agg-sv-disable) │ 171.01ms │
│ Average Time (feat_hash-agg-sv)         │ 174.87ms │
│ Queries Faster                          │        0 │
│ Queries Slower                          │        0 │
│ Queries with No Change                  │        2 │
└─────────────────────────────────────────┴──────────┘

Comment on lines +118 to +125
if let Some(sv) = sv {
for idx in sv {
let v = if cols[0].as_primitive::<T>().is_null(*idx) {
None
} else {
Some(cols[0].as_primitive::<T>().value(*idx))
};
let group_id = match v {
Copy link
Owner Author

Choose a reason for hiding this comment

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

According to the selection indices, get the record by index iteratively.

@goldmedal goldmedal changed the title Introduce selection vector for hash aggregate [POC] Introduce selection vector for hash aggregate Apr 20, 2025
Comment on lines +829 to +836
let mut sv_mode = false;
let selection: Vec<usize> =
if let Some(array) = batch.column_by_name(SELECTION_FIELD_NAME) {
sv_mode = true;
array.as_boolean().values().set_indices().collect()
} else {
vec![]
};
Copy link
Owner Author

Choose a reason for hiding this comment

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

Where to get the selection vector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant