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

Actually use indexes #73

Merged
merged 2 commits into from
Jul 26, 2023
Merged

Actually use indexes #73

merged 2 commits into from
Jul 26, 2023

Conversation

kulakowski
Copy link
Contributor

Description of Changes

API

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

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

@kulakowski
Copy link
Contributor Author

This could be rewritten a few different ways, but mostly wanted to get eyes on it and know if there should be some other abstraction around the indexes, Tyler.

Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

Looks good! Some non-functional things I think could aid readability.

Comment on lines +1345 to +1365
// We have to index_seek in both the committed state and the current tx state.
// First, we will check modifications in the current tx. It may be that the table
// has not been modified yet in the current tx, in which case we will only search
// the committed state. Finally, the table may not be indexed at all, in which case
// we fall back to iterating the entire table.

// We need to check the tx_state first. In particular, it may be that the index
// was only added in the current transaction.
// TODO(george): It's unclear that we truly support dynamically creating an index
// yet. In particular, I don't know if creating an index in a transaction and
// rolling it back will leave the index in place.
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Comment on lines +1375 to +1386
// Either the current transaction has not modified this table, or the table is not
// indexed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Either the current transaction has not modified this table, or the table is not
// indexed.
// Either the current transaction has modified this table, or the table is indexed.

Not sure if this is better.

crates/core/src/db/datastore/locking_tx_datastore/mod.rs Outdated Show resolved Hide resolved
Comment on lines 1616 to 1639
pub enum IterByColEq<'a> {
Scan(ScanIterByColEq<'a>),
Index(IndexIterByColEq<'a>),
CommittedIndex(CommittedIndexIterByColEq<'a>),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Docs on these would probably aid quicker understanding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually good question for you:

In this common pattern of

enum Foo {
    X(X),
    Y(Y),
}

struct X {}
struct Y {}

would you prefer the more substantial doc comments on the structs X and Y, or on the enum arms X and Y?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm that's a tough one. I think it depends on how often one has the Foo version vs. the X/Y versions. I think I tend to prefer more of the docs on the enum variants as they tend to be used like so Foo::X(X { the fields }) and it provides more context in relation to the other variants. That said, you can always back-link and such, so it's not a big deal either way.

crates/core/src/db/datastore/locking_tx_datastore/mod.rs Outdated Show resolved Hide resolved
Comment on lines +1728 to +1743
!self
.tx_state
.delete_tables
.get(&self.table_id)
.map_or(false, |table| table.contains(row_id))
Copy link
Contributor

Choose a reason for hiding this comment

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

This here two I think could help readability if it was made into a function with docs explaining the why.

@kulakowski kulakowski merged commit ff98499 into master Jul 26, 2023
4 checks passed
cloutiertyler pushed a commit that referenced this pull request Aug 1, 2023
* Actually use indexes

* Get rid of unneeded references
cloutiertyler pushed a commit that referenced this pull request Aug 1, 2023
* Actually use indexes

* Get rid of unneeded references
@cloutiertyler cloutiertyler deleted the george/fix-indexes branch August 1, 2023 21:53
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.

3 participants