Skip to content

Improve data chunk #5082

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

sferik
Copy link

@sferik sferik commented Jul 11, 2025

  • Replaced the manual implementation of Clone for Chunk<T> with #[derive(Clone)] so the struct relies on the automatic, efficient clone implementation provided for Arc types
  • Fixed a typo in DataChunkIterator

Copy link
Contributor

propel-code-bot bot commented Jul 11, 2025

This PR removes the hand-written Clone implementation for Chunk in favor of #[derive(Clone)], relying on Rust's more efficient automatic derivation for Arc-based structs. Additionally, it fixes a typo in the iterator type DataChunkIterator and adds #[derive(Clone)] for the internal MaterializedLogRecord struct.

This summary was automatically generated by @propel-code-bot

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)

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.

Thanks

@HammadB HammadB enabled auto-merge (squash) July 12, 2025 00:40
auto-merge was automatically disabled July 12, 2025 03:50

Head branch was pushed to by a user without write access

@@ -122,7 +122,7 @@ impl ChromaError for LogMaterializerError {
/// Instead of cloning or holding references to log records/segment data, this struct contains owned values that can be resolved to the referenced data.
/// E.x. `final_document_at_log_index: Option<usize>` is used instead of `final_document: Option<&str>` to avoid holding references to the data.
/// This allows `MaterializedLogRecord` (and types above it) to be trivially Send'able.
#[derive(Debug)]
#[derive(Debug, Clone)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I saw this was added after I hit approve. We generally don't expose Clone on types that we don't intend to clone, as a defensive measure. Was there a strong reason for this change, would you be ok to remove it?

Copy link
Author

@sferik sferik Jul 12, 2025

Choose a reason for hiding this comment

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

The MaterializeLogsResult struct contains a Chunk<MaterializedLogRecord> field (on line 481).

Without this commit, tests were failing with the following error:

   Compiling chroma-segment v0.1.0 (/Users/erik/Code/Rust/chroma/rust/segment)
error[E0277]: the trait bound `MaterializedLogRecord: Clone` is not satisfied
   --> rust/segment/src/types.rs:481:5
    |
478 | #[derive(Debug, Clone)]
    |                 ----- in this derive macro expansion
...
481 |     materialized: Chunk<MaterializedLogRecord>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `MaterializedLogRecord`
    |
    = note: required for `Chunk<MaterializedLogRecord>` to implement `Clone`
help: consider annotating `MaterializedLogRecord` with `#[derive(Clone)]`
    |
126 + #[derive(Clone)]
127 | struct MaterializedLogRecord {
    |

For more information about this error, try `rustc --explain E0277`.
error: could not compile `chroma-segment` (lib) due to 1 previous error
error: command `/opt/homebrew/bin/cargo test --no-run --message-format json-render-diagnostics` exited with code 101

This patch fixes that problem so the tests all pass. (Sorry for not running the tests locally before submitting my initial patch.)

@HammadB
Copy link
Collaborator

HammadB commented Jul 12, 2025 via email

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.

2 participants