Records in Aerospike are collections of named bins.
The bins in a record are analogous to columns in relational databases. However, unlike columns, the bins themselves are not typed. Instead, bins contain values which are typed. So, it is possible to have multiple records with bins of the same name but different types for values.
The bin's value can only be of the types defined in as_bin_value
.
Initialization
There are several ways to initialize an as_record
.
You can create the as_record
on the stack:
Then initialize it using either the as_record_init()
function or as_record_inita()
macro.
The as_record_init()
function will initialize the variable, then allocate the specified number of bins using malloc()
. The following initializes rec
with 2 bins.
The as_record_inita()
macro will initialize the variable, then allocate the specified number of bins using alloca()
. The following initializes rec
with 2 bins.
The as_record_new()
function will allocate an as_record
on the heap using malloc()
then allocate the specified number of bins using malloc()
. The following creates a new as_record
with 2 bins.
Destruction
When you no longer require an as_record, you should call as_record_destroy()
to release the record and associated resources.
If the record has been ref-counted, then the ref-count will be decremented, until it reaches 0 (zero), at which point, the record will be released.
Setting Bin Values
The following are functions for setting values in bins of a record. Utilize the appropriate setter for the data you want to store in a bin.
Getting Bin Values
The following are functions for getting values from bins of a record. Utilize the appropriate getter for the data you want to read from a bin.
If you are unsure of the type of data stored in the bin, then you should use as_record_get()
. You can then check the type of the value using as_val_type()
.
Traversing Bins
If you want to traverse the bins of a record, then you have two options:
Definition at line 164 of file src/include/aerospike/as_record.h.
|
(Note that these are not member functions.)
|
void | as_record_destroy (as_record *rec) |
|
bool | as_record_foreach (const as_record *rec, as_rec_foreach_callback callback, void *udata) |
|
as_record * | as_record_fromval (const as_val *v) |
|
as_bin_value * | as_record_get (const as_record *rec, const as_bin_name name) |
|
as_bytes * | as_record_get_bytes (const as_record *rec, const as_bin_name name) |
|
int64_t | as_record_get_int64 (const as_record *rec, const as_bin_name name, int64_t fallback) |
|
as_integer * | as_record_get_integer (const as_record *rec, const as_bin_name name) |
|
as_list * | as_record_get_list (const as_record *rec, const as_bin_name name) |
|
as_map * | as_record_get_map (const as_record *rec, const as_bin_name name) |
|
char * | as_record_get_str (const as_record *rec, const as_bin_name name) |
|
as_string * | as_record_get_string (const as_record *rec, const as_bin_name name) |
|
as_record * | as_record_init (as_record *rec, uint16_t nbins) |
|
#define | as_record_inita(__rec, __nbins) |
|
as_record * | as_record_new (uint16_t nbins) |
|
uint16_t | as_record_numbins (const as_record *rec) |
|
bool | as_record_set (as_record *rec, const as_bin_name name, as_bin_value *value) |
|
bool | as_record_set_bytes (as_record *rec, const as_bin_name name, as_bytes *value) |
|
bool | as_record_set_int64 (as_record *rec, const as_bin_name name, int64_t value) |
|
bool | as_record_set_integer (as_record *rec, const as_bin_name name, as_integer *value) |
|
bool | as_record_set_list (as_record *rec, const as_bin_name name, as_list *value) |
|
bool | as_record_set_map (as_record *rec, const as_bin_name name, as_map *value) |
|
bool | as_record_set_nil (as_record *rec, const as_bin_name name) |
|
bool | as_record_set_raw (as_record *rec, const as_bin_name name, const uint8_t *value, uint32_t size) |
|
bool | as_record_set_rawp (as_record *rec, const as_bin_name name, const uint8_t *value, uint32_t size, bool free) |
|
bool | as_record_set_str (as_record *rec, const as_bin_name name, const char *value) |
|
bool | as_record_set_string (as_record *rec, const as_bin_name name, as_string *value) |
|
bool | as_record_set_strp (as_record *rec, const as_bin_name name, const char *value, bool free) |
|
as_val * | as_record_toval (const as_record *rec) |
|
as_rec * | as_rec_cons (as_rec *rec, bool free, void *data, const as_rec_hooks *hooks) |
|
void | as_rec_destroy (as_rec *rec) |
|
as_bytes * | as_rec_digest (const as_rec *rec) |
|
bool | as_rec_foreach (const as_rec *rec, as_rec_foreach_callback callback, void *udata) |
|
as_rec * | as_rec_fromval (const as_val *v) |
|
uint16_t | as_rec_gen (const as_rec *rec) |
|
as_val * | as_rec_get (const as_rec *rec, const char *name) |
|
as_bytes * | as_rec_get_bytes (const as_rec *rec, const char *name) |
|
int64_t | as_rec_get_int64 (const as_rec *rec, const char *name) |
|
as_integer * | as_rec_get_integer (const as_rec *rec, const char *name) |
|
as_list * | as_rec_get_list (const as_rec *rec, const char *name) |
|
as_map * | as_rec_get_map (const as_rec *rec, const char *name) |
|
char * | as_rec_get_str (const as_rec *rec, const char *name) |
|
as_string * | as_rec_get_string (const as_rec *rec, const char *name) |
|
as_rec * | as_rec_init (as_rec *rec, void *data, const as_rec_hooks *hooks) |
|
as_rec * | as_rec_new (void *data, const as_rec_hooks *hooks) |
|
uint16_t | as_rec_numbins (const as_rec *rec) |
|
int | as_rec_remove (const as_rec *rec, const char *name) |
|
int | as_rec_set (const as_rec *rec, const char *name, const as_val *value) |
|
int | as_rec_set_bytes (const as_rec *rec, const char *name, const as_bytes *value) |
|
int | as_rec_set_flags (const as_rec *rec, const char *name, uint8_t flags) |
|
int | as_rec_set_int64 (const as_rec *rec, const char *name, int64_t value) |
|
int | as_rec_set_integer (const as_rec *rec, const char *name, const as_integer *value) |
|
int | as_rec_set_list (const as_rec *rec, const char *name, const as_list *value) |
|
int | as_rec_set_map (const as_rec *rec, const char *name, const as_map *value) |
|
int | as_rec_set_str (const as_rec *rec, const char *name, const char *value) |
|
int | as_rec_set_string (const as_rec *rec, const char *name, const as_string *value) |
|
int | as_rec_set_type (const as_rec *rec, uint8_t rec_type) |
|
void * | as_rec_source (const as_rec *rec) |
|
as_val * | as_rec_toval (const as_rec *rec) |
|
uint32_t | as_rec_ttl (const as_rec *rec) |
|