sdskv-server.h 2.96 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1
2
3
4
5
6
7
8
9
10
/*
 * (C) 2018 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

#ifndef __SDSKV_SERVER_H
#define __SDSKV_SERVER_H

#include <margo.h>
Matthieu Dorier's avatar
Matthieu Dorier committed
11
#include <sdskv-common.h>
Matthieu Dorier's avatar
Matthieu Dorier committed
12
13
14
15
16
17

#ifdef __cplusplus
extern "C" {
#endif

#define SDSKV_ABT_POOL_DEFAULT ABT_POOL_NULL
18
#define SDSKV_PROVIDER_ID_DEFAULT 0
Matthieu Dorier's avatar
Matthieu Dorier committed
19
#define SDSKV_PROVIDER_IGNORE NULL
20
#define SDSKV_COMPARE_DEFAULT NULL
Matthieu Dorier's avatar
Matthieu Dorier committed
21
22

typedef struct sdskv_server_context_t* sdskv_provider_t;
23
typedef int (*sdskv_compare_fn)(const void*, size_t, const void*, size_t);
Matthieu Dorier's avatar
Matthieu Dorier committed
24

25
26
27
28
/**
 * @brief Creates a new provider.
 *
 * @param[in] mid Margo instance
29
 * @param[in] provider_id provider id
30
31
32
33
34
 * @param[in] pool Argobots pool
 * @param[out] provider provider handle
 *
 * @return SDSKV_SUCCESS or error code defined in sdskv-common.h
 */
Matthieu Dorier's avatar
Matthieu Dorier committed
35
36
int sdskv_provider_register(
        margo_instance_id mid,
37
        uint16_t provider_id,
Matthieu Dorier's avatar
Matthieu Dorier committed
38
39
40
41
42
43
        ABT_pool pool,
        sdskv_provider_t* provider);

/**
 * Makes the provider start managing a database.
 *
44
45
46
47
48
 * @param[in] provider provider
 * @param[in] db_name name of the database
 * @param[in] db_type type of database
 * @param[in] comp_fn comparison function for the database
 * @param[out] db_id resulting id identifying the database
Matthieu Dorier's avatar
Matthieu Dorier committed
49
 *
50
 * @return SDSKV_SUCCESS or error code defined in sdskv-common.h
Matthieu Dorier's avatar
Matthieu Dorier committed
51
 */
Matthieu Dorier's avatar
Matthieu Dorier committed
52
int sdskv_provider_add_database(
Matthieu Dorier's avatar
Matthieu Dorier committed
53
54
55
        sdskv_provider_t provider,
        const char* db_name,
        sdskv_db_type_t db_type,
56
        sdskv_compare_fn comp_fn,
Matthieu Dorier's avatar
Matthieu Dorier committed
57
58
59
        sdskv_database_id_t* sb_id);

/**
60
61
62
 * Makes the provider stop managing a database and deletes the
 * database. This will effectively destroy the database if it is
 * not backed up by a file.
Matthieu Dorier's avatar
Matthieu Dorier committed
63
64
65
66
 *
 * @param provider provider
 * @param db_id id of the database to remove
 *
67
 * @return SDSKV_SUCCESS or error code defined in sdskv-common.h
Matthieu Dorier's avatar
Matthieu Dorier committed
68
 */
Matthieu Dorier's avatar
Matthieu Dorier committed
69
int sdskv_provider_remove_database(
Matthieu Dorier's avatar
Matthieu Dorier committed
70
71
72
73
74
75
76
77
        sdskv_provider_t provider,
        sdskv_database_id_t db_id);

/**
 * Removes all the databases associated with a provider.
 *
 * @param provider provider
 *
78
 * @return SDSKV_SUCCESS or error code defined in sdskv-common.h
Matthieu Dorier's avatar
Matthieu Dorier committed
79
80
81
82
83
84
85
86
87
88
 */
int sdskv_provider_remove_all_databases(
        sdskv_provider_t provider);

/**
 * Returns the number of databases that this provider manages.
 *
 * @param provider provider
 * @param num_db resulting number of databases
 *
89
 * @return SDSKV_SUCCESS or error code defined in sdskv-common.h
Matthieu Dorier's avatar
Matthieu Dorier committed
90
91
92
93
94
95
96
97
98
99
100
 */
int sdskv_provider_count_databases(
        sdskv_provider_t provider,
        uint64_t* num_db);

/**
 * List the database ids of the databases managed by this provider.
 * The databases array must be pre-allocated with at least enough
 * space to hold all the ids (use sdskv_provider_count_databases
 * to know how many databases are managed).
 *
101
102
 * @param[in] provider provider
 * @param[out] databases resulting database ids
Matthieu Dorier's avatar
Matthieu Dorier committed
103
 *
104
 * @return SDSKV_SUCCESS or error code defined in sdskv-common.h
Matthieu Dorier's avatar
Matthieu Dorier committed
105
106
107
108
109
110
111
112
113
114
 */
int sdskv_provider_list_databases(
        sdskv_provider_t provider,
        sdskv_database_id_t* databases);

#ifdef __cplusplus
}
#endif

#endif /* __BAKE_SERVER_H */