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(core): Implement write and write_from for Writer #4482

Merged
merged 6 commits into from
Apr 15, 2024

Conversation

zjregee
Copy link
Member

@zjregee zjregee commented Apr 13, 2024

related to: #4465

@zjregee zjregee requested a review from Xuanwo as a code owner April 13, 2024 02:44
@zjregee zjregee marked this pull request as draft April 13, 2024 02:44
@github-actions github-actions bot requested review from oowl and silver-ymz April 13, 2024 02:44
core/src/types/writer.rs Outdated Show resolved Hide resolved
core/src/types/writer.rs Outdated Show resolved Hide resolved
core/src/types/writer.rs Outdated Show resolved Hide resolved
core/src/types/writer.rs Outdated Show resolved Hide resolved
@zjregee
Copy link
Member Author

zjregee commented Apr 13, 2024

Got this, thank you for your guidance, I will modify the api implementation and related uses in the codes later.

@zjregee
Copy link
Member Author

zjregee commented Apr 14, 2024

This in itself is not very important, because it does not affect the implementation and API, but I have a little confuse about the use of Buffer and bytes::Bytes in the code.

For example, Bytes is used to generate input in the bench and fuzz tests now. Is it necessary to reduce the direct usage of Bytes and replace it entirely with Buffer?

Or we just focus on the API interface and the implementation underneath the API. The usage elsewhere in the code doesn't matter.

@zjregee zjregee marked this pull request as ready for review April 14, 2024 15:46
@Xuanwo
Copy link
Member

Xuanwo commented Apr 15, 2024

For example, Bytes is used to generate input in the bench and fuzz tests now. Is it necessary to reduce the direct usage of Bytes and replace it entirely with Buffer?

I feel like we don't need to.

Or we just focus on the API interface and the implementation underneath the API. The usage elsewhere in the code doesn't matter.

Yes, the point of Buffer is public API.

@@ -806,7 +806,7 @@ mod tests {
#[tokio::test]
async fn test_writer() {
let op = new_test_operator(Capability::default());
let res = op.write("path", vec![]).await;
let res = op.write("path", Vec::<u8>::new()).await;
Copy link
Member

Choose a reason for hiding this comment

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

Does this change required? I expect vec![] can work as is.

Copy link
Member Author

@zjregee zjregee Apr 15, 2024

Choose a reason for hiding this comment

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

This should be necessary because we have implemented conversion from Vec<u8> and Vec<Bytes> for Buffer. If we directly vec![], the compiler cannot determine which one it is and will report an error.

Copy link
Member

Choose a reason for hiding this comment

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

Nice point!

Copy link
Member

Choose a reason for hiding this comment

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

How about changing the code here into following for better reading?

let bs: Vec<u8> = vec![];
let res = op.write("path", bs).await;

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Thanks!

@Xuanwo Xuanwo merged commit 1a99896 into apache:main Apr 15, 2024
216 checks passed
@zjregee zjregee deleted the make-writer-use-buffer branch April 15, 2024 03:18
@Xuanwo Xuanwo mentioned this pull request Apr 16, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants