JULEA
Functions
Helper

Functions

void j_helper_get_number_string (gchar *string, guint32 length, guint32 number)
 
void j_helper_set_cork (GSocketConnection *connection, gboolean enable)
 
void j_helper_set_nodelay (GSocketConnection *connection, gboolean enable)
 
guint64 j_helper_atomic_add (guint64 volatile *ptr, guint64 val)
 
gboolean j_helper_execute_parallel (JBackgroundOperationFunc func, gpointer *data, guint length)
 
guint32 j_helper_hash (gchar const *str)
 
gchar * j_helper_str_replace (gchar const *str, gchar const *old, gchar const *new)
 
gpointer j_helper_alloc_aligned (gsize align, gsize len)
 
gboolean j_helper_file_sync (gchar const *path)
 
gboolean j_helper_file_discard (gchar const *path)
 
GQuark j_backend_bson_error_quark (void)
 
GQuark j_backend_db_error_quark (void)
 
GQuark j_backend_sql_error_quark (void)
 
gboolean j_backend_load (gchar const *name, JBackendComponent component, JBackendType type, GModule **module, JBackend **backend)
 
gboolean j_backend_unload (JBackend *backend, GModule *module)
 
gboolean j_backend_object_init (JBackend *backend, gchar const *path)
 
void j_backend_object_fini (JBackend *backend)
 
gboolean j_backend_object_create (JBackend *backend, gchar const *namespace, gchar const *path, gpointer *data)
 
gboolean j_backend_object_open (JBackend *backend, gchar const *namespace, gchar const *path, gpointer *data)
 
gboolean j_backend_object_delete (JBackend *backend, gpointer data)
 
gboolean j_backend_object_get_all (JBackend *backend, gchar const *namespace, gpointer *iterator)
 
gboolean j_backend_object_get_by_prefix (JBackend *backend, gchar const *namespace, gchar const *prefix, gpointer *iterator)
 
gboolean j_backend_object_iterate (JBackend *backend, gpointer iterator, gchar const **name)
 
gboolean j_backend_object_close (JBackend *backend, gpointer data)
 
gboolean j_backend_object_status (JBackend *backend, gpointer data, gint64 *modification_time, guint64 *size)
 
gboolean j_backend_object_sync (JBackend *backend, gpointer data)
 
gboolean j_backend_object_read (JBackend *backend, gpointer data, gpointer buffer, guint64 length, guint64 offset, guint64 *bytes_read)
 
gboolean j_backend_object_write (JBackend *backend, gpointer data, gconstpointer buffer, guint64 length, guint64 offset, guint64 *bytes_written)
 
gboolean j_backend_kv_init (JBackend *backend, gchar const *path)
 
void j_backend_kv_fini (JBackend *backend)
 
gboolean j_backend_kv_batch_start (JBackend *backend, gchar const *namespace, JSemantics *semantics, gpointer *batch)
 
gboolean j_backend_kv_batch_execute (JBackend *backend, gpointer batch)
 
gboolean j_backend_kv_put (JBackend *backend, gpointer batch, gchar const *key, gconstpointer value, guint32 value_len)
 
gboolean j_backend_kv_delete (JBackend *backend, gpointer batch, gchar const *key)
 
gboolean j_backend_kv_get (JBackend *backend, gpointer batch, gchar const *key, gpointer *value, guint32 *value_len)
 
gboolean j_backend_kv_get_all (JBackend *backend, gchar const *namespace, gpointer *iterator)
 
gboolean j_backend_kv_get_by_prefix (JBackend *backend, gchar const *namespace, gchar const *prefix, gpointer *iterator)
 
gboolean j_backend_kv_iterate (JBackend *backend, gpointer iterator, gchar const **key, gconstpointer *value, guint32 *value_len)
 
gboolean j_backend_db_init (JBackend *backend, gchar const *path)
 
void j_backend_db_fini (JBackend *backend)
 
gboolean j_backend_db_batch_start (JBackend *backend, gchar const *namespace, JSemantics *semantics, gpointer *batch, GError **error)
 
gboolean j_backend_db_batch_execute (JBackend *backend, gpointer batch, GError **error)
 
gboolean j_backend_db_schema_create (JBackend *backend, gpointer batch, gchar const *name, bson_t const *schema, GError **error)
 
gboolean j_backend_db_schema_get (JBackend *backend, gpointer batch, gchar const *name, bson_t *schema, GError **error)
 
gboolean j_backend_db_schema_delete (JBackend *backend, gpointer batch, gchar const *name, GError **error)
 
gboolean j_backend_db_insert (JBackend *backend, gpointer batch, gchar const *name, bson_t const *metadata, bson_t *id, GError **error)
 
gboolean j_backend_db_update (JBackend *backend, gpointer batch, gchar const *name, bson_t const *selector, bson_t const *metadata, GError **error)
 
gboolean j_backend_db_delete (JBackend *backend, gpointer batch, gchar const *name, bson_t const *selector, GError **error)
 
