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

feat: finish read/write for single shard #17

Merged
merged 5 commits into from
Feb 18, 2024

Conversation

v0y4g3r
Copy link
Collaborator

@v0y4g3r v0y4g3r commented Feb 8, 2024

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

This PR implements the iter method for DataParts. The iterator is simply a merge reader that compares the pk from both active and frozen parts of DataParts and merges those DataBatches with same pk index.

Also freeze will be triggered on write path of the num of rows inside active data buffer exceeds freeze_threshold in MergeTreeConfig.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

Refer to a related PR or issue link (optional)

@v0y4g3r v0y4g3r marked this pull request as ready for review February 9, 2024 06:11
@v0y4g3r v0y4g3r changed the title feat: trigger freeze feat: finish read/write for single shard Feb 9, 2024
@v0y4g3r v0y4g3r requested a review from evenyag February 9, 2024 06:13

impl Iterator for Iter {
type Item = Result<DataBatch>;

fn next(&mut self) -> Option<Self::Item> {
todo!()
while let Some(mut top) = self.heap.pop() {
if top.source.is_valid() {
Copy link
Owner

Choose a reason for hiding this comment

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

We can guarantee nodes in the heap are valid so we don't need this check.

@@ -186,6 +335,8 @@ impl DataBuffer {
})
.push_value_ref(field);
}

self.ts_builder.len() >= self.freeze_threshold
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe we should provide a len() method and check this outside of the buffer. Then we don't need to store the threshold in the buffer.

offset: 0,
current_data_batch: None,
};
iter.next(); // fill data batch for comparison and merge.
Copy link
Owner

Choose a reason for hiding this comment

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

next() returns a result. We should handle it or change the return value of next().

@evenyag
Copy link
Owner

evenyag commented Feb 18, 2024

I plan to merge it first.

@evenyag evenyag merged commit f03bf90 into evenyag:poc/compact-memtable Feb 18, 2024
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants