All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | Related Functions
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");

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");

Destruction

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.

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 196 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 Functions

(Note that these are not member functions.)

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 Function Documentation

AS_EXTERN void as_key_destroy ( as_key key)
related

Destory the as_key, releasing resources.

Parameters
keyThe as_key to destroy.
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.

Parameters
keyThe key to get the digest for.
Returns
The digest for the key.
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_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_digest_value digest = {0};
as_key key;
as_key_init_digest(&key, "ns", "set", 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_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);

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

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 388 of file as_key.h.

References 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);

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.
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");

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 329 of file as_key.h.

References 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);

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_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);

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_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_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_digest_value digest = {0};
as_key* key = as_key_new_digest("ns", "set", 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_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);

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

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 588 of file as_key.h.

References 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);

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.
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");

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 531 of file as_key.h.

References 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);

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_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);

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_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

as_digest as_key::digest

Digest for the key.

Definition at line 229 of file as_key.h.

as_namespace as_key::ns

The namespace the key belongs to.

Definition at line 207 of file as_key.h.

as_set as_key::set

The set the key belongs to.

Definition at line 212 of file as_key.h.

as_key_value as_key::value

The key value.

Definition at line 217 of file as_key.h.

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 224 of file as_key.h.


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