Loading...
Searching...
No Matches
Data Fields | Related Symbols
as_key Struct Reference

Detailed Description

A key is used for locating records in the database.

Initialization

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:

as_key key;
as_key_init(&key, "ns", "set", "key");
AS_EXTERN as_key * as_key_init(as_key *key, const char *ns, const char *set, const char *value)

For heap allocated as_key, you should use the following functions to allocate and initialize the value on the heap.

as_key* key = as_key_new("ns", "set", "key");
AS_EXTERN as_key * as_key_new(const char *ns, const char *set, const char *value)

Destruction

When you no longer require an instance of as_key, you should release the key and associated resources via as_key_destroy().

AS_EXTERN void as_key_destroy(as_key *key)

This function should be used on both stack and heap allocated keys.

Operations

The following are operations which require a key.

Digest

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().

Definition at line 180 of file as_key.h.

#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_valuevaluep
 

Related Symbols

(Note that these are not member symbols.)

AS_EXTERN void as_key_destroy (as_key *key)
 
AS_EXTERN as_digestas_key_digest (as_key *key)
 
AS_EXTERN as_keyas_key_init (as_key *key, const char *ns, const char *set, const char *value)
 
AS_EXTERN as_keyas_key_init_digest (as_key *key, const char *ns, const char *set, const as_digest_value digest)
 
AS_EXTERN as_keyas_key_init_int64 (as_key *key, const char *ns, const char *set, int64_t value)
 
static as_keyas_key_init_raw (as_key *key, const char *ns, const char *set, const uint8_t *value, uint32_t size)
 
AS_EXTERN as_keyas_key_init_rawp (as_key *key, const char *ns, const char *set, const uint8_t *value, uint32_t size, bool free)
 
static as_keyas_key_init_str (as_key *key, const char *ns, const char *set, const char *value)
 
AS_EXTERN as_keyas_key_init_strp (as_key *key, const char *ns, const char *set, const char *value, bool free)
 
AS_EXTERN as_keyas_key_init_value (as_key *key, const char *ns, const char *set, const as_key_value *value)
 
AS_EXTERN as_keyas_key_new (const char *ns, const char *set, const char *value)
 
AS_EXTERN as_keyas_key_new_digest (const char *ns, const char *set, const as_digest_value digest)
 
AS_EXTERN as_keyas_key_new_int64 (const char *ns, const char *set, int64_t value)
 
static as_keyas_key_new_raw (const char *ns, const char *set, const uint8_t *value, uint32_t size)
 
AS_EXTERN as_keyas_key_new_rawp (const char *ns, const char *set, const uint8_t *value, uint32_t size, bool free)
 
static as_keyas_key_new_str (const char *ns, const char *set, const char *value)
 
AS_EXTERN as_keyas_key_new_strp (const char *ns, const char *set, const char *value, bool free)
 
AS_EXTERN as_keyas_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)
 

Friends And Related Symbol Documentation

◆ as_key_destroy()

AS_EXTERN void as_key_destroy ( as_key * key)
related

Destory the as_key, releasing resources.

Parameters
keyThe as_key to destroy.

◆ as_key_digest()

AS_EXTERN as_digest * as_key_digest ( as_key * key)
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.

AS_EXTERN as_digest * as_key_digest(as_key *key)
as_digest digest
Definition as_key.h:213
Parameters
keyThe key to get the digest for.
Returns
The digest for the key.

◆ as_key_init()

AS_EXTERN as_key * as_key_init ( as_key * key,
const char * ns,
const char * set,
const char * value )
related

Initialize a stack allocated as_key to a NULL-terminated string value.

as_key key;
as_key_init(&key, "ns", "set", "key");

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
Returns
The initialized as_key on success. Otherwise NULL.

◆ as_key_init_digest()

AS_EXTERN as_key * as_key_init_digest ( as_key * key,
const char * ns,
const char * set,
const as_digest_value digest )
related

Initialize a stack allocated as_key with a digest.

as_key key;
as_key_init_digest(&key, "ns", "set", digest);
uint8_t as_digest_value[AS_DIGEST_VALUE_SIZE]
Definition as_key.h:65
AS_EXTERN as_key * as_key_init_digest(as_key *key, const char *ns, const char *set, const as_digest_value digest)

Use as_key_destroy() to release resources allocated to as_key.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
digestThe digest for the key.
Returns
The initialized as_key on success. Otherwise NULL.

◆ as_key_init_int64()

