JULEA
Data Structures | Typedefs | Functions
KV

Data Structures

struct  JKVOperation
 
struct  JKV
 

Typedefs

typedef struct JKV JKV
 
typedef void(* JKVGetFunc) (gpointer, guint32, gpointer)
 
typedef struct JKVOperation JKVOperation
 

Functions

JKVj_kv_new (gchar const *namespace, gchar const *key)
 
JKVj_kv_new_for_index (guint32 index, gchar const *namespace, gchar const *key)
 
JKVj_kv_ref (JKV *kv)
 
void j_kv_unref (JKV *kv)
 
void j_kv_put (JKV *kv, gpointer value, guint32 value_len, GDestroyNotify value_destroy, JBatch *batch)
 
void j_kv_delete (JKV *kv, JBatch *batch)
 
void j_kv_get (JKV *kv, gpointer *value, guint32 *value_len, JBatch *batch)
 
void j_kv_get_callback (JKV *kv, JKVGetFunc func, gpointer data, JBatch *batch)
 
JBackendj_kv_get_backend (void)
 

Detailed Description

Data structures and functions for managing key-value pairs.

Typedef Documentation

◆ JKV

typedef struct JKV JKV

◆ JKVGetFunc

typedef void(* JKVGetFunc) (gpointer, guint32, gpointer)

A callback for j_kv_get_callback.

The callback will receive a pointer to the value (must be freed by the caller), the value's length and a pointer to optional user-provided data.

◆ JKVOperation

typedef struct JKVOperation JKVOperation

Function Documentation

◆ j_kv_delete()

void j_kv_delete ( JKV kv,
JBatch batch 
)

Deletes a key-value pair.

Parameters
kvA JKV.
batchA batch.

◆ j_kv_get()

void j_kv_get ( JKV kv,
gpointer *  value,
guint32 *  value_len,
JBatch batch 
)

Get a key-value pair.

Parameters
kvA KV.
valueA pointer for the returned value buffer.
value_lenA pointer to the length of the returned value buffer.
batchA batch.

◆ j_kv_get_backend()

JBackend* j_kv_get_backend ( void  )

Returns the kv backend.

Returns
The kv backend.

◆ j_kv_get_callback()

void j_kv_get_callback ( JKV kv,
JKVGetFunc  func,
gpointer  data,
JBatch batch 
)

Get a key-value pair and execute a callback function once the pair is received.

Parameters
kvA key-value pair.
funcThe callback function. Will be called even if no KV is found (with value == NULL and len == 0).
dataUser defined data which will be passed to the callback function.
batchA batch.

◆ j_kv_new()

JKV * j_kv_new ( gchar const *  namespace,
gchar const *  key 
)

Creates a new key-value pair.

JKV* i;
i = j_kv_new("JULEA", "KEY");
JKV * j_kv_new(gchar const *namespace, gchar const *key)
Definition: jkv.c:525
Definition: jkv.c:69
Parameters
namespaceNamespace to create the key-value pair in.
keyA key-value pair key.
Returns
A new key-value pair. Should be freed with j_kv_unref().

◆ j_kv_new_for_index()

JKV * j_kv_new_for_index ( guint32  index,
gchar const *  namespace,
gchar const *  key 
)

Creates a new key-value pair on a specific KV-server.

JKV* i;
i = j_kv_new_for_index(0, "JULEA", "KEY");
JKV * j_kv_new_for_index(guint32 index, gchar const *namespace, gchar const *key)
Definition: jkv.c:545
Parameters
indexIndex of the KV-server where the key-value pair should be stored.
namespaceNamespace to create the key-value pair in.
keyA key-value pair key.
Returns
A new key-value pair. Should be freed with j_kv_unref().

◆ j_kv_put()

void j_kv_put ( JKV kv,
gpointer  value,
guint32  value_len,
GDestroyNotify  value_destroy,
JBatch batch 
)

Creates a key-value pair.

Parameters
kvA KV.
valueA value.
value_lenLength of value buffer.
value_destroyA function to correctly free the stored data.
batchA batch.
Todo:
key = index + namespace

◆ j_kv_ref()

JKV * j_kv_ref ( JKV kv)

Increases a key-value pair's reference count.

JKV* i;
JKV * j_kv_ref(JKV *kv)
Definition: jkv.c:566
Parameters
kvA key-value pair.
Returns
key-value pair.

◆ j_kv_unref()

void j_kv_unref ( JKV kv)

Decreases a key-value pair's reference count. When the reference count reaches zero, frees the memory allocated for the key-value pair.

Parameters
kvA key-value pair.