-
Notifications
You must be signed in to change notification settings - Fork 91
rdma: expose ranged GET through the C ABI #258
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
|
|
||
| #include <unistd.h> | ||
|
|
||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <cstring> | ||
| #include <istream> | ||
|
|
@@ -145,9 +146,14 @@ ssize_t miniocpp_put_object(miniocpp_client* c, const char* bucket, | |
| return static_cast<ssize_t>(size); | ||
| } | ||
|
|
||
| ssize_t miniocpp_get_object(miniocpp_client* c, const char* bucket, | ||
| const char* object, void* buf, size_t size, | ||
| miniocpp_write_cb write_cb, void* userdata) { | ||
| namespace { | ||
|
|
||
| // Body shared by miniocpp_get_object and miniocpp_get_object_range. | ||
| // `offset` < 0 reads the whole object; >= 0 selects a byte range. | ||
| ssize_t GetObjectImpl(miniocpp_client* c, const char* bucket, | ||
| const char* object, void* buf, size_t size, | ||
| miniocpp_write_cb write_cb, void* userdata, | ||
| int64_t offset) { | ||
|
Comment on lines
+151
to
+156
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift Return the actual transferred byte count. The shared buffer GET path currently reports the requested 📍 Affects 1 file
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| if (c == nullptr || bucket == nullptr || object == nullptr) { | ||
| SetLastError("client, bucket, object are required"); | ||
| return MINIOCPP_ERR_INVALID_ARG; | ||
|
|
@@ -162,6 +168,7 @@ ssize_t miniocpp_get_object(miniocpp_client* c, const char* bucket, | |
| args.bucket = bucket; | ||
| args.object = object; | ||
| args.region = holder->base_url.region; | ||
| if (offset >= 0) args.offset = static_cast<size_t>(offset); | ||
|
|
||
| ssize_t bytes_seen = 0; | ||
|
|
||
|
|
@@ -186,6 +193,31 @@ ssize_t miniocpp_get_object(miniocpp_client* c, const char* bucket, | |
| return buf != nullptr ? static_cast<ssize_t>(size) : bytes_seen; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| ssize_t miniocpp_get_object(miniocpp_client* c, const char* bucket, | ||
| const char* object, void* buf, size_t size, | ||
| miniocpp_write_cb write_cb, void* userdata) { | ||
| return GetObjectImpl(c, bucket, object, buf, size, write_cb, userdata, -1); | ||
| } | ||
|
|
||
| ssize_t miniocpp_get_object_range(miniocpp_client* c, const char* bucket, | ||
| const char* object, void* buf, size_t size, | ||
| uint64_t offset) { | ||
| if (buf == nullptr) { | ||
| SetLastError("buf is required for a ranged get"); | ||
| return MINIOCPP_ERR_INVALID_ARG; | ||
| } | ||
| // GetObjectArgs::offset is a size_t and the range header is built from a | ||
| // signed value; refuse anything that would not survive the round trip. | ||
| if (offset > static_cast<uint64_t>(INT64_MAX)) { | ||
| SetLastError("offset out of range"); | ||
| return MINIOCPP_ERR_INVALID_ARG; | ||
| } | ||
| return GetObjectImpl(c, bucket, object, buf, size, nullptr, nullptr, | ||
| static_cast<int64_t>(offset)); | ||
| } | ||
|
|
||
| void* miniocpp_alloc_aligned(size_t size) { | ||
| void* p = nullptr; | ||
| if (posix_memalign(&p, static_cast<size_t>(getpagesize()), size) != 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.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the public API documentation.
The sentence
Two things that needs:is incomplete. Replace it withThis API supports two use cases:.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents