![]() |
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"
Collaboration diagram for as_key:Data Fields | |
| as_digest | digest |
| as_namespace | ns |
| as_set | set |
| as_key_value | value |
| as_key_value * | valuep |
Private Attributes | |
| bool | _free |
|
related |
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. |
Definition at line 379 of file as_key.h.
References as_key_init_rawp().
|
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. |
Definition at line 322 of file as_key.h.
References as_key_init_strp().
|
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. |
|
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. |
|
related |
Initialize a stack 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. |
|
related |
Initialize a stack 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 |
Initialize a stack 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. |
Definition at line 572 of file as_key.h.
References as_key_new_rawp().
|
related |
Initialize a stack 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. |
Definition at line 517 of file as_key.h.
References as_key_new_strp().
|
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 |
Initialize a stack 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. |
|
private |
If true, then as_key_destroy() will free this instance.
| 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.