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

[ENH] Handle deletes and updates for count API #2185

Merged
merged 3 commits into from May 14, 2024
Merged

[ENH] Handle deletes and updates for count API #2185

merged 3 commits into from May 14, 2024

Conversation

sanketkedia
Copy link
Contributor

Description of changes

Summarize the changes made by this PR.

  • New functionality
    Updates, deletes and duplicate adds are handled for the count API in this PR.

Test plan

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Documentation Changes

None

Copy link

vercel bot commented May 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
chroma ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 4:49am

Copy link

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@@ -275,6 +275,22 @@ impl<'me, K: ArrowReadableKey<'me>, V: ArrowReadableValue<'me>> ArrowBlockfileRe
}
}

pub(crate) async fn key_exists(&'me self, prefix: &str, key: K) -> bool {
Copy link
Collaborator

@HammadB HammadB May 13, 2024

Choose a reason for hiding this comment

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

I would prefer has() or contains()

pub(crate) async fn key_exists(&'referred_data self, prefix: &str, key: K) -> bool {
match self {
BlockfileReader::ArrowBlockfileReader(reader) => reader.key_exists(prefix, key).await,
BlockfileReader::MemoryBlockfileReader(reader) => todo!(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like we implemented this, does it need to be todo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point! Missed updating here after implementing it

@@ -23,16 +25,21 @@ impl CountRecordsOperator {
pub(crate) struct CountRecordsInput {
record_segment_definition: Segment,
blockfile_provider: BlockfileProvider,
// Note: this vector needs to be in the same order as the log
// for the counting logic to be correct.
log_operation_and_id: Vec<(Operation, String)>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused as to why we pull this datastructure out rather than just keep Chunk which encapsulates the same information

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah there's no particular reason. I was trying to be cautious of cloning the entire log record by selectively cloning only the id and operation but I noticed that it is behind Arc so will change

let logs = logs.logs();
self.log_record_count = logs.total_len();
// TODO: Add logic for merging logs with count from record segment.
let mut operation_and_id: Vec<(Operation, String)> = Vec::new();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would prefer if we just forwarded the Chunk<> to align with other operators and also to minimize copying

}
};
// Reconcile adds, updates and deletes.
let mut present_id_set: HashSet<String> = HashSet::new();
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit on naming for readability here: would be nice if we made it distinct that this is present_in_record_segment or something as below we also have a "present set"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to more verbose names and also added some comemnts

@@ -262,7 +264,7 @@ impl BlockfileFlusher {
pub(crate) fn id(&self) -> uuid::Uuid {
match self {
// TODO: should memory blockfiles have ids?
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can remove this todo


#[cfg(test)]
mod tests {
use std::{collections::HashMap, str::FromStr};
Copy link
Collaborator

@HammadB HammadB May 14, 2024

Choose a reason for hiding this comment

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

nit: use statements should touch to trigger format/autosort

Copy link
Collaborator

@HammadB HammadB left a comment

Choose a reason for hiding this comment

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

[IGNORE]

@HammadB HammadB merged commit 37a030c into main May 14, 2024
46 checks passed
HammadB added a commit that referenced this pull request May 14, 2024
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - Count should handle uninit'ed segments
 - New functionality
	 - None
	 
## Test plan
*How are these changes tested?*
#2185 should add tests for the count() operator
- [x] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
None
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.

None yet

2 participants