sdskv-client.h 3.92 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef sds_keyval_client_h
#define sds_keyval_client_h

#include <margo.h>
#include <stdint.h>
#include <sdskv-common.h>

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct sdskv_client* sdskv_client_t;
#define SDSKV_CLIENT_NULL ((sdskv_client_t)NULL)

typedef struct sdskv_provider_handle *sdskv_provider_handle_t;
#define SDSKV_PROVIDER_HANDLE_NULL ((sdskv_provider_handle_t)NULL)

int sdskv_client_init(margo_instance_id mid, sdskv_client_t* client);

int sdskv_client_finalize(sdskv_client_t client);

int sdskv_provider_handle_create(
        sdskv_client_t client,
        hg_addr_t addr,
        uint8_t mplex_id,
        sdskv_provider_handle_t* handle);

int sdskv_provider_handle_ref_incr(
        sdskv_provider_handle_t handle);

Matthieu Dorier's avatar
Matthieu Dorier committed
31
int sdskv_provider_handle_release(sdskv_provider_handle_t handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

int sdskv_open(
        sdskv_provider_handle_t provider,
        const char* db_name,
        sdskv_database_id_t* db_id);

int sdskv_put(sdskv_provider_handle_t provider, 
        sdskv_database_id_t db_id,
        const void *key, hg_size_t ksize,
        const void *value, hg_size_t vsize);

int sdskv_get(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id, 
        const void *key, hg_size_t ksize,
        void *value, hg_size_t* vsize);

int sdskv_length(sdskv_provider_handle_t db, 
        sdskv_database_id_t db_id, const void *key, 
        hg_size_t ksize, hg_size_t* vsize);

Matthieu Dorier's avatar
Matthieu Dorier committed
52
53
54
55
int sdskv_erase(sdskv_provider_handle_t db,
        sdskv_database_id_t db_id, const void *key,
        hg_size_t ksize);

Matthieu Dorier's avatar
Matthieu Dorier committed
56
57
int sdskv_list_keys(
        sdskv_provider_handle_t provider,
Matthieu Dorier's avatar
Matthieu Dorier committed
58
59
60
61
62
63
64
65
66
67
        sdskv_database_id_t db_id,  // db instance
        const void *start_key,  // we want keys strictly after this start_key
        hg_size_t start_ksize,  // size of the start_key
        void **keys,            // pointer to an array of void* pointers,
                                //     this array has size *max_keys
        hg_size_t* ksizes,      // pointer to an array of hg_size_t sizes
                                //    representing sizes allocated in
                                //     keys for each key
        hg_size_t* max_keys);   // maximum number of keys requested

Matthieu Dorier's avatar
Matthieu Dorier committed
68
69
int sdskv_list_keys_with_prefix(
        sdskv_provider_handle_t provider,
Matthieu Dorier's avatar
Matthieu Dorier committed
70
71
72
73
74
75
76
77
78
79
80
81
        sdskv_database_id_t db_id,  // db instance
        const void *start_key,  // we want keys strictly after this start_key
        hg_size_t start_ksize,  // size of the start_key
        const void *prefix,     // return only keys that begin with 'prefix'
        hg_size_t prefix_size,
        void **keys,            // pointer to an array of void* pointers,
                                // this array has size *max_keys
        hg_size_t* ksizes,      // pointer to an array of hg_size_t sizes 
                                // representing sizes allocated in
                                // keys for each key
        hg_size_t* max_keys);   // maximum number of keys requested

Matthieu Dorier's avatar
Matthieu Dorier committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
int sdskv_list_keyvals(
        sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id,
        const void *start_key,
        hg_size_t start_ksize,
        void **keys,
        hg_size_t* ksizes,
        void **values,
        hg_size_t* vsizes,
        hg_size_t* max_items);

int sdskv_list_keyvals_with_prefix(
        sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id,
        const void *start_key,
        hg_size_t start_ksize,
        const void *prefix,
        hg_size_t prefix_size,
        void **keys,
        hg_size_t* ksizes,
        void **values,
        hg_size_t* vsizes,
        hg_size_t* max_items);


Matthieu Dorier's avatar
Matthieu Dorier committed
107
108
109
110
111
112
113
114
115
116
117
/**
 * Shuts down a remote SDSKV service (given an address).
 * This will shutdown all the providers on the target address.
 * 
 * @param [in] client SDSKV client
 * @param [in] addr address of the server 
 * @returns 0 on success, -1 on failure 
 */
int sdskv_shutdown_service(
        sdskv_client_t client, hg_addr_t addr);

Matthieu Dorier's avatar
Matthieu Dorier committed
118
119
120
121
122
#if defined(__cplusplus)
}
#endif

#endif