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] Metadata segment reader/writer #2211

Merged
merged 14 commits into from
May 24, 2024
Merged

[ENH] Metadata segment reader/writer #2211

merged 14 commits into from
May 24, 2024

Conversation

beggers
Copy link
Member

@beggers beggers commented May 15, 2024

Description of changes

Summarize the changes made by this PR.

  • New functionality
    • Metadata segment reader/writer outline. They don't yet have methods to add and query stuff.
    • Note: We don't have the requisite types in Rust to represent full-text or metadata queries yet -- since I'm ooo tomorrow, putting this PR up now for a review as-is.

Test plan

How are these changes tested?

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

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?

Copy link

vercel bot commented May 15, 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 23, 2024 9:49pm

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)

@beggers beggers changed the title [ENH] Metadata segment reader/writer skeleton [ENH] Metadata segment reader/writer May 16, 2024
}
}

fn apply_log_chunk(
Copy link
Collaborator

Choose a reason for hiding this comment

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

note to self: we should remove this

@@ -24,6 +25,7 @@ impl From<SegmentType> for String {
SegmentType::Record => "urn:chroma:segment/record".to_string(),
SegmentType::Sqlite => "urn:chroma:segment/metadata/sqlite".to_string(),
SegmentType::BlockfileMetadata => "urn:chroma:segment/metadata/blockfile".to_string(),
SegmentType::Metadata => "urn:chroma:segment/metadata".to_string(),
Copy link
Collaborator

@HammadB HammadB May 23, 2024

Choose a reason for hiding this comment

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

i think "urn:chroma:segment/metadata/blockfile" is what we want to use? maybe im confused.

Segment scopes are Record/ Vector / Metadata. Types are concrete impls

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, that is what I want. While we're here, though, what exactly is this for? Is this a storage location of some sort or?

@@ -23,37 +27,40 @@ impl ChromaError for FullTextIndexError {
pub(crate) struct FullTextIndexWriter {
posting_lists_blockfile_writer: BlockfileWriter,
frequencies_blockfile_writer: BlockfileWriter,
tokenizer: Box<dyn ChromaTokenizer>,
// This is a crime.
tokenizer: Arc<Mutex<Box<dyn ChromaTokenizer>>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

we could make this thread local if it turns out tokenization sync is bad

}

impl SegmentWriter for MetadataSegmentWriter {
fn apply_materialized_log_chunk(
Copy link
Contributor

Choose a reason for hiding this comment

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

note to self: This needs to be audited again after materializedLogRecordV2 is merged. Also, TBD add support for updates/deletes/upserts here

MetadataValue::Int(value) => {
match &self.u32_metadata_index_writer {
Some(writer) => {
let _ = writer.set(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this diff but one thing that came to my mind is that we don't write atomically across the segments today i.e. it can happen that the compactor node crashes after writing for e.g. to the record segment but before writing to the metadata segment, etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Capturing our conversation here for posterity:

Yes, that can happen. We designed for this and that's why the flush protocol is: write new blockfiles, update sysdb to point to new blockfiles, purge logs. If we crash anywhere in there we're still correct.

@beggers beggers merged commit cf63813 into main May 24, 2024
47 checks passed
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

3 participants