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

New and improved iteration APIs for Chunks #6989

Merged
merged 3 commits into from
Jul 29, 2024

Conversation

teh-cmc
Copy link
Member

@teh-cmc teh-cmc commented Jul 25, 2024

Just bunch of brand new and/or improved iteration APIs for Chunks.

This will be used all over the place with the new query APIs, which will appear in a future PR.

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!
  • If have noted any breaking changes to the log API in CHANGELOG.md and the migration guide

To run all checks from main, comment on the PR with @rerun-bot full-check.

@teh-cmc teh-cmc added 🧑‍💻 dev experience developer experience (excluding CI) 🔍 re_query affects re_query itself 🚀 performance Optimization, memory use, etc do-not-merge Do not merge this PR include in changelog labels Jul 25, 2024
crates/store/re_chunk/src/iter.rs Show resolved Hide resolved
crates/store/re_chunk/src/slice.rs Show resolved Hide resolved
crates/store/re_chunk/src/slice.rs Show resolved Hide resolved
crates/store/re_chunk/src/slice.rs Show resolved Hide resolved
@teh-cmc teh-cmc changed the title TODO 0: todo New and improved iteration APIs for Chunks Jul 25, 2024
@teh-cmc teh-cmc marked this pull request as ready for review July 25, 2024 16:10
@Wumpf Wumpf self-requested a review July 26, 2024 08:52
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

so many iterators * _ *
looks good tho

crates/store/re_chunk/src/chunk.rs Show resolved Hide resolved
#[inline]
pub fn iter_indices(&self, timeline: &Timeline) -> impl Iterator<Item = (TimeInt, RowId)> + '_ {
if self.is_static() {
Either::Right(Either::Left(izip!(
Copy link
Member

Choose a reason for hiding this comment

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

nit: the way you decide when to pick left/right seems a bit arbitrary and is hard to read

Copy link
Member Author

Choose a reason for hiding this comment

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

It is not arbitrary!

They should all follow this model:

  • The first layer is always the emptiness layer: Left is empty, Right is non-empty.
  • The second layer is the temporarily layer: Left is static, Right is temporal.
  • Any layers beyond that follow the same pattern: Left doesn't have something, while Right does.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a comment in the code reflecting that.

let indices = izip!(std::iter::repeat(TimeInt::STATIC), self.row_ids());

if let Some(validity) = list_array.validity() {
Either::Right(Either::Left(Either::Left(
Copy link
Member

Choose a reason for hiding this comment

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

... not sure why I whined about double nested either earlier Oo. Maybe you want to introduce new IterVariants3 and IterVariants4 iterators which internally match things?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tbh I'd rather keep the nicely composable Either than introduce more ad-hoc things.

The caller never has to deal with them anyhow 🤷

crates/store/re_chunk/src/iter.rs Outdated Show resolved Hide resolved
crates/store/re_chunk/src/iter.rs Outdated Show resolved Hide resolved
@teh-cmc teh-cmc merged commit e9c0be7 into main Jul 29, 2024
18 of 19 checks passed
@teh-cmc teh-cmc deleted the cmc/chunkified_queries_0_chunk_iter branch July 29, 2024 10:38
@teh-cmc teh-cmc removed the do-not-merge Do not merge this PR label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍💻 dev experience developer experience (excluding CI) include in changelog 🚀 performance Optimization, memory use, etc 🔍 re_query affects re_query itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants