All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Typedefs | Functions
Batch Operations

Description

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.

+ Collaboration diagram for Batch Operations:

Typedefs

typedef bool(* aerospike_batch_read_callback )(const as_batch_read *results, uint32_t n, void *udata)
 

Functions

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)
 

Typedef Documentation

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
resultsThe results from the batch request.
nThe number of results from the batch request.
udataUser-data provided to the calling function.
Returns
true on success. Otherwise, an error occurred.

Definition at line 71 of file aerospike_batch.h.

Function Documentation

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 
)

Test whether multiple records exist in the cluster.

as_batch batch;
as_batch_inita(&batch, 3);
as_key_init(as_batch_keyat(&batch,0), "ns", "set", "key1");
as_key_init(as_batch_keyat(&batch,1), "ns", "set", "key2");
as_key_init(as_batch_keyat(&batch,2), "ns", "set", "key3");
if ( aerospike_batch_exists(&as, &err, NULL, &batch, callback, NULL) != AEROSPIKE_OK ) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
batchThe batch of keys to read.
callbackThe callback to invoke for each record read.
udataThe user-data for the callback.
Returns
AEROSPIKE_OK if successful. Otherwise an error.
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 
)

Look up multiple records by key, then return all bins.

as_batch batch;
as_batch_inita(&batch, 3);
as_key_init(as_batch_keyat(&batch,0), "ns", "set", "key1");
as_key_init(as_batch_keyat(&batch,1), "ns", "set", "key2");
as_key_init(as_batch_keyat(&batch,2), "ns", "set", "key3");
if ( aerospike_batch_get(&as, &err, NULL, &batch, callback, NULL) != AEROSPIKE_OK ) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
batchThe batch of keys to read.
callbackThe callback to invoke for each record read.
udataThe user-data for the callback.
Returns
AEROSPIKE_OK if successful. Otherwise an error.
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 
)

Look up multiple records by key, then return specified bins.

as_batch batch;
as_batch_inita(&batch, 3);
as_key_init(as_batch_keyat(&batch,0), "ns", "set", "key1");
as_key_init(as_batch_keyat(&batch,1), "ns", "set", "key2");
as_key_init(as_batch_keyat(&batch,2), "ns", "set", "key3");
const char* bin_filters[] = {"bin1", "bin2"};
if ( aerospike_batch_get_bins(&as, &err, NULL, &batch, bin_filters, 2, callback, NULL) != AEROSPIKE_OK ) {
fprintf(stderr, "error(%d) %s at [%s:%d]", err.code, err.message, err.file, err.line);
}
Parameters
asThe aerospike instance to use for this operation.
errThe as_error to be populated if an error occurs.
policyThe policy to use for this operation. If NULL, then the default policy will be used.
batchThe batch of keys to read.
binsBin filters. Only return these bins.
n_binsThe number of bin filters.
callbackThe callback to invoke for each record read.
udataThe user-data for the callback.
Returns
AEROSPIKE_OK if successful. Otherwise an error.