Skip to content
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

test(414): multi-column index scan #415

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

joshua-spacetime
Copy link
Collaborator

Closes #414.

Adds a test for calling iter_by_col_eq with multiple columns. Ensures the index is scanned if an applicable multi-column index is present. To write this test, iter_by_col_eq was updated to take multiple columns.

Description of Changes

API and ABI

  • This is a breaking change to the module ABI
  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API

If the API is breaking, please state below what will break

Expected complexity level and risk

How complicated do you think these changes are? Grade on a scale from 1 to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex change.

This complexity rating applies not only to the complexity apparent in the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning ways.

@joshua-spacetime joshua-spacetime force-pushed the joshua/414/test/multi-column-index branch from be8cace to fa67322 Compare October 11, 2023 15:12
@@ -1920,20 +1915,20 @@ impl TxDatastore for Locking {
&'a self,
tx: &'a Self::TxId,
table_id: TableId,
col_id: ColId,
cols: NonEmpty<ColId>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the datastore iterators to take a NonEmpty list of column ids.

@@ -152,7 +152,7 @@ impl InstanceEnv {
let eq_value = stdb.decode_column(tx, table_id, col_id, value)?;

// Find all rows in the table where the column data equates to `value`.
let seek = stdb.iter_by_col_eq(tx, table_id, col_id, eq_value)?;
let seek = stdb.iter_by_col_eq(tx, table_id, ColId(col_id), eq_value)?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

After updating the type signatures of the datastore iterators, the rest of the changes, like this one, were about updating the call sites to reflect the new signature.

let cols: NonEmpty<ColId> = NonEmpty::collect(vec![ColId(0), ColId(1)]).unwrap();
let value: AlgebraicValue = product![AlgebraicValue::U64(0), AlgebraicValue::U64(1)].into();

let IterByColEq::Index(mut iter) = stdb.iter_by_col_eq(&tx, table_id, cols, value)? else {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Testing the new iter_by_col_eq with multi-column index.

@joshua-spacetime joshua-spacetime requested review from mamcx and kim October 11, 2023 15:17
Copy link
Contributor

@kim kim left a comment

Choose a reason for hiding this comment

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

👍

//If we don't have `self.tx_state` yet is likely we are running the bootstrap process
Some(committed_rows) => match self.tx_state.as_ref() {
None => Ok(IterByColRange::Scan(ScanIterByColRange {
range,
col_id: *col_id,
cols: NonEmpty::collect(cols.into_iter().map(|col| col.0)).unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just map directly over cols

@joshua-spacetime joshua-spacetime force-pushed the joshua/414/test/multi-column-index branch from fa67322 to 0dbcf1f Compare October 12, 2023 21:44
Closes #414.

Adds a test for calling iter_by_col_eq with multiple columns.
Ensures the index is scanned if an applicable multi-column index is present.
To write this test, iter_by_col_eq was updated to take multiple columns.
@joshua-spacetime joshua-spacetime force-pushed the joshua/414/test/multi-column-index branch from 0dbcf1f to 7c84ba8 Compare October 12, 2023 21:48
@joshua-spacetime joshua-spacetime enabled auto-merge (squash) October 12, 2023 21:49
@joshua-spacetime joshua-spacetime merged commit ca532c9 into master Oct 12, 2023
@joshua-spacetime joshua-spacetime deleted the joshua/414/test/multi-column-index branch October 12, 2023 22:07
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.

Add test for multi-column index scan
2 participants