rados: implement binding for read_op_omap_get_vals_by_keys#629
Conversation
| // Next gets the next omap key/value pair referenced by | ||
| // ReadOpOmapGetValsByKeysStep's internal iterator. | ||
| // If there are no more elements to retrieve, (nil, nil) is returned. | ||
| // May be called only after Operate() finished. | ||
| // PREVIEW | ||
| func (s *ReadOpOmapGetValsByKeysStep) Next() (*OmapKeyValue, error) { | ||
| if !s.canIterate { | ||
| return nil, ErrOperationIncomplete | ||
| } | ||
|
|
||
| var ( | ||
| cKey *C.char | ||
| cVal *C.char | ||
| cValLen C.size_t | ||
| ) | ||
|
|
||
| ret := C.rados_omap_get_next(s.iter, &cKey, &cVal, &cValLen) | ||
| if ret != 0 { | ||
| return nil, getError(ret) | ||
| } | ||
|
|
||
| if cKey == nil { | ||
| // Iterator has reached the end of the list. | ||
| return nil, nil | ||
| } | ||
|
|
||
| return &OmapKeyValue{ | ||
| Key: C.GoString(cKey), | ||
| Value: C.GoBytes(unsafe.Pointer(cVal), C.int(cValLen)), | ||
| }, nil | ||
| } |
There was a problem hiding this comment.
There are a couple more place in rados's codebase that deals with OMap iterators and this adds an unnecessary amount of boilerplate. Maybe we could factor it out into its own struct and reuse that (probably as a separate PR)?
There was a problem hiding this comment.
Actually couple means just ReadOp.GetOmapValues.
There was a problem hiding this comment.
Sure, refactoring is generally welcome especially if it reduces the maintenance burden. Usually the only cases where I'd object to it would be cases where copy-n-paste reduces the maintenace burden or if its not really clear the code paths are the same,etc.
For this case I see two main options:
- private helper functions that perform much of the boilerplate work
- a private embedded struct type that can provide the common methods
We can do the work in a follow up PR or here in this PR, but please let us know what you are thinking so I know how deeply to review the current state in the short term. :-)
There was a problem hiding this comment.
@phlogistonjohn thanks for the suggestions. I think doing it in a follow up PR would be cleaner, so this one should be ok to review as is.
Pull request has been modified.
|
PTAL @ansiwen when you have some time, I have a few more rados bindings PRs open (3 + this one to be exact) that I hope to get merged for 0.14.0 too. |
a1803d7 to
c9ed3fa
Compare
Pull request has been modified.
|
Sorry, the issue in #630 also applies here. I hope it's ok, but since we will release one week later, I hope you are fine with that late request. |
|
Sorry, I forgot to use mergify to rebase this and check the CI status... regardless I hope the ci is now fixed |
|
This pull request now has conflicts with the target branch. Could you please resolve conflicts and force push the corrected changes? 🙏 |
| cValLen C.size_t | ||
| ) | ||
|
|
||
| ret := C.rados_omap_get_next(s.iter, &cKey, &cVal, &cValLen) |
There was a problem hiding this comment.
Another remark, because you will push again anyway: we should probably use rados_omap_get_next2() here, which is more flexible about the keys (can contain 0-bytes).
There was a problem hiding this comment.
@ansiwen yeah I was thinking about which version of the function to use here, especially when rados_read_op_omap_get_keys() and rados_read_op_omap_get_vals() are tagged with __attribute__((deprecated)). However WriteOp.SetOmap() uses rados_write_op_omap_set() that expects the keys to be null-terminated:
Lines 93 to 103 in 17fbb4b
This is also true for rados_read_op_omap_get_vals_by_keys() used in this PR, so I'm not sure using rados_omap_get_next2() alone would make much difference.
So unless we use rados_read_op_omap_get_vals_by_keys2() as well, or better yet, use the *2() versions for all omap ops, it's ok as it is. What do you think?
There was a problem hiding this comment.
As you like. You are welcome to change to the *2 versions in a follow up commit. 😉
There was a problem hiding this comment.
I'd rather do it separately
There was a problem hiding this comment.
Doing it separately is A-OK with me. I highly encourage you to do it soon because I don't love the idea of adding new code based on deprecated functions (assuming I am reading this discussion correctly). I am not asking that you do it before the release, just do it before we all forget. :-)
f6952fb to
201d1db
Compare
|
This pull request now has conflicts with the target branch. Could you please resolve conflicts and force push the corrected changes? 🙏 |
|
^ I just tried to resolve the conflicts manually here on github... |
|
@Mergifyio rebase |
❌ Base branch update has failedDetailsGit reported the following error: err-code: 9C5DE |
5191df5 to
0cb61e6
Compare
|
This pull request now has conflicts with the target branch. Could you please resolve conflicts and force push the corrected changes? 🙏 |
This commit implements binding for read_op_omap_get_vals_by_keys RADOS Read operation. Includes a unit test. Signed-off-by: Robert Vasek <robert.vasek@cern.ch>
0cb61e6 to
a2b5629
Compare
ansiwen
left a comment
There was a problem hiding this comment.
LGTM 🥳 Thanks for bearing with us!
|
@phlogistonjohn can you please take a look? I believe all the comments so far have been addressed. Also, when do you roughly expect for 0.14.0 to come out? I don't have any more PRs for the time being, I'm just wondering whether to pin my go.mod dependencies to a commit, or just wait for the release if it's soon enough. Thanks! |
I will do so as soon as I can
The next release is scheduled for 2022-02-15. In general, you should be able to use the project milestones to determine when the next release(s) are going to be. I do try to keep them up to date. If it's ever missing, out of date, or confusing, feel free to ping me to get me to fix them. |
| cValLen C.size_t | ||
| ) | ||
|
|
||
| ret := C.rados_omap_get_next(s.iter, &cKey, &cVal, &cValLen) |
There was a problem hiding this comment.
Doing it separately is A-OK with me. I highly encourage you to do it soon because I don't love the idea of adding new code based on deprecated functions (assuming I am reading this discussion correctly). I am not asking that you do it before the release, just do it before we all forget. :-)
|
Thank you both for great reviews and for getting through those PRs rather fast @phlogistonjohn @ansiwen 👍 ! @phlogistonjohn thanks for the info!
AFAIK the only deprecations of concern are As for the deprecated Lines 67 to 84 in 573598c ... this is just for peace of mind that there's no actual deprecated code in use. In any case I'll send a PR to "upgrade" them all today or tomorrow. |
This PR implements binding for
read_op_omap_get_vals_by_keysRADOS Read operation.Checklist