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

Switch record_payloads from using &'b [u8] to bytes::Buf #29

Closed
imotov opened this issue Feb 24, 2023 · 1 comment · Fixed by #31
Closed

Switch record_payloads from using &'b [u8] to bytes::Buf #29

imotov opened this issue Feb 24, 2023 · 1 comment · Fixed by #31
Assignees
Labels
enhancement New feature or request

Comments

@imotov
Copy link
Collaborator

imotov commented Feb 24, 2023

As we discussed in quickwit-oss/quickwit#2834, we need to store more than a record's content in payload. In case we want to store a command like this:

enum Command<'a> {
     Ingest {
         json_payload: &'a [u8]
     },
     Commit,
     // ... more to come?
}

we will need to write a command type followed by json_payload. Having &[u8] in the interface doesn't allow us to write two chunks of data efficiently. However, if we switch interface to use bytes::Buf it will allows us to continue using &[u8] thanks to impl Buf for &[u8] and at the same time be able to provide access to command code and payload without copying thanks to Buf's support for chaining.

@imotov imotov added the enhancement New feature or request label Feb 24, 2023
@fulmicoton
Copy link
Contributor

That sounds like the perfect solution.

imotov added a commit to imotov/mrecordlog that referenced this issue Feb 28, 2023
Switches record_payloads internface from using &'b [u8] to bytes::Buf.

Closes quickwit-oss#29
trinity-1686a added a commit that referenced this issue Mar 1, 2023
* Switch record_payloads to bytes::Buf

Switches record_payloads internface from using &'b [u8] to bytes::Buf.

Closes #29

* Update src/record.rs

Better check for remaining

Co-authored-by: trinity-1686a <trinity.pointard@gmail.com>

---------

Co-authored-by: trinity-1686a <trinity.pointard@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants