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

Refactor levels, key range checking etc #89

Open
marvin-j97 opened this issue Dec 7, 2024 · 0 comments
Open

Refactor levels, key range checking etc #89

marvin-j97 opened this issue Dec 7, 2024 · 0 comments
Labels

Comments

@marvin-j97
Copy link
Contributor

marvin-j97 commented Dec 7, 2024

Currently, all the level logic operates basically on a Vec<Vec>, which can be a pain to unit test because we have to create fixture segments.

It would be better if all the key range checking, overlapping in other levels can be utility functions over a trait K that is basically:

trait K {
  fn id(&self) -> Id;
  fn key_range(&self) -> &KeyRange;
  fn size(&self) -> u64;
}

and Segment implements that trait (quite trivially).

And then have utility functions for &[K] like:

fn overlaps(&self, key_range: &KeyRange, hidden_set: &HashSet<Self::Id>) -> impl Iterator<Item = K>;

fn find_by_key(&self, key: &[u8]) -> Option<&K>;

// ...etc

That way, all the range checking, overlapping logic etc is separated from segments.

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

No branches or pull requests

1 participant