|
Apache OpenDALâ„¢ C Binding
The C binding for Apache OpenDALâ„¢
|
Options for read operations. More...
#include <opendal.h>
Public Attributes | |
| uint64_t | offset |
| bool | has_length |
| uint64_t | length |
| const char * | version |
| const char * | if_match |
| const char * | if_none_match |
| bool | has_if_modified_since |
| int64_t | if_modified_since |
| bool | has_if_unmodified_since |
| int64_t | if_unmodified_since |
| uintptr_t | concurrent |
| bool | has_chunk |
| uintptr_t | chunk |
| bool | has_gap |
| uintptr_t | gap |
| bool | has_content_length_hint |
| uint64_t | content_length_hint |
| const char * | override_content_type |
| const char * | override_cache_control |
| const char * | override_content_disposition |
Options for read operations.
Each condition checks the file being read, and every condition must hold for the read to proceed. Once the option and capability checks pass, a read that reaches storage fails with OPENDAL_NOT_FOUND for a missing file, no matter which conditions are set. An existing file that fails a condition returns OPENDAL_CONDITION_NOT_MATCH, and a condition the service does not advertise through its capability returns OPENDAL_UNSUPPORTED; OpenDAL never silently drops a condition. A read with an empty range, such as one that opendal_read_options_set_range(opts, offset, 0) sets, validates the read options and capabilities, then returns an empty buffer without accessing storage or evaluating conditions against the file.
See the conditional operation specification for the complete cross-operation contract.
Use opendal_read_options_new() to construct and opendal_read_options_free() to free.
A caller that declares the struct itself must initialize every member, for example with opendal_read_options opts = {0};, because a function that takes these options reads every member, also one whose has_* member is false.
| uintptr_t opendal_read_options::chunk |
Set chunk for the operation.
By default, OpenDAL reads the range with a single request instead of in chunks. Users can set chunk based on their own needs. 0 has the same behavior as leaving it unset.
A read with a positive chunk and an open-ended range, such as no range or one that opendal_read_options_set_range_from() sets, first stats the file to learn its length, unless content_length_hint is set. That stat carries the read's version and conditions, so each of them also needs its stat capability, such as opendal_capability.stat_with_if_modified_since for if_modified_since; otherwise the read returns OPENDAL_UNSUPPORTED.
has_chunk controls whether this value applies.
| uintptr_t opendal_read_options::concurrent |
Set concurrent for the operation.
OpenDAL reads a file without concurrency by default. This is not efficient for cases when users read large chunks of data. By setting concurrent together with chunk, opendal will read files concurrently on supported storage services.
By setting concurrent, opendal will fetch chunks concurrently with the given chunk size. Without chunk, OpenDAL does not read concurrently. 0 has the same behavior as 1.
0 is the default.
| uint64_t opendal_read_options::content_length_hint |
Known content length of the object.
This is an execution hint that allows OpenDAL to avoid extra metadata requests while planning reads. It must not be used as an object identity or consistency condition.
has_content_length_hint controls whether this value applies.
| uintptr_t opendal_read_options::gap |
| bool opendal_read_options::has_chunk |
Whether chunk has been set.
| bool opendal_read_options::has_content_length_hint |
Whether content_length_hint has been set.
| bool opendal_read_options::has_gap |
Whether gap has been set.
| bool opendal_read_options::has_if_modified_since |
Whether if_modified_since has been set.
| bool opendal_read_options::has_if_unmodified_since |
Whether if_unmodified_since has been set.
| bool opendal_read_options::has_length |
Whether length has been set. Without it, the read continues to the end of the file.
| const char* opendal_read_options::if_match |
Read only when the file has this exact ETag.
The condition succeeds when the file exists and its ETag equals this value. A file with a different ETag returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.
The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_match.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_read_options_set_if_match() stores this pointer without copying the string, and opendal_read_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| int64_t opendal_read_options::if_modified_since |
Read only when the file was modified after this timestamp.
The condition succeeds when the file exists and was modified after this time. A file not modified since this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.
The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_modified_since.
Milliseconds since the Unix epoch. has_if_modified_since controls whether this value applies. When it applies, a value out of range fails the operation with OPENDAL_CONFIG_INVALID.
| const char* opendal_read_options::if_none_match |
Read only when the file does not have this ETag.
With a concrete ETag value, the condition succeeds when the file exists with a different ETag. A file whose ETag equals this value returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND. Only concrete ETag values are portable; a wildcard such as "*" has no portable meaning here.
The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_none_match.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_read_options_set_if_none_match() stores this pointer without copying the string, and opendal_read_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| int64_t opendal_read_options::if_unmodified_since |
Read only when the file was not modified after this timestamp.
The condition succeeds when the file exists and was not modified after this time. A file modified after this time returns OPENDAL_CONDITION_NOT_MATCH; a missing file returns OPENDAL_NOT_FOUND.
The operation returns OPENDAL_UNSUPPORTED when the service does not advertise opendal_capability.read_with_if_unmodified_since.
Milliseconds since the Unix epoch. has_if_unmodified_since controls whether this value applies. When it applies, a value out of range fails the operation with OPENDAL_CONFIG_INVALID.
| uint64_t opendal_read_options::length |
| uint64_t opendal_read_options::offset |
Read from this byte offset instead of from the start of the file.
An offset at or beyond the end of the file can return an empty buffer or fail the read, depending on the service and on chunk.
| const char* opendal_read_options::override_cache_control |
Request a cache-control response header override from services that support it, including for presigned read requests.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_read_options_set_override_cache_control() stores this pointer without copying the string, and opendal_read_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| const char* opendal_read_options::override_content_disposition |
Request a content-disposition response header override from services that support it, including for presigned read requests.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_read_options_set_override_content_disposition() stores this pointer without copying the string, and opendal_read_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| const char* opendal_read_options::override_content_type |
Request a content-type response header override from services that support it, including for presigned read requests.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_read_options_set_override_content_type() stores this pointer without copying the string, and opendal_read_options_free() does not free it, so the string must stay valid until the function that takes these options returns.
| const char* opendal_read_options::version |
Read the given version of the file instead of the current one.
This selects which stored version the read returns; it is not a condition on the file. A version that does not exist returns OPENDAL_NOT_FOUND.
Check opendal_capability.read_with_version before using this option.
NULL means unset. A non-NULL value must point to a readable, nul-terminated UTF-8 string. opendal_read_options_set_version() stores this pointer without copying the string, and opendal_read_options_free() does not free it, so the string must stay valid until the function that takes these options returns.