AS_EXTERN as_key * as_key_init_int64 ( as_key * key,
const char * ns,
const char * set,
int64_t value )
related

Initialize a stack allocated as_key to a int64_t value.

as_key key;
as_key_init_int64(&key, "ns", "set", 123);
AS_EXTERN as_key * as_key_init_int64(as_key *key, const char *ns, const char *set, int64_t value)

Use as_key_destroy() to release resources allocated to as_key.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
Returns
The initialized as_key on success. Otherwise NULL.

◆ as_key_init_raw()

static as_key * as_key_init_raw ( as_key * key,
const char * ns,
const char * set,
const uint8_t * value,
uint32_t size )
related

Initialize a stack allocated as_key to bytes array.

uint8_t rgb[3] = {254,254,120};
as_key key;
as_key_init_raw(&key, "ns", "set", rgb, 3);
static as_key * as_key_init_raw(as_key *key, const char *ns, const char *set, const uint8_t *value, uint32_t size)
Definition as_key.h:366

Use as_key_destroy() to release resources allocated to as_key.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
sizeThe number of bytes in value. Must last for the lifetime of the key.
Returns
The initialized as_key on success. Otherwise NULL.

Definition at line 366 of file as_key.h.

◆ as_key_init_rawp()

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 )
related

Initialize a stack allocated as_key to bytes array.

uint8_t * rgb = (uint8_t *) malloc(3);
rgb[0] = 255;
rgb[1] = 255;
rgb[3] = 255;
as_key key;
as_key_init_rawp(&key, "ns", "set", rgb, 3, true);
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)

Use as_key_destroy() to release resources allocated to as_key.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
sizeThe number of bytes in value.
freeIf true, then the key's value can be freed when the key is destroyed.
Returns
The initialized as_key on success. Otherwise NULL.

◆ as_key_init_str()

static as_key * as_key_init_str ( as_key * key,
const char * ns,
const char * set,
const char * value )
related

Initialize a stack allocated as_key to a NULL-terminated string value.

as_key key;
as_key_init_str(&key, "ns", "set", "key");
static as_key * as_key_init_str(as_key *key, const char *ns, const char *set, const char *value)
Definition as_key.h:309

Use as_key_destroy() to release resources allocated to as_key.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
valueThe key's value. Must last for the lifetime of the key.
Returns
The initialized as_key on success. Otherwise NULL.

Definition at line 309 of file as_key.h.

◆ as_key_init_strp()

AS_EXTERN as_key * as_key_init_strp ( as_key * key,
const char * ns,
const char * set,
const char * value,
bool free )
related

Initialize a stack allocated as_key to a NULL-terminated string value.

as_key key;
as_key_init_strp(&key, "ns", "set", stdup("key"), true);
AS_EXTERN as_key * as_key_init_strp(as_key *key, const char *ns, const char *set, const char *value, bool free)

Use as_key_destroy() to release resources allocated to as_key.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
freeIf true, then the key's value can be freed when the key is destroyed.
Returns
The initialized as_key on success. Otherwise NULL.

◆ as_key_init_value()

AS_EXTERN as_key * as_key_init_value ( as_key * key,
const char * ns,
const char * set,
const as_key_value * value )
related

Initialize a stack allocated as_key to an as_key_value.

as_string_init(&str, "abc", false);
as_key key;
as_key_init_value(&key, "ns", "set", (as_key_value *) str);
AS_EXTERN as_string * as_string_init(as_string *string, 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)

Use as_key_destroy() to release resources allocated to as_key.

Parameters
keyThe key to initialize.
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
Returns
The initialized as_key on success. Otherwise NULL.

◆ as_key_new()

AS_EXTERN as_key * as_key_new ( const char * ns,
const char * set,
const char * value )
related

Creates and initializes a heap allocated as_key to a NULL-terminated string value.

as_key* key = as_key_new("ns", "set", "key");

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
Returns
A new as_key on success. Otherwise NULL.

◆ as_key_new_digest()

AS_EXTERN as_key * as_key_new_digest ( const char * ns,
const char * set,
const as_digest_value digest )
related

Creates and initializes a heap allocated as_key with a digest.

as_key* key = as_key_new_digest("ns", "set", digest);
AS_EXTERN as_key * as_key_new_digest(const char *ns, const char *set, const as_digest_value digest)

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
digestThe key's digest.
Returns
A new as_key on success. Otherwise NULL.

◆ as_key_new_int64()

AS_EXTERN as_key * as_key_new_int64 ( const char * ns,
const char * set,
int64_t value )
related

Creates and initializes a heap allocated as_key to a int64_t value.

as_key* key = as_key_new_int64("ns", "set", 123);
AS_EXTERN as_key * as_key_new_int64(const char *ns, const char *set, int64_t value)

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
Returns
A new as_key on success. Otherwise NULL.

◆ as_key_new_raw()

static as_key * as_key_new_raw ( const char * ns,
const char * set,
const uint8_t * value,
uint32_t size )
related

Creates and initializes a heap allocated as_key to a byte array.

uint8_t rgb[3] = {254,254,120};
as_key* key = as_key_new_raw("ns", "set", rgb, 3);
static as_key * as_key_new_raw(const char *ns, const char *set, const uint8_t *value, uint32_t size)
Definition as_key.h:558

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
valueThe key's value. Must last for the lifetime of the key.
sizeThe number of bytes in the value.
Returns
A new as_key on success. Otherwise NULL.

Definition at line 558 of file as_key.h.

◆ as_key_new_rawp()

AS_EXTERN as_key * as_key_new_rawp ( const char * ns,
const char * set,
const uint8_t * value,
uint32_t size,
bool free )
related

Creates and initializes a heap allocated as_key to a byte array.

uint8_t * rgb = (uint8_t *) malloc(3);
rgb[0] = 255;
rgb[1] = 255;
rgb[3] = 255;
as_key* key = as_key_new_rawp("ns", "set", rgb, 3, true);
AS_EXTERN as_key * as_key_new_rawp(const char *ns, const char *set, const uint8_t *value, uint32_t size, bool free)

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
sizeThe number of bytes in the value.
freeIf true, then the key's value can be freed when the key is destroyed.
Returns
A new as_key on success. Otherwise NULL.

◆ as_key_new_str()

static as_key * as_key_new_str ( const char * ns,
const char * set,
const char * value )
related

Creates and initializes a heap allocated as_key to a NULL-terminated string value.

as_key* key = as_key_new_str("ns", "set", "key");
static as_key * as_key_new_str(const char *ns, const char *set, const char *value)
Definition as_key.h:503

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
valueThe key's value. Must last for the lifetime of the key.
Returns
A new as_key on success. Otherwise NULL.

Definition at line 503 of file as_key.h.

◆ as_key_new_strp()

AS_EXTERN as_key * as_key_new_strp ( const char * ns,
const char * set,
const char * value,
bool free )
related

Creates and initializes a heap allocated as_key to a NULL-terminated string value.

as_key* key = as_key_new_strp("ns", "set", strdup("key"), true);
AS_EXTERN as_key * as_key_new_strp(const char *ns, const char *set, const char *value, bool free)

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
freeIf true, then the key's value can be freed when the key is destroyed.
Returns
A new as_key on success. Otherwise NULL.

◆ as_key_new_value()

AS_EXTERN as_key * as_key_new_value ( const char * ns,
const char * set,
const as_key_value * value )
related

Creates and initializes a heap allocated as_key to a an as_key_value.

as_string_init(&str, "abc", false);
as_key* key = as_key_new_value("ns", "set", (as_key_value *) str);
AS_EXTERN as_key * as_key_new_value(const char *ns, const char *set, const as_key_value *value)

Use as_key_destroy() to release resources allocated to as_key via this function.

Parameters
nsThe namespace for the key.
setThe set for the key.
valueThe key's value.
Returns
A new as_key on success. Otherwise NULL.

◆ as_key_set_digest()

AS_EXTERN as_status as_key_set_digest ( as_error * err,
as_key * key )
related

Set the digest value in the key structure. Keys must be integer, string or blob. Otherwise, an error is returned.

Parameters
errError message that is populated on error.
keyThe key to get the digest for.
Returns
Status code.

Field Documentation

◆ digest

as_digest as_key::digest

Digest for the key.

Definition at line 213 of file as_key.h.

◆ ns

as_namespace as_key::ns

The namespace the key belongs to.

Definition at line 191 of file as_key.h.

◆ set

as_set as_key::set

The set the key belongs to.

Definition at line 196 of file as_key.h.

◆ value

as_key_value as_key::value

The key value.

Definition at line 201 of file as_key.h.

◆ valuep

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.

Definition at line 208 of file as_key.h.


The documentation for this struct was generated from the following file: