SOS: Scalable Object Store
4.0.0
|
Macros | |
#define | SOS_INDEX_RT_OPT_MP_UNSAFE 1 |
#define | SOS_INDEX_RT_OPT_VISIT_ASYNC 2 |
Typedefs | |
typedef int(* | sos_ins_cb_fn_t )(sos_index_t index, sos_key_t key, int missing, sos_obj_ref_t *ref, void *arg) |
typedef enum sos_visit_action | sos_visit_action_t |
typedef sos_visit_action_t(* | sos_visit_cb_fn_t )(sos_index_t index, sos_key_t key, sos_idx_data_t *idx_data, int found, void *arg) |
typedef uint32_t | sos_index_rt_opt_t |
typedef struct sos_container_index_iter_s * | sos_container_index_iter_t |
Enumerations | |
enum | sos_visit_action { SOS_VISIT_ADD = ODS_VISIT_ADD, SOS_VISIT_DEL = ODS_VISIT_DEL, SOS_VISIT_UPD = ODS_VISIT_UPD, SOS_VISIT_NOP = ODS_VISIT_NOP } |
Functions | |
sos_obj_t | sos_obj_find (sos_attr_t attr, sos_key_t key) |
int | sos_index_new (sos_t sos, const char *name, const char *idx_type, const char *key_type, const char *args) |
Create a new Index. More... | |
sos_index_t | sos_index_open (sos_t sos, const char *name) |
Open an existing Index. More... | |
int | sos_index_rt_opt_set (sos_index_t index, sos_index_rt_opt_t opt,...) |
int | sos_index_insert (sos_index_t index, sos_key_t key, sos_obj_t obj) |
Add an object to an index. More... | |
int | sos_index_remove (sos_index_t index, sos_key_t key, sos_obj_t obj) |
Remove a key from an index. More... | |
int | sos_index_visit (sos_index_t index, sos_key_t key, sos_visit_cb_fn_t cb_fn, void *arg) |
Visit the key entry in the index. More... | |
sos_obj_t | sos_index_find (sos_index_t index, sos_key_t key) |
Find an object in the index by it's key. More... | |
int | sos_index_find_ref (sos_index_t index, sos_key_t key, sos_obj_ref_t *ref) |
Find a key in the index and return the ref. More... | |
sos_obj_t | sos_index_find_inf (sos_index_t index, sos_key_t key) |
Find the infinum (greatest lower bound) of the specified key. More... | |
sos_obj_t | sos_index_find_sup (sos_index_t index, sos_key_t key) |
Find the supremum (least upper bound) of the specified key. More... | |
int | sos_index_commit (sos_index_t index, sos_commit_t flags) |
Commit an Index's data to stable storage. More... | |
int | sos_index_close (sos_index_t index, sos_commit_t flags) |
Close the index and commit changes to storage. More... | |
size_t | sos_index_key_size (sos_index_t index) |
Return the size of the index's key. More... | |
sos_key_t | sos_index_key_new (sos_index_t index, size_t size) |
Create a key based on the specified index or size. More... | |
int | sos_index_key_from_str (sos_index_t index, sos_key_t key, const char *str) |
Set the value of a key from a string. More... | |
const char * | sos_index_key_to_str (sos_index_t index, sos_key_t key) |
Return a string representation of the key value. More... | |
int | sos_index_key_cmp (sos_index_t index, sos_key_t a, sos_key_t b) |
Compare two keys using the index's compare function. More... | |
void | sos_index_print (sos_index_t index, FILE *fp) |
const char * | sos_index_name (sos_index_t index) |
Return the index's name. More... | |
int | sos_index_stat (sos_index_t index, sos_index_stat_t sb) |
Return the statistics of the Index. More... | |
void | sos_container_index_list (sos_t sos, FILE *fp) |
sos_container_index_iter_t | sos_container_index_iter_new (sos_t sos) |
void | sos_container_index_iter_free (sos_container_index_iter_t iter) |
sos_index_t | sos_container_index_iter_first (sos_container_index_iter_t iter) |
sos_index_t | sos_container_index_iter_next (sos_container_index_iter_t iter) |
enum sos_visit_action |
int sos_index_close | ( | sos_index_t | index, |
sos_commit_t | flags | ||
) |
Close the index and commit changes to storage.
index The index handle flags The commit flags: SOS_COMMIT_SYNC, SOS_COMMIT_ASYNC
0 | Success |
!0 | A unix errno |
int sos_index_commit | ( | sos_index_t | index, |
sos_commit_t | flags | ||
) |
Commit an Index's data to stable storage.
index | The Index handle |
flags | The commit flags |
0 | Success |
!0 | A Unix error code |
sos_obj_t sos_index_find | ( | sos_index_t | index, |
sos_key_t | key | ||
) |
Find an object in the index by it's key.
index | The index handle |
key | The key |
!NULL | The object associated with the key |
NULL | The object was not found |
sos_obj_t sos_index_find_inf | ( | sos_index_t | index, |
sos_key_t | key | ||
) |
Find the infinum (greatest lower bound) of the specified key.
index | The index handle |
key | The key |
!NULL | The object associated with the key |
NULL | The object was not found |
int sos_index_find_ref | ( | sos_index_t | index, |
sos_key_t | key, | ||
sos_obj_ref_t * | ref | ||
) |
Find a key in the index and return the ref.
index | The index handle |
key | The key |
ref | Pointer to sos_obj_ref_t |
0 | The key was found and ref contains the data |
ENOENT | The key was not found |
sos_obj_t sos_index_find_sup | ( | sos_index_t | index, |
sos_key_t | key | ||
) |
Find the supremum (least upper bound) of the specified key.
index | The index handle |
key | The key |
!NULL | The object associated with the key |
NULL | The object was not found |
int sos_index_insert | ( | sos_index_t | index, |
sos_key_t | key, | ||
sos_obj_t | obj | ||
) |
Add an object to an index.
index | The index handle |
key | The key |
obj | The object to which the key will refer |
0 | Success |
EINVAL | The object or index is invalid |
!0 | A Unix error code |
Compare two keys using the index's compare function.
index | The index handle |
a | The first key |
b | The second key |
int sos_index_key_from_str | ( | sos_index_t | index, |
sos_key_t | key, | ||
const char * | str | ||
) |
Set the value of a key from a string.
index | The index handle |
key | The key |
str | Pointer to a string |
0 | if successful |
-1 | if there was an error converting the string to a value |
sos_key_t sos_index_key_new | ( | sos_index_t | index, |
size_t | size | ||
) |
Create a key based on the specified index or size.
Create a new SOS key for the specified index. If the size is specified, the index parameter is ignored and the key is based on the specified size.
index | The index handle |
size | The desired key size |
A | pointer to the new key or NULL if there is an error |
size_t sos_index_key_size | ( | sos_index_t | index | ) |
Return the size of the index's key.
Returns the native size of the index's key values. If the key value is variable size, this function returns -1. See the sos_key_len() and sos_key_size() functions for the current size of the key's value and the size of the key's buffer respectively.
const char* sos_index_key_to_str | ( | sos_index_t | index, |
sos_key_t | key | ||
) |
Return a string representation of the key value.
index | The index handle |
key | The key |
const char* sos_index_name | ( | sos_index_t | index | ) |
Return the index's name.
index | The index handle |
The | index name |
int sos_index_new | ( | sos_t | sos, |
const char * | name, | ||
const char * | idx_type, | ||
const char * | key_type, | ||
const char * | idx_args | ||
) |
Create a new Index.
sos | The container handle |
name | The unique index name |
idx_type | The index type, e.g. "BXTREE" |
key_type | The key type, e.g. "UINT64" |
idx_args | The index type specific arguments, e.g. "ORDER=5" for a B+Tree |
0 | Success |
!0 | A Unix error code |
sos_index_t sos_index_open | ( | sos_t | sos, |
const char * | name | ||
) |
Open an existing Index.
sos | The container handle |
name | The unique index name |
0 | Success |
!0 | A Unix error code |
int sos_index_remove | ( | sos_index_t | index, |
sos_key_t | key, | ||
sos_obj_t | obj | ||
) |
Remove a key from an index.
Remove a key/value from the index. Note that the function takes an object as a paramter. This is necessary to discriminate when multiple objects are referred to by the same key.
index | The index handle |
key | The key |
obj | The specific object to which the key will refer |
0 | Success |
!0 | A Unix error code |
int sos_index_stat | ( | sos_index_t | index, |
sos_index_stat_t | sb | ||
) |
Return the statistics of the Index.
index | The index handle |
0 | Success |
!0 | A Unix errno |
int sos_index_visit | ( | sos_index_t | index, |
sos_key_t | key, | ||
sos_visit_cb_fn_t | cb_fn, | ||
void * | arg | ||
) |
Visit the key entry in the index.
Find the key in the index and call the visit callback function with the index, the key, a 1 or 0 to indicate if the key was found, a pointer to a sos_idx_data_t structure, and the ctxt passed to sos_index_update(). If the found parameter to the cb_fn() is 1, the the idx_data structure contains the index data for the key. If the found parameter is 0, the contents of this structure are undefined.
The cb_fn() must return one of the following value: