![]() |
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
.
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.
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.
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.
Function | Description |
---|---|
as_record_set_int64() | Set the bin value to a 64-bit integer. |
as_record_set_str() | Set the bin value to a NULL-terminated string. |
as_record_set_integer() | Set the bin value to an as_integer . |
as_record_set_double() | Set the bin value to an as_double . |
as_record_set_string() | Set the bin value to an as_string . |
as_record_set_geojson() | Set the bin value to an as_geojson . |
as_record_set_bytes() | Set the bin value to an as_bytes . |
as_record_set_list() | Set the bin value to an as_list . |
as_record_set_map() | Set the bin value to an as_map . |
as_record_set_nil() | Set the bin value to an as_nil . |
as_record_set() | Set the bin value to an as_bin_value . |
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.
Function | Description |
---|---|
as_record_get_int64() | Get the bin as a 64-bit integer. |
as_record_get_str() | Get the bin as a NULL-terminated string. |
as_record_get_integer() | Get the bin as an as_integer . |
as_record_get_double() | Get the bin as an as_double . |
as_record_get_string() | Get the bin as an as_string . |
as_record_get_geojson() | Get the bin as an as_geojson . |
as_record_get_bytes() | Get the bin as an as_bytes . |
as_record_get_list() | Get the bin as an as_list . |
as_record_get_map() | Get the bin as an as_map . |
as_record_get() | Get the bin as an as_bin_value . |
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()
.
If you want to traverse the bins of a record, then you have two options:
Definition at line 166 of file as_record.h.
#include "as_record.h"
Data Fields | |
as_bins | bins |
uint16_t | gen |
as_key | key |
uint32_t | ttl |
![]() | |
void * | data |
const struct as_rec_hooks_s * | hooks |
![]() | |
uint32_t | count |
bool | free |
as_val_t | type |
Related Symbols | |
(Note that these are not member symbols.) | |
AS_EXTERN void | as_record_destroy (as_record *rec) |
AS_EXTERN bool | as_record_foreach (const as_record *rec, as_rec_foreach_callback callback, void *udata) |
static as_record * | as_record_fromval (const as_val *v) |
AS_EXTERN as_bin_value * | as_record_get (const as_record *rec, const char *name) |
AS_EXTERN as_double * | as_record_get_as_double (const as_record *rec, const char *name) |
AS_EXTERN bool | as_record_get_bool (const as_record *rec, const char *name) |
AS_EXTERN as_bytes * | as_record_get_bytes (const as_record *rec, const char *name) |
AS_EXTERN double | as_record_get_double (const as_record *rec, const char *name, double fallback) |
AS_EXTERN as_geojson * | as_record_get_geojson (const as_record *rec, const char *name) |
AS_EXTERN char * | as_record_get_geojson_str (const as_record *rec, const char *name) |
AS_EXTERN int64_t | as_record_get_int64 (const as_record *rec, const char *name, int64_t fallback) |
AS_EXTERN as_integer * | as_record_get_integer (const as_record *rec, const char *name) |
AS_EXTERN as_list * | as_record_get_list (const as_record *rec, const char *name) |
AS_EXTERN as_map * | as_record_get_map (const as_record *rec, const char *name) |
AS_EXTERN char * | as_record_get_str (const as_record *rec, const char *name) |
AS_EXTERN as_string * | as_record_get_string (const as_record *rec, const char *name) |
AS_EXTERN char * | as_record_get_udf_error (const as_record *rec) |
AS_EXTERN as_val * | as_record_get_udf_result (const as_record *rec) |
AS_EXTERN as_record * | as_record_init (as_record *rec, uint16_t nbins) |
#define | as_record_inita(__rec, __nbins) |
AS_EXTERN as_record * | as_record_new (uint16_t nbins) |
AS_EXTERN uint16_t | as_record_numbins (const as_record *rec) |
AS_EXTERN bool | as_record_set (as_record *rec, const char *name, as_bin_value *value) |
AS_EXTERN bool | as_record_set_as_double (as_record *rec, const char *name, as_double *value) |
AS_EXTERN bool | as_record_set_bool (as_record *rec, const char *name, bool value) |
AS_EXTERN bool | as_record_set_bytes (as_record *rec, const char *name, as_bytes *value) |
AS_EXTERN bool | as_record_set_double (as_record *rec, const char *name, double value) |
AS_EXTERN bool | as_record_set_geojson (as_record *rec, const char *name, as_geojson *value) |
static bool | as_record_set_geojson_str (as_record *rec, const char *name, const char *value) |
AS_EXTERN bool | as_record_set_geojson_strp (as_record *rec, const char *name, const char *value, bool free) |
AS_EXTERN bool | as_record_set_int64 (as_record *rec, const char *name, int64_t value) |
AS_EXTERN bool | as_record_set_integer (as_record *rec, const char *name, as_integer *value) |
AS_EXTERN bool | as_record_set_list (as_record *rec, const char *name, as_list *value) |
AS_EXTERN bool | as_record_set_map (as_record *rec, const char *name, as_map *value) |
AS_EXTERN bool | as_record_set_nil (as_record *rec, const char *name) |
static bool | as_record_set_raw (as_record *rec, const char *name, const uint8_t *value, uint32_t size) |
AS_EXTERN bool | as_record_set_raw_typep (as_record *rec, const char *name, const uint8_t *value, uint32_t size, as_bytes_type type, bool free) |
AS_EXTERN bool | as_record_set_rawp (as_record *rec, const char *name, const uint8_t *value, uint32_t size, bool free) |
static bool | as_record_set_str (as_record *rec, const char *name, const char *value) |
AS_EXTERN bool | as_record_set_string (as_record *rec, const char *name, as_string *value) |
AS_EXTERN bool | as_record_set_strp (as_record *rec, const char *name, const char *value, bool free) |
static as_val * | as_record_toval (const as_record *rec) |
![]() | |
static int | as_rec_bin_names (const as_rec *rec, as_rec_bin_names_callback callback, void *udata) |
AS_EXTERN as_rec * | as_rec_cons (as_rec *rec, bool free, void *data, const as_rec_hooks *hooks) |
static void | as_rec_destroy (as_rec *rec) |
static uint32_t | as_rec_device_size (const as_rec *rec) |
static as_bytes * | as_rec_digest (const as_rec *rec) |
static int | as_rec_drop_key (const as_rec *rec) |
static bool | as_rec_foreach (const as_rec *rec, as_rec_foreach_callback callback, void *udata) |
static as_rec * | as_rec_fromval (const as_val *v) |
static uint16_t | as_rec_gen (const as_rec *rec) |
static as_val * | as_rec_get (const as_rec *rec, const char *name) |
static as_double * | as_rec_get_as_double (const as_rec *rec, const char *name) |
static as_bytes * | as_rec_get_bytes (const as_rec *rec, const char *name) |
static double | as_rec_get_double (const as_rec *rec, const char *name) |
static as_geojson * | as_rec_get_geojson (const as_rec *rec, const char *name) |
static char * | as_rec_get_geojson_str (const as_rec *rec, const char *name) |
static int64_t | as_rec_get_int64 (const as_rec *rec, const char *name) |
static as_integer * | as_rec_get_integer (const as_rec *rec, const char *name) |
static as_list * | as_rec_get_list (const as_rec *rec, const char *name) |
static as_map * | as_rec_get_map (const as_rec *rec, const char *name) |
static char * | as_rec_get_str (const as_rec *rec, const char *name) |
static as_string * | as_rec_get_string (const as_rec *rec, const char *name) |
AS_EXTERN as_rec * | as_rec_init (as_rec *rec, void *data, const as_rec_hooks *hooks) |
static as_val * | as_rec_key (const as_rec *rec) |
static uint64_t | as_rec_last_update_time (const as_rec *rec) |
static uint32_t | as_rec_memory_size (const as_rec *rec) |
AS_EXTERN as_rec * | as_rec_new (void *data, const as_rec_hooks *hooks) |
static uint16_t | as_rec_numbins (const as_rec *rec) |
static int | as_rec_remove (const as_rec *rec, const char *name) |
static int | as_rec_set (const as_rec *rec, const char *name, const as_val *value) |
static int | as_rec_set_as_double (const as_rec *rec, const char *name, const as_double *value) |
static int | as_rec_set_bytes (const as_rec *rec, const char *name, const as_bytes *value) |
static int | as_rec_set_double (const as_rec *rec, const char *name, double value) |
static int | as_rec_set_geojson (const as_rec *rec, const char *name, const as_geojson *value) |
static int | as_rec_set_int64 (const as_rec *rec, const char *name, int64_t value) |
static int | as_rec_set_integer (const as_rec *rec, const char *name, const as_integer *value) |
static int | as_rec_set_list (const as_rec *rec, const char *name, const as_list *value) |
static int | as_rec_set_map (const as_rec *rec, const char *name, const as_map *value) |
static int | as_rec_set_str (const as_rec *rec, const char *name, const char *value) |
static int | as_rec_set_string (const as_rec *rec, const char *name, const as_string *value) |
static int | as_rec_set_ttl (const as_rec *rec, uint32_t ttl) |
static const char * | as_rec_setname (const as_rec *rec) |
static uint32_t | as_rec_size (const as_rec *rec) |
static void * | as_rec_source (const as_rec *rec) |
static as_val * | as_rec_toval (const as_rec *rec) |
static uint32_t | as_rec_ttl (const as_rec *rec) |
Destroy the as_record and associated resources.
rec | The record to destroy. |
|
related |
Iterate over each bin in the record and invoke the callback function.
If the callback returns true, then iteration will continue to the next bin. Otherwise, the iteration will halt and as_record_foreach()
will return false.
rec | The record containing the bins to iterate over. |
callback | The callback to invoke for each bin. |
udata | User-data provided for the callback. |
Convert from an as_val.
Definition at line 1000 of file as_record.h.
References AS_REC, and as_util_fromval.
|
related |
Get specified bin's value.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as an as_double.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as a bool.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as an as_bytes.
rec | The record containing the bin. |
name | The name of the bin. |
|
related |
Get specified bin's value as a double.
rec | The record containing the bin. |
name | The name of the bin. |
fallback | The default value to use, if the bin doesn't exist or is not an integer. |
|
related |
Get specified bin's value as an as_geojson.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as an NULL terminated GeoJSON string.
rec | The record containing the bin. |
name | The name of the bin. |
|
related |
Get specified bin's value as an int64_t.
rec | The record containing the bin. |
name | The name of the bin. |
fallback | The default value to use, if the bin doesn't exist or is not an integer. |
|
related |
Get specified bin's value as an as_integer.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as an as_list.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as an as_map.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as an NULL terminated string.
rec | The record containing the bin. |
name | The name of the bin. |
Get specified bin's value as an as_string.
rec | The record containing the bin. |
name | The name of the bin. |
Get the error string returned by a UDF apply in a batch. Return null if an error did not occur.
Get the value returned by a UDF apply in a batch. The result may be null.
Initializes an as_record created on the stack.
When you are finished using the as_record
instance, you should release the resources allocated to it by calling as_record_destroy()
.
rec | The record to initialize. |
nbins | The number of bins to initialize. |
|
related |
Initialize a stack allocated as_record
then allocate __nbins
capacity for as_record.bins on the stack.
When you are finished using the as_record
instance, you should release the resources allocated to it by calling as_record_destroy()
.
__rec | The as_record * to initialize. |
__nbins | The number of as_record.bins.entries to allocate on the stack. |
Definition at line 254 of file as_record.h.
Create a new as_record on the heap.
When you are finished using the as_record
instance, you should release the resources allocated to it by calling as_record_destroy()
.
nbins | The number of bins to initialize. |
Get the number of bins in the record.
|
related |
Set specified bin's value to an as_bin_value.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. |
|
related |
Set specified bin's value to an as_double.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
Set specified bin's value to a bool. Requires server version 5.6.0+.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. |
Set specified bin's value to an as_bytes.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
Set specified bin's value to a double.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. |
|
related |
Set specified bin's value to an as_geojson.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
|
related |
Set specified bin's value to an NULL terminated GeoJSON string.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
Definition at line 473 of file as_record.h.
|
related |
Set specified bin's value to an NULL terminated GeoJSON string.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
free | If true, then the value will be freed when the record is destroyed. |
Set specified bin's value to an int64_t.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. |
|
related |
Set specified bin's value to an as_integer.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
Set specified bin's value to an as_list.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
Set specified bin's value to an as_map.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
Set specified bin's value to as_nil.
rec | The record containing the bin. |
name | The name of the bin. |
|
related |
Set specified bin's value to an NULL terminated string.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
size | The size of the value. |
Definition at line 547 of file as_record.h.
|
related |
Set specified bin's value to an as_bytes value of a specified type.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
size | The size of the value. |
type | The as_bytes_type designation (AS_BYTES_*) |
free | If true, then the value will be freed when the record is destroyed. |
|
related |
Set specified bin's value to an NULL terminated string.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
size | The size of the value. |
free | If true, then the value will be freed when the record is destroyed. |
|
related |
Set specified bin's value to an NULL terminated string.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
Definition at line 433 of file as_record.h.
|
related |
Set specified bin's value to an as_string.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
|
related |
Set specified bin's value to an NULL terminated string.
rec | The record containing the bin. |
name | The name of the bin. |
value | The value of the bin. Must be in scope for the lifetime of the record. |
free | If true, then the value will be freed when the record is destroyed. |
Convert to an as_val.
Definition at line 990 of file as_record.h.
as_bins as_record::bins |
The bins of the record.
Definition at line 203 of file as_record.h.
uint16_t as_record::gen |
The generation of the record.
Definition at line 185 of file as_record.h.
as_key as_record::key |
The key of the record. This is only populated on records returned from a scan or secondary index query. This should not be set by the user.
Definition at line 180 of file as_record.h.
uint32_t as_record::ttl |
The time-to-live (expiration) of the record in seconds.
There are also special values that can be set in the record ttl:
Definition at line 198 of file as_record.h.