![]() |
A key is used for locating records in the database.
A key can either be stack or heap allocated. Use one of the following functions to properly initialize an as_key.
Each function requires a namespace, set and key value. The set can be and empty string.
For stack allocated as_key, you should you the following functions to initialize the value:
For heap allocated as_key, you should use the following functions to allocate and initialize the value on the heap.
When you no longer require an instance of as_key, you should release the key and associated resources via as_key_destroy().
This function should be used on both stack and heap allocated keys.
The following are operations which require a key.
Each operation that requires a key, internally generates a digest for the key. The digest is a hash value used to locate a record in the cluster. Once calculated, the digest will be reused.
To get the digest value of a key, use as_key_digest().
#include "as_key.h"
Data Fields | |
as_digest | digest |
as_namespace | ns |
as_set | set |
as_key_value | value |
as_key_value * | valuep |
Related Symbols | |
(Note that these are not member symbols.) | |
AS_EXTERN void | as_key_destroy (as_key *key) |
AS_EXTERN as_digest * | as_key_digest (as_key *key) |
AS_EXTERN as_key * | as_key_init (as_key *key, const char *ns, const char *set, const char *value) |
AS_EXTERN as_key * | as_key_init_digest (as_key *key, const char *ns, const char *set, const as_digest_value digest) |
AS_EXTERN as_key * | as_key_init_int64 (as_key *key, const char *ns, const char *set, int64_t value) |
static as_key * | as_key_init_raw (as_key *key, const char *ns, const char *set, const uint8_t *value, uint32_t size) |
AS_EXTERN as_key * | as_key_init_rawp (as_key *key, const char *ns, const char *set, const uint8_t *value, uint32_t size, bool free) |
static as_key * | as_key_init_str (as_key *key, const char *ns, const char *set, const char *value) |
AS_EXTERN as_key * | as_key_init_strp (as_key *key, const char *ns, const char *set, const char *value, bool free) |
AS_EXTERN as_key * | as_key_init_value (as_key *key, const char *ns, const char *set, const as_key_value *value) |
AS_EXTERN as_key * | as_key_new (const char *ns, const char *set, const char *value) |
AS_EXTERN as_key * | as_key_new_digest (const char *ns, const char *set, const as_digest_value digest) |
AS_EXTERN as_key * | as_key_new_int64 (const char *ns, const char *set, int64_t value) |
static as_key * | as_key_new_raw (const char *ns, const char *set, const uint8_t *value, uint32_t size) |
AS_EXTERN as_key * | as_key_new_rawp (const char *ns, const char *set, const uint8_t *value, uint32_t size, bool free) |
static as_key * | as_key_new_str (const char *ns, const char *set, const char *value) |
AS_EXTERN as_key * | as_key_new_strp (const char *ns, const char *set, const char *value, bool free) |
AS_EXTERN as_key * | as_key_new_value (const char *ns, const char *set, const as_key_value *value) |
AS_EXTERN as_status | as_key_set_digest (as_error *err, as_key *key) |
Get the digest for the given key.
The digest is computed the first time function is called. Subsequent calls will return the previously calculated value.
key | The key to get the digest for. |
|
related |
Initialize a stack allocated as_key to a NULL-terminated string value.
Use as_key_destroy() to release resources allocated to as_key via this function.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
|
related |
Initialize a stack allocated as_key with a digest.
Use as_key_destroy() to release resources allocated to as_key.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
digest | The digest for the key. |
|
related |
Initialize a stack allocated as_key to a int64_t value.
Use as_key_destroy() to release resources allocated to as_key.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
|
related |
Initialize a stack allocated as_key to bytes array.
Use as_key_destroy() to release resources allocated to as_key.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
size | The number of bytes in value. Must last for the lifetime of the key. |
|
related |
Initialize a stack allocated as_key to bytes array.
Use as_key_destroy() to release resources allocated to as_key.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
size | The number of bytes in value. |
free | If true, then the key's value can be freed when the key is destroyed. |
|
related |
Initialize a stack allocated as_key to a NULL-terminated string value.
Use as_key_destroy() to release resources allocated to as_key.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. Must last for the lifetime of the key. |
|
related |
Initialize a stack allocated as_key to a NULL-terminated string value.
Use as_key_destroy() to release resources allocated to as_key.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
free | If true, then the key's value can be freed when the key is destroyed. |
|
related |
Initialize a stack allocated as_key to an as_key_value.
Use as_key_destroy() to release resources allocated to as_key.
key | The key to initialize. |
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
Creates and initializes a heap allocated as_key to a NULL-terminated string value.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
|
related |
Creates and initializes a heap allocated as_key with a digest.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
digest | The key's digest. |
Creates and initializes a heap allocated as_key to a int64_t value.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
|
related |
Creates and initializes a heap allocated as_key to a byte array.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. Must last for the lifetime of the key. |
size | The number of bytes in the value. |
|
related |
Creates and initializes a heap allocated as_key to a byte array.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
size | The number of bytes in the value. |
free | If true, then the key's value can be freed when the key is destroyed. |
|
related |
Creates and initializes a heap allocated as_key to a NULL-terminated string value.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. Must last for the lifetime of the key. |
|
related |
Creates and initializes a heap allocated as_key to a NULL-terminated string value.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
free | If true, then the key's value can be freed when the key is destroyed. |
|
related |
Creates and initializes a heap allocated as_key to a an as_key_value.
Use as_key_destroy() to release resources allocated to as_key via this function.
ns | The namespace for the key. |
set | The set for the key. |
value | The key's value. |
Set the digest value in the key structure. Keys must be integer, string or blob. Otherwise, an error is returned.
err | Error message that is populated on error. |
key | The key to get the digest for. |
as_namespace as_key::ns |
as_key_value as_key::value |
as_key_value* as_key::valuep |
The key value pointer. If NULL, then there is no value. It can point to as_key.value or a different value.