-
Notifications
You must be signed in to change notification settings - Fork 257
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
rados: implement binding for rados_read_op_read #615
Conversation
Currently, in order for users to read the data off of the buffer, they need to do I think this ^ would be a bit more user-friendly, but perhaps further from its C form. I'll let reviewers decide which one is better and will change this PR accordingly. |
Please ignore the CI error
|
Thanks for mentioning this. I think it's fine in the current form. A "short read" is handled the same way in idiomatic go when using something like an io.Reader too. So it's not just a closeness to C argument I think. Plus if there was high demand for this proposed form, it'd be relatively easy to implement as a helper building on top of this step, but the other way around would not be possible. :-) I'll try to look at the full implementation soon, but I'm going to have limited availability for the next few days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call the file just read_op_raed.go
, then we don't have to change the filename, when it's changing to stable.
rados/read_op_preview.go
Outdated
} | ||
|
||
// Read bytes from offset into buffer. | ||
// `len(buffer)` is the maximum number of bytes read from the object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go comments don't support this markdown style formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I've just seen them being used on a couple of places, e.g.
go-ceph/internal/cutil/aliases.go
Lines 36 to 43 in 1d9c3f8
// CharPtrPtr is an unsafe pointer wrapping C's `char**`. | |
type CharPtrPtr unsafe.Pointer | |
// CharPtr is an unsafe pointer wrapping C's `char*`. | |
type CharPtr unsafe.Pointer | |
// SizeTPtr is an unsafe pointer wrapping C's `size_t*`. | |
type SizeTPtr unsafe.Pointer |
... but then there are other functions right next to them and they are not using backticks. If this causes an eyesore I can remove them for consistency sake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, these are also "wrong", but they are in an internal package, so no documentation is created from it. Your comments are however part of the external interface and will show up in the docs, so I would prefer to keep it to the Go conventions.
rados/read_op_preview.go
Outdated
// size_t * bytes_read, | ||
// int * prval) | ||
func (r *ReadOp) Read(offset uint64, buffer []byte) *ReadOpReadStep { | ||
oe := newReadStep(buffer, uint64(len(buffer)), offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the second argument is always len(buffer), we don't need it and can get len(buffer)
in newReadStep()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, right now there are no other cases where the length differs. But maybe in the future there might be one, and all the occurrences would have to be refactored? I can't give examples where this would be true from the top of my head though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Go idiomatic way would be to use a slice of the buffer then, like buffer[:N]
, because that doesn't cause a copy. I think it would not be good coding style to give a function the whole buffer, but then tell it: "oh but please don't use the whole buffer but only the beginning of it".
And anyway I hope there will be not many occurrences of a function called newReadStep()
. ;-)
Is that the plan? To have each OP implementation in a separate file? If that's so then sure, that makes more sense -- only the build tag would be removed. |
@ansiwen @phlogistonjohn Hello and happy new year! Just a reminder for this PR because I haven't received any responses for my last comments -- unless it means you insist on all of them? |
There is no real plan, but I think it doesn't hurt, given that we have the new "preview" policy in place. |
Yeah, Thanks for the reminder. I answered now. @phlogistonjohn will be back at work tomorrow. |
b3de1a4
to
be5e4cf
Compare
Hmm, I got an "ok" from running
@phlogistonjohn @ansiwen can you please take a look? I hope I addressed all of the comments so far. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing in the code jumps out at me and the API looks OK and the tests look OK.
We do need to fix the version numbers in the API metadata tho as we have made additional releases since you originally generated the files. Sorry for the inconvenience.
docs/api-status.json
Outdated
{ | ||
"name": "ReadOp.Read", | ||
"comment": "Read bytes from offset into buffer.\nlen(buffer) is the maximum number of bytes read from the object.\nbuffer[:ReadOpReadStep.BytesRead] then contains object data.\n PREVIEW\n\nImplements:\n void rados_read_op_read(rados_read_op_t read_op,\n uint64_t offset,\n size_t len,\n char * buffer,\n size_t * bytes_read,\n int * prval)\n", | ||
"added_in_version": "v0.12.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The numbers here have to be updated. The next upcoming release is v0.14
docs/api-status.md
Outdated
@@ -13,6 +13,7 @@ | |||
Name | Added in Version | Expected Stable Version | | |||
---- | ---------------- | ----------------------- | | |||
WriteOp.CmpExt | v0.12.0 | v0.14.0 | | |||
ReadOp.Read | v0.12.0 | v0.14.0 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. This file is generated based on the json - you can either update this by hand or by running the apiage tool. For a trivial edit the by-hand appraoch is probably faster :-)
This commit implements binding for rados_read_op_read RADOS Read operation. Includes a unit test. Signed-off-by: Robert Vasek <[email protected]>
be5e4cf
to
037e5eb
Compare
@ansiwen @phlogistonjohn I've re-run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Thank you both for feedback and reviews! It seems though this is not getting merged because of the failing "Summary" CI job? |
Thanks for pointing that out. Mergify config appears broken. I'll just merge it manually now and look into the mergify issue later today. Thanks! |
This PR adds binding for
rados_read_op_read
RADOS Read operation including a unit test for it.It also adds a common
readStep
struct as it was missing.Checklist