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

kv: iterator support #629

Draft
wants to merge 7 commits into
base: develop
Choose a base branch
from
Draft

kv: iterator support #629

wants to merge 7 commits into from

Conversation

barraguda
Copy link
Contributor

Problem

hyperware-ai/process_lib#125

Solution

pub enum KvAction {
    // ...
    IterStart { prefix: Option<Vec<u8>> },
    IterNext { iterator_id: u64, count: u64 },
    IterClose { iterator_id: u64 },
}

pub enum KvResponse {
    // ...
    IterStart { iterator_id: u64 },
    IterNext { done: bool },
    IterClose { iterator_id: u64 },
}

Testing

# Follow these steps to test

Copy link
Member

@nick1udwig nick1udwig left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me. I'd recommend closing the iterator once you hit done = true rather than requiring the consumer to call IterClose.

In general DashMaps make me nervous cuz we've had a lot of deadlocks from them, but just looking at the code it seems ok 😅

Please be sure to hit all the new codepaths here in tests, ideally with two processes to try to exercise the DashMaps in a multi-tokio::task context.

Copy link
Member

@dr-frmr dr-frmr left a comment

Choose a reason for hiding this comment

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

Comment nits, please try to give interface that final polish.

Echoing Nick's concern here about lockups when multiple processes are iterating on same DB, please make sure to test that.

lib/src/kv.rs Outdated
@@ -20,6 +20,10 @@ pub enum KvAction {
BeginTx,
Commit { tx_id: u64 },
Backup,
// Iterator operations
Copy link
Member

Choose a reason for hiding this comment

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

Comments inside enums should be /// docstrings -- please label each iter operation with an explanation of how to use it. It's not immediately obvious to me how it works.

@dr-frmr dr-frmr marked this pull request as draft December 20, 2024 17:08
Base automatically changed from v0.10.0 to develop December 22, 2024 23:13
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.

3 participants