KV().GetWithParam#

static inline std::vector<std::shared_ptr<YR::Buffer>> YR::KVManager::GetWithParam(const std::vector<std::string> &keys, const YR::GetParams &params, int timeout = DEFAULT_GET_TIMEOUT_SEC)#

Retrieves multiple values associated with specified keys with additional parameters, supporting offset-based reading.

This function fetches values stored under the specified keys, allowing for partial data retrieval based on specified offsets and sizes. If any key does not exist or the operation times out, an exception is thrown unless allowPartial is set to true.

int main() {
    YR::Config conf;
    conf.mode = Config::Mode::CLUSTER_MODE;
    YR::Init(conf);
    std::string key = "kv-id-888";
    YR::KV().Del(key);
    std::string value = "kv-id-888wqdq";
    YR::KV().Set(key, value);
    YR::GetParam param = { .offset = 0, .size = 0 };
    YR::GetParams params;
    params.getParams.emplace_back(param);
    std::vector<std::shared_ptr<YR::Buffer>> res = YR::KV().GetWithParam({ key }, params);
    return 0;
}

Parameters:
  • keys – A list of keys to retrieve values for. The maximum number of keys is 10000.

  • params – A structure containing parameters for the get operation, including offset, size, and traceId for each key.

  • timeout – The maximum time in seconds to wait for the values to be retrieved. The default value is 300 seconds. Setting to -1 waits indefinitely.

Throws:

YR::Exception – Thrown in the following cases:

  • 1001: Invalid input parameters (e.g., empty keys, mismatched sizes, or invalid characters).

  • 4005: Get operation failed (e.g., key not found or timeout exceeded).

  • 4201: RocksDB error (e.g., disk issues).

  • 4202: Shared memory limit exceeded.

  • 4203: Disk operation failed (e.g., permission issues).

  • 4204: Disk space full.

  • 1000, 1001, 1002: Internal communication errors.

Returns:

std::vector<std::shared_ptr<YR::Buffer>>, A vector containing the retrieved data. The order of results corresponds to the order of keys. Failed keys have empty pointers.

struct GetParam#

Specifies parameters for a query key.

Public Members

uint64_t offset#

The offset specifies the starting position of the data to be retrieved.

uint64_t size#

The size specifies the number of elements or the amount of data to retrieve.

The parameter structure is supplemented with the following explanation:

struct GetParams#

Specifies parameters for a set of query keys.

Public Members

std::vector<GetParam> getParams#

A vector containing multiple GetParam objects.

std::string traceId#

A trace ID used for tracking and identifying specific requests.