Skip to content

feat(core): Implement write and write_from for Writer - #4482

Merged
Xuanwo merged 6 commits into
apache:mainfrom
zjregee:make-writer-use-buffer
Apr 15, 2024
Merged

Xuanwo merged 6 commits into
apache:mainfrom
zjregee:make-writer-use-buffer

Conversation

@zjregee

@zjregee zjregee commented Apr 13, 2024

Copy link
Copy Markdown
Member

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
@github-actions github-actions Bot added the releases-note/feat The PR implements a new feature or has a title that begins with "feat" label Apr 13, 2024
Comment thread core/src/types/writer.rs Resolved
Comment thread core/src/types/writer.rs Resolved
Comment thread core/src/types/writer.rs Resolved
Comment thread core/src/types/writer.rs Resolved
@zjregee

zjregee commented Apr 13, 2024

Copy link
Copy Markdown
Member Author

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

@zjregee

zjregee commented Apr 14, 2024

Copy link
Copy Markdown
Member Author

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

Xuanwo commented Apr 15, 2024 •

Copy link
Copy Markdown
Member

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.

Comment thread core/src/layers/complete.rs Outdated
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
Copy Markdown
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.

@zjregee zjregee Apr 15, 2024 •

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated.

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

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
@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 done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants