All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | Private Attributes | 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_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 199 of file src/include/aerospike/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
 

Private Attributes

bool _free
 

Related Functions

(Note that these are not member functions.)

void as_key_destroy (as_key *key)
 
as_digestas_key_digest (as_key *key)
 
as_keyas_key_init (as_key *key, const as_namespace ns, const as_set set, const char *value)
 
as_keyas_key_init_digest (as_key *key, const as_namespace ns, const as_set set, const as_digest_value digest)
 
as_keyas_key_init_int64 (as_key *key, const as_namespace ns, const as_set set, int64_t value)
 
as_keyas_key_init_raw (as_key *key, const as_namespace ns, const as_set set, const uint8_t *value, uint32_t size)
 
as_keyas_key_init_rawp (as_key *key, const as_namespace ns, const as_set set, const uint8_t *value, uint32_t size, bool free)
 
as_keyas_key_init_str (as_key *key, const as_namespace ns, const as_set set, const char *value)
 
as_keyas_key_init_strp (as_key *key, const as_namespace ns, const as_set set, const char *value, bool free)
 
as_keyas_key_init_value (as_key *key, const as_namespace ns, const as_set set, const as_key_value *value)
 
as_keyas_key_new (const as_namespace ns, const as_set set, const char *value)
 
as_keyas_key_new_digest (const as_namespace ns, const as_set set, const as_digest_value digest)
 
as_keyas_key_new_int64 (const as_namespace ns, const as_set set, int64_t value)
 
as_keyas_key_new_raw (const as_namespace ns, const as_set set, const uint8_t *value, uint32_t size)
 
as_keyas_key_new_rawp (const as_namespace ns, const as_set set, const uint8_t *value, uint32_t size, bool free)
 
as_keyas_key_new_str (const as_namespace ns, const as_set set, const char *value)
 
as_keyas_key_new_strp (const as_namespace ns, const as_set set, const char *value, bool free)
 
as_keyas_key_new_value (const as_namespace ns, const as_set set, const as_key_value *value)
 

Friends And Related Function Documentation

void as_key_destroy ( as_key key)
related

Destory the as_key, releasing resources.

Parameters
keyThe as_key to destroy.
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_key * as_key_init ( as_key key,
const as_namespace  ns,
const as_set  set,
const char *  value 
)
related

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

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 * as_key_init_digest ( as_key key,
const as_namespace  ns,
const as_set  set,
const as_digest_value  digest 
)
related

Initialize a stack allocated as_key with a digest.

as_digest_value digest = {0};
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_key * as_key_init_int64 ( as_key key,
const as_namespace  ns,
const as_set  set,
int64_t  value 
)
related

Initialize a stack allocated as_key to a int64_t value.

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.
as_key * as_key_init_raw ( as_key key,
const as_namespace  ns,
const as_set  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_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 385 of file src/include/aerospike/as_key.h.

References as_key_init_rawp().

as_key * as_key_init_rawp ( as_key key,
const as_namespace  ns,
const as_set  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_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.
as_key * as_key_init_str ( as_key key,
const as_namespace  ns,
const as_set  set,
const char *  value 
)
related

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

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 328 of file src/include/aerospike/as_key.h.

References as_key_init_strp().

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

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

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_key * as_key_init_value ( as_key key,
const as_namespace  ns,
const as_set  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_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_key * as_key_new ( const as_namespace  ns,
const as_set  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 * as_key_new_digest ( const as_namespace  ns,
const as_set  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_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_key * as_key_new_int64 ( const as_namespace  ns,
const as_set  set,
int64_t  value 
)
related

Initialize a stack 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.
as_key * as_key_new_raw ( const as_namespace  ns,
const as_set  set,
const uint8_t *  value,
uint32_t  size 
)
related

Initialize a stack 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 578 of file src/include/aerospike/as_key.h.

References as_key_new_rawp().

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

Initialize a stack 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.
as_key * as_key_new_str ( const as_namespace  ns,
const as_set  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 523 of file src/include/aerospike/as_key.h.

References as_key_new_strp().

as_key * as_key_new_strp ( const as_namespace  ns,
const as_set  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_key * as_key_new_value ( const as_namespace  ns,
const as_set  set,
const as_key_value value 
)
related

Initialize a stack 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.

Field Documentation

bool as_key::_free
private

If true, then as_key_destroy() will free this instance.

Definition at line 205 of file src/include/aerospike/as_key.h.

as_digest as_key::digest

Digest for the key.

Definition at line 232 of file src/include/aerospike/as_key.h.

as_namespace as_key::ns

The namespace the key belongs to.

Definition at line 210 of file src/include/aerospike/as_key.h.

as_set as_key::set

The set the key belongs to.

Definition at line 215 of file src/include/aerospike/as_key.h.

as_key_value as_key::value

The key value.

Definition at line 220 of file src/include/aerospike/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 227 of file src/include/aerospike/as_key.h.


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