Aerospike provides a batch API to access data in the cluster.
The Batch API is a collection of APIs that use as_keyset as for looking up records for accessing in the cluster.
|
as_status | aerospike_batch_exists (aerospike *as, as_error *err, const as_policy_batch *policy, const as_batch *batch, aerospike_batch_read_callback callback, void *udata) |
|
as_status | aerospike_batch_get (aerospike *as, as_error *err, const as_policy_batch *policy, const as_batch *batch, aerospike_batch_read_callback callback, void *udata) |
|
as_status | aerospike_batch_get_bins (aerospike *as, as_error *err, const as_policy_batch *policy, const as_batch *batch, const char **bins, uint32_t n_bins, aerospike_batch_read_callback callback, void *udata) |
|
as_status | aerospike_batch_read (aerospike *as, as_error *err, const as_policy_batch *policy, as_batch_read_records *records) |
|
void | as_batch_read_destroy (as_batch_read_records *records) |
|
static void | as_batch_read_init (as_batch_read_records *records, uint32_t capacity) |
|
static as_batch_read_record * | as_batch_read_reserve (as_batch_read_records *records) |
|
typedef bool(* aerospike_batch_read_callback)(const as_batch_read *results, uint32_t n, void *udata) |
This callback will be called with the results of aerospike_batch_get(), or aerospike_batch_exists() functions.
The results
argument will be an array of n
as_batch_read entries. The results
argument is on the stack and is only available within the context of the callback. To use the data outside of the callback, copy the data.
bool my_callback(
const as_batch_read * results, uint32_t n,
void * udata) {
return true;
}
- Parameters
-
results | The results from the batch request. |
n | The number of results from the batch request. |
udata | User-data provided to the calling function. |
- Returns
true
on success. Otherwise, an error occurred.
Definition at line 134 of file aerospike_batch.h.
Test whether multiple records exist in the cluster.
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
batch | The batch of keys to read. |
callback | The callback to invoke for each record read. |
udata | The user-data for the callback. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Look up multiple records by key, then return all bins.
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
batch | The batch of keys to read. |
callback | The callback to invoke for each record read. |
udata | The user-data for the callback. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Look up multiple records by key, then return specified bins.
const char* bin_filters[] = {"bin1", "bin2"};
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
batch | The batch of keys to read. |
bins | Bin filters. Only return these bins. |
n_bins | The number of bin filters. |
callback | The callback to invoke for each record read. |
udata | The user-data for the callback. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Read multiple records for specified batch keys in one batch call. This method allows different namespaces/bins to be requested for each key in the batch. The returned records are located in the same batch array. This method requires Aerospike Server version >= 3.5.15.
char* bin_names[] = {"bin1", "bin2"};
char* set = "set";
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
- Parameters
-
as | The aerospike instance to use for this operation. |
err | The as_error to be populated if an error occurs. |
policy | The policy to use for this operation. If NULL, then the default policy will be used. |
records | List of keys and bins to retrieve. The returned records are located in the same array. |
- Returns
- AEROSPIKE_OK if successful. Otherwise an error.
Destroy keys and records in record list. It's the responsility of the caller to free as_batch_read_record.bin_names
when necessary.
- Parameters
-
records | Batch record list. |