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 metadata deletes + fix bugs related to Updates/deletes in the metadata writer #2344

Merged
merged 4 commits into from
Jun 18, 2024

Conversation

sanketkedia
Copy link
Contributor

@sanketkedia sanketkedia commented Jun 14, 2024

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Handles metadata deletes
    • Full text writer adds (token, freq) pair even if freq is 0. Fixes this.
    • Full text writer does not remove postings list of documents that have been deleted. Fixes this.
    • Fix for test_query_without_add

Test plan

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

Documentation Changes

None

@sanketkedia sanketkedia requested a review from HammadB June 14, 2024 23:25
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)


// Merges update metadata to base metadata, updating
// the delete list and upsert list.
pub(crate) fn merge_update_metadata(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does this take base_metadata as a tuple? Feels clunky

record_from_map.metadata_to_be_merged = match merge_update_metadata(
&record_from_map.metadata_to_be_merged,
match merge_update_metadata(
(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This tupling feels unnecessary? What is your explanation for doing it this way?

use thiserror::Error;

use super::record_segment::{ApplyMaterializedLogError, RecordSegmentReader};

// Materializes metadata from update metadata, populating the delete list
// and upsert list.
pub(crate) fn materialize_update_metadata(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find materialize_update_metadata + merge_update_metadata in tandem very confusing.

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.

This is fine. The metadata update logic and state handling is very hard to follow IMO.

@sanketkedia
Copy link
Contributor Author

Discussed offline that nothing obvious comes to mind wrt simplifying the metadata merge. At this point, ok to move on but revisit this later and assess if there are possibilities to do this

@sanketkedia sanketkedia force-pushed the metadata_update_bugs branch 2 times, most recently from 621a903 to d2fe0ab Compare June 17, 2024 22:11
@sanketkedia sanketkedia merged commit 7684d61 into main Jun 18, 2024
63 checks passed
Anush008 pushed a commit to Anush008/chroma that referenced this pull request Jun 27, 2024
…n the metadata writer (chroma-core#2344)

## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
    - Handles metadata deletes
- Full text writer adds (token, freq) pair even if freq is 0. Fixes
this.
- Full text writer does not remove postings list of documents that have
been deleted. Fixes this.
    - Fix for test_query_without_add

## Test plan
- [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