gboolean j_backend_db_query (JBackend *backend, gpointer batch, gchar const *name, bson_t const *selector, gpointer *iterator, GError **error)
 
gboolean j_backend_db_iterate (JBackend *backend, gpointer iterator, bson_t *metadata, GError **error)
 

Detailed Description

Helper data structures and functions.

Function Documentation

◆ j_backend_bson_error_quark()

GQuark j_backend_bson_error_quark ( void  )

◆ j_backend_db_batch_execute()

gboolean j_backend_db_batch_execute ( JBackend backend,
gpointer  batch,
GError **  error 
)

◆ j_backend_db_batch_start()

gboolean j_backend_db_batch_start ( JBackend backend,
gchar const *  namespace,
JSemantics semantics,
gpointer *  batch,
GError **  error 
)

◆ j_backend_db_delete()

gboolean j_backend_db_delete ( JBackend backend,
gpointer  batch,
gchar const *  name,
bson_t const *  selector,
GError **  error 
)

◆ j_backend_db_error_quark()

GQuark j_backend_db_error_quark ( void  )

◆ j_backend_db_fini()

void j_backend_db_fini ( JBackend backend)

◆ j_backend_db_init()

gboolean j_backend_db_init ( JBackend backend,
gchar const *  path 
)

◆ j_backend_db_insert()

gboolean j_backend_db_insert ( JBackend backend,
gpointer  batch,
gchar const *  name,
bson_t const *  metadata,
bson_t *  id,
GError **  error 
)

◆ j_backend_db_iterate()

gboolean j_backend_db_iterate ( JBackend backend,
gpointer  iterator,
bson_t *  metadata,
GError **  error 
)

◆ j_backend_db_query()

gboolean j_backend_db_query ( JBackend backend,
gpointer  batch,
gchar const *  name,
bson_t const *  selector,
gpointer *  iterator,
GError **  error 
)

◆ j_backend_db_schema_create()

gboolean j_backend_db_schema_create ( JBackend backend,
gpointer  batch,
gchar const *  name,
bson_t const *  schema,
GError **  error 
)

◆ j_backend_db_schema_delete()

gboolean j_backend_db_schema_delete ( JBackend backend,
gpointer  batch,
gchar const *  name,
GError **  error 
)

◆ j_backend_db_schema_get()

gboolean j_backend_db_schema_get ( JBackend backend,
gpointer  batch,
gchar const *  name,
bson_t *  schema,
GError **  error 
)

◆ j_backend_db_update()

gboolean j_backend_db_update ( JBackend backend,
gpointer  batch,
gchar const *  name,
bson_t const *  selector,
bson_t const *  metadata,
GError **  error 
)

◆ j_backend_kv_batch_execute()

gboolean j_backend_kv_batch_execute ( JBackend backend,
gpointer  batch 
)

◆ j_backend_kv_batch_start()

gboolean j_backend_kv_batch_start ( JBackend backend,
gchar const *  namespace,
JSemantics semantics,
gpointer *  batch 
)

◆ j_backend_kv_delete()

gboolean j_backend_kv_delete ( JBackend backend,
gpointer  batch,
gchar const *  key 
)

◆ j_backend_kv_fini()

void j_backend_kv_fini ( JBackend backend)

◆ j_backend_kv_get()

gboolean j_backend_kv_get ( JBackend backend,
gpointer  batch,
gchar const *  key,
gpointer *  value,
guint32 *  value_len 
)

◆ j_backend_kv_get_all()

gboolean j_backend_kv_get_all ( JBackend backend,
gchar const *  namespace,
gpointer *  iterator 
)

◆ j_backend_kv_get_by_prefix()

gboolean j_backend_kv_get_by_prefix ( JBackend backend,
gchar const *  namespace,
gchar const *  prefix,
gpointer *  iterator 
)

◆ j_backend_kv_init()

gboolean j_backend_kv_init ( JBackend backend,
gchar const *  path 
)

◆ j_backend_kv_iterate()

gboolean j_backend_kv_iterate ( JBackend backend,
gpointer  iterator,
gchar const **  key,
gconstpointer *  value,
guint32 *  value_len 
)

◆ j_backend_kv_put()

gboolean j_backend_kv_put ( JBackend backend,
gpointer  batch,
gchar const *  key,
gconstpointer  value,
guint32  value_len 
)

◆ j_backend_load()

gboolean j_backend_load ( gchar const *  name,
JBackendComponent  component,
JBackendType  type,
GModule **  module,
JBackend **  backend 
)

◆ j_backend_object_close()

gboolean j_backend_object_close ( JBackend backend,
gpointer  data 
)

◆ j_backend_object_create()

gboolean j_backend_object_create ( JBackend backend,
gchar const *  namespace,
gchar const *  path,
gpointer *  data 
)

◆ j_backend_object_delete()

gboolean j_backend_object_delete ( JBackend backend,
gpointer  data 
)

◆ j_backend_object_fini()

void j_backend_object_fini ( JBackend backend)

◆ j_backend_object_get_all()

gboolean j_backend_object_get_all ( JBackend backend,
gchar const *  namespace,
gpointer *  iterator 
)

◆ j_backend_object_get_by_prefix()

gboolean j_backend_object_get_by_prefix ( JBackend backend,
gchar const *  namespace,
gchar const *  prefix,
gpointer *  iterator 
)

◆ j_backend_object_init()

gboolean j_backend_object_init ( JBackend backend,
gchar const *  path 
)

◆ j_backend_object_iterate()

gboolean j_backend_object_iterate ( JBackend backend,
gpointer  iterator,
gchar const **  name 
)

◆ j_backend_object_open()

gboolean j_backend_object_open ( JBackend backend,
gchar const *  namespace,
gchar const *  path,
gpointer *  data 
)

◆ j_backend_object_read()

gboolean j_backend_object_read ( JBackend backend,
gpointer  data,
gpointer  buffer,
guint64  length,
guint64  offset,
guint64 *  bytes_read 
)

◆ j_backend_object_status()

gboolean j_backend_object_status ( JBackend backend,
gpointer  data,
gint64 *  modification_time,
guint64 *  size 
)

◆ j_backend_object_sync()

gboolean j_backend_object_sync ( JBackend backend,
gpointer  data 
)

◆ j_backend_object_write()

gboolean j_backend_object_write ( JBackend backend,
gpointer  data,
gconstpointer  buffer,
guint64  length,
guint64  offset,
guint64 *  bytes_written 
)

◆ j_backend_sql_error_quark()

GQuark j_backend_sql_error_quark ( void  )

◆ j_backend_unload()

gboolean j_backend_unload ( JBackend backend,
GModule *  module 
)

◆ j_helper_alloc_aligned()

gpointer j_helper_alloc_aligned ( gsize  align,
gsize  len 
)

Error checking wrapper for aligned_alloc().

Parameters
alignThe alignment to use. Must be support by implementation.
lenThe number of bytes to allocate.
Returns
A pointer to allocated memory or NULL on failure. Memory should be freed with free().

◆ j_helper_atomic_add()

guint64 j_helper_atomic_add ( guint64 volatile *  ptr,
guint64  val 
)

Atomically add val to *ptr and return the result.

Parameters
ptrAddress of a 64 bit unsigned integer.
valValue to add to *ptr.
Remarks
If no atomic operation is available locking will bew used.
Todo:
check C11 atomic_fetch_add

◆ j_helper_execute_parallel()

gboolean j_helper_execute_parallel ( JBackgroundOperationFunc  func,
gpointer *  data,
guint  length 
)

Execute func in parallel.

Parameters
funcA JBackgroundOperationFunc.
dataAn argument array for parallel execution of func.
lengthThe length of data.
Remarks
NULL is allowed to appear in data but func will not be executed with NULL as argument.

◆ j_helper_file_discard()

gboolean j_helper_file_discard ( gchar const *  path)

Synchronizes the file described by path with the storage device. The file will be marked as not accessed in the near future to make optimization in kernel possible.

Parameters
pathThe file to sync.
Remarks
This only states an intention and is not binding.
Returns
TRUE on success FALSE otherwise.

◆ j_helper_file_sync()

gboolean j_helper_file_sync ( gchar const *  path)

Synchronizes the file described by path with the storage device.

Parameters
pathThe file to sync.
Returns
TRUE on success FALSE otherwise.

◆ j_helper_get_number_string()

void j_helper_get_number_string ( gchar *  string,
guint32  length,
guint32  number 
)

Convert a number to a string.

Parameters
stringThe buffer to be filled with the number string.
lengthThe size of the string buffer.
numberThe number to convert.
Remarks
If the buffer is to small not the whole number will be written.
Todo:
improve

◆ j_helper_hash()

guint32 j_helper_hash ( gchar const *  str)

A hash function for strings

Parameters
strThe string to be hashed.

◆ j_helper_set_cork()

void j_helper_set_cork ( GSocketConnection *  connection,
gboolean  enable 
)

Set the TCP_CORK flag to the value of enable

Parameters
connectionThe connection to manipulate.
enableThe value to be set for TCP_CORK.
Todo:
get rid of GSocketConnection

◆ j_helper_set_nodelay()

void j_helper_set_nodelay ( GSocketConnection *  connection,
gboolean  enable 
)

Set the TCP_NODELAY flag to the value of enable

Parameters
connectionThe connection to manipulate.
enableThe value to be set for TCP_NODELAY.
Todo:
get rid of GSocketConnection

◆ j_helper_str_replace()

gchar * j_helper_str_replace ( gchar const *  str,
gchar const *  old,
gchar const *  new 
)

Replaces all occurences of old with new in str in a new string.

Parameters
strA string.
oldA string.
newA string.
Returns
A new string containing the replacements. Should be freed with g_free().
Todo:
consider using g_string_replace for GLib >= 2.68