Commit f3a8efe1 authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

commenting and cleaning up Makefile.am

parent b7a45a2d
......@@ -6,69 +6,67 @@ CLIENT_LiBS=@CLIENT_LIBS@
AM_CPPFLAGS = -I${srcdir}/src -I${srcdir}/include
bin_PROGRAMS = bin/sdskv-server-daemon \
bin/sdskv-shutdown \
test/sdskv-open-test \
test/sdskv-put-test \
test/sdskv-length-test \
test/sdskv-get-test \
test/sdskv-erase-test \
test/sdskv-list-keys-test \
test/sdskv-list-keyvals-test \
test/sdskv-list-keys-prefix-test \
test/sdskv-custom-cmp-test \
test/sdskv-custom-server-daemon
bin/sdskv-shutdown
check_PROGRAMS = test/sdskv-open-test \
test/sdskv-put-test \
test/sdskv-length-test \
test/sdskv-get-test \
test/sdskv-erase-test \
test/sdskv-list-keys-test \
test/sdskv-list-keyvals-test \
test/sdskv-list-keys-prefix-test \
test/sdskv-custom-cmp-test \
test/sdskv-custom-server-daemon
bin_sdskv_server_daemon_SOURCES = src/sdskv-server-daemon.c
bin_sdskv_server_daemon_DEPENDENCIES = lib/libsdskv-server.la
bin_sdskv_server_daemon_LDFLAGS = -Llib -lsdskv-server
bin_sdskv_server_daemon_LDADD = ${LIBS} -lsdskv-server ${SERVER_LIBS}
test_sdskv_custom_server_daemon_SOURCES = test/sdskv-custom-server-daemon.c
test_sdskv_custom_server_daemon_DEPENDENCIES = lib/libsdskv-server.la
test_sdskv_custom_server_daemon_LDFLAGS = -Llib -lsdskv-server
test_sdskv_custom_server_daemon_LDADD = ${LIBS} -lsdskv-server ${SERVER_LIBS}
bin_sdskv_shutdown_SOURCES = src/sdskv-shutdown.c
bin_sdskv_shutdown_DEPENDENCIES = lib/libsdskv-client.la
bin_sdskv_shutdown_LDFLAGS = -Llib -lsdskv-client
bin_sdskv_shutdown_LDADD = ${LIBS} -lsdskv-client
lib_LTLIBRARIES = lib/libkvclient.la \
lib/libkvserver.la \
lib/libkvgroupclient.la \
lib/libkvgroupserver.la \
lib/libsdskv-client.la \
#lib_LTLIBRARIES = lib/libkvclient.la \
# lib/libkvserver.la \
# lib/libkvgroupclient.la \
# lib/libkvgroupserver.la \
# lib/libsdskv-client.la \
# lib/libsdskv-server.la
lib_LTLIBRARIES = lib/libsdskv-client.la \
lib/libsdskv-server.la
lib_libsdskv_client_la_SOURCES = src/sdskv-client.c
lib_libkvclient_la_SOURCES = src/kv-client.c
#lib_libkvclient_la_SOURCES = src/kv-client.c
lib_libkvgroupclient_la_SOURCES = src/kvgroup-client.cc
#lib_libkvgroupclient_la_SOURCES = src/kvgroup-client.cc
lib_libkvserver_la_SOURCES = src/kv-server.cc \
src/datastore/datastore.cc
#lib_libkvserver_la_SOURCES = src/kv-server.cc \
# src/datastore/datastore.cc
lib_libsdskv_server_la_SOURCES = src/sdskv-server.cc \
src/datastore/datastore.cc
if BUILD_BWTREE
lib_libkvserver_la_SOURCES += src/BwTree/src/bwtree.cpp \
src/datastore/bwtree_datastore.cc
#lib_libkvserver_la_SOURCES += src/BwTree/src/bwtree.cpp \
# src/datastore/bwtree_datastore.cc
lib_libsdskv_server_la_SOURCES += src/BwTree/src/bwtree.cpp \
src/datastore/bwtree_datastore.cc
endif
if BUILD_BDB
lib_libkvserver_la_SOURCES += src/datastore/berkeleydb_datastore.cc
#lib_libkvserver_la_SOURCES += src/datastore/berkeleydb_datastore.cc
#
lib_libsdskv_server_la_SOURCES += src/datastore/berkeleydb_datastore.cc
endif
if BUILD_LEVELDB
lib_libkvserver_la_SOURCES += src/datastore/leveldb_datastore.cc
#lib_libkvserver_la_SOURCES += src/datastore/leveldb_datastore.cc
lib_libsdskv_server_la_SOURCES += src/datastore/leveldb_datastore.cc
endif
......@@ -78,7 +76,8 @@ include_HEADERS = include/sdskv-client.h \
include/sdskv-server.h \
include/sdskv-common.h
noinst_HEADERS = src/sds-keyval.h \
noinst_HEADERS = src/bulk.h \
src/sds-keyval.h \
src/sds-keyval-group.h \
src/sdskv-rpc-types.h \
src/datastore/datastore.h \
......@@ -93,10 +92,8 @@ noinst_HEADERS = src/sds-keyval.h \
src/BwTree/src/bloom_filter.h \
src/BwTree/src/sorted_small_set.h
#lib_libkvgroupserver_la_SOURCES = src/kvgroup-server.cc
lib_libkvgroupserver_la_SOURCES = src/kvgroup-server.cc
check_PROGRAMS = test/sdskv-open-test
TESTS = test/basic.sh \
test/open-test.sh \
......@@ -148,6 +145,11 @@ test_sdskv_custom_cmp_test_SOURCES = test/sdskv-custom-cmp-test.cc
test_sdskv_custom_cmp_test_DEPENDENCIES = lib/libsdskv-client.la
test_sdskv_custom_cmp_test_LDFLAGS = -Llib -lsdskv-client
test_sdskv_custom_server_daemon_SOURCES = test/sdskv-custom-server-daemon.c
test_sdskv_custom_server_daemon_DEPENDENCIES = lib/libsdskv-server.la
test_sdskv_custom_server_daemon_LDFLAGS = -Llib -lsdskv-server
test_sdskv_custom_server_daemon_LDADD = ${LIBS} -lsdskv-server ${SERVER_LIBS}
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = maint/sdskv-server.pc \
maint/sdskv-client.pc
......
......@@ -15,70 +15,227 @@ typedef struct sdskv_client* sdskv_client_t;
typedef struct sdskv_provider_handle *sdskv_provider_handle_t;
#define SDSKV_PROVIDER_HANDLE_NULL ((sdskv_provider_handle_t)NULL)
/**
* @brief Creates a SDSKV client.
*
* @param[in] mid Margo instance
* @param[out] client SDSKV client
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_client_init(margo_instance_id mid, sdskv_client_t* client);
/**
* @brief Finalizes a SDSKV client.
*
* @param[in] client SDSKV client to finalize
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_client_finalize(sdskv_client_t client);
/**
* @brief Creates a SDSKV provider handle.
*
* @param[in] client SDSKV client responsible for the provider handle
* @param[in] addr Mercury address of the provider
* @param[in] mplex_id Multiplex id of the provider
* @param[in] handle provider handle
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_handle_create(
sdskv_client_t client,
hg_addr_t addr,
uint8_t mplex_id,
sdskv_provider_handle_t* handle);
/**
* @brief Increments the reference counter of a provider handle.
*
* @param handle provider handle
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_handle_ref_incr(
sdskv_provider_handle_t handle);
/**
* @brief Releases the provider handle. This will decrement the
* reference counter, and free the provider handle if the reference
* counter reaches 0.
*
* @param[in] handle provider handle to release.
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_handle_release(sdskv_provider_handle_t handle);
/**
* @brief Opens a database. This effectively contacts the provider
* pointed to by the provider handle and request the database id
* associated with the database name.
*
* @param[in] provider provider handle
* @param[in] db_name name of the database to lookup
* @param[out] db_id database id
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_open(
sdskv_provider_handle_t provider,
const char* db_name,
sdskv_database_id_t* db_id);
/**
* @brief Puts a key/value pair into the database.
*
* @param provider provider handle managing the database
* @param db_id targeted database id
* @param key key to store
* @param ksize size (in bytes) of the key
* @param value value to store
* @param vsize size (in bytes) of the value
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
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);
/**
* @brief Gets the value associated with a given key.
* vsize needs to be set to the current size of the allocated
* value buffer. After a succesful call to sdskv_get, vsize
* will hold the actual size of the key. Note that the size
* of a value can get obtained using sdskv_length.
*
* @param[in] provider provider handle
* @param[in] db_id database id of the target database
* @param[in] key key to lookup
* @param[in] ksize size of the key
* @param[out] value pointer to buffer to put the value
* @param[inout] vsize size of the value
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
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,
/**
* @brief Gets the length of a value associated with a given key.
*
* @param[in] handle provider handle
* @param[in] db_id database id
* @param[in] key key to lookup
* @param[in] ksize size of the key
* @param[out] vsize size of the associated value
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_length(sdskv_provider_handle_t handle,
sdskv_database_id_t db_id, const void *key,
hg_size_t ksize, hg_size_t* vsize);
int sdskv_erase(sdskv_provider_handle_t db,
/**
* @brief Erases the key/value pair pointed by the given key.
*
* @param handle provider handle
* @param db_id database id
* @param key key to erase
* @param ksize size of the key
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_erase(sdskv_provider_handle_t handle,
sdskv_database_id_t db_id, const void *key,
hg_size_t ksize);
/**
* Lists at most max_keys keys starting strictly after start_key,
* whether start_key is effectively in the database or not. "strictly after"
* must be understood in the sens of the custom comparison function set
* for the target database, if such comparison function has been set.
* Passing NULL as start_key allows one to start listing from the beginning
* of the database.
* keys must be an array of max_keys void* elements, each element keys[i]
* being a preallocated buffer of size ksizes[i]. ksizes must be an array
* of sizes of the preallocated buffers. After a successful call, max_keys
* is set to the actual number of keys retrieved, ksizes[i] is set to the
* actual size of the i-th key, and keys[i] contains the i-th key. The call
* will fail if at least one of the preallocated size is too small to hold
* the key.
*
* @param[in] provider provider handle
* @param[in] db_id database id
* @param[in] start_key starting key
* @param[in] start_ksize size of the starting key
* @param[out] keys array of buffers to hold returned keys
* @param[inout] ksizes array of key sizes
* @param[inout] max_keys max keys requested
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_list_keys(
sdskv_provider_handle_t provider,
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
sdskv_database_id_t db_id,
const void *start_key,
hg_size_t start_ksize,
void **keys,
hg_size_t* ksizes,
hg_size_t* max_keys);
/**
* @brief Same as sdskv_list_keys, but provides a prefix
* that returned keys must start with. Note that "prefix" is understood
* in the sens of the bytes making up the key, not in the sens of any
* comparison function set by the user on the provider side.
*
* @param[in] provider provider handle
* @param[in] db_id database id
* @param[in] start_key starting key
* @param[in] start_ksize size of the starting key
* @param[in] prefix prefix that returned keys must match
* @param[in] prefix_size size of the prefix
* @param[out] keys array of buffers to hold returned keys
* @param[inout] ksizes array of key sizes
* @param[inout] max_keys max keys requested
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_list_keys_with_prefix(
sdskv_provider_handle_t provider,
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'
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, // 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
void **keys,
hg_size_t* ksizes,
hg_size_t* max_keys);
/**
* @brief Same as sdskv_list_keys but returns also the values.
* The values array must be an array of max_keys sizes, with
* each element values[i] being a buffer of size vsizes[i].
* After a successful call, values[i] will hold the i-th value
* and vsizes[i] will be set to the actual size of the i-th value.
*
* @param[in] provider provider handle
* @param[in] db_id database id
* @param[in] start_key starting key
* @param[in] start_ksize size of the starting key
* @param[out] keys array of buffers to hold returned keys
* @param[inout] ksizes array of key sizes
* @param[inout] values array of buffers to hold returned values
* @param[inout] vsizes array of value sizes
* @param[inout] max_keys max keys requested
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_list_keyvals(
sdskv_provider_handle_t provider,
sdskv_database_id_t db_id,
......@@ -90,6 +247,24 @@ int sdskv_list_keyvals(
hg_size_t* vsizes,
hg_size_t* max_items);
/**
* @brief Same as sdskv_list_keyvals but lets the user provide
* a prefix that returned keys must satisfy.
*
* @param[in] provider provider handle
* @param[in] db_id database id
* @param[in] start_key starting key
* @param[in] start_ksize size of the starting key
* @param[in] prefix prefix that returned keys must match
* @param[in] prefix_size size of the prefix
* @param[out] keys array of buffers to hold returned keys
* @param[inout] ksizes array of key sizes
* @param[inout] values array of buffers to hold returned values
* @param[inout] vsizes array of value sizes
* @param[inout] max_keys max keys requested
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_list_keyvals_with_prefix(
sdskv_provider_handle_t provider,
sdskv_database_id_t db_id,
......@@ -103,14 +278,14 @@ int sdskv_list_keyvals_with_prefix(
hg_size_t* vsizes,
hg_size_t* max_items);
/**
* 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
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_shutdown_service(
sdskv_client_t client, hg_addr_t addr);
......
......@@ -8,10 +8,10 @@ extern "C" {
typedef enum sdskv_db_type_t
{
KVDB_MAP,
KVDB_BWTREE,
KVDB_LEVELDB,
KVDB_BERKELEYDB
KVDB_MAP, /* Datastore implementation using std::map */
KVDB_BWTREE, /* Datastore implementation using a BwTree */
KVDB_LEVELDB, /* Datastore implementation using LevelDB */
KVDB_BERKELEYDB /* Datasotre implementation using BerkeleyDB */
} sdskv_db_type_t;
typedef uint64_t sdskv_database_id_t;
......
......@@ -22,6 +22,16 @@ extern "C" {
typedef struct sdskv_server_context_t* sdskv_provider_t;
typedef int (*sdskv_compare_fn)(const void*, size_t, const void*, size_t);
/**
* @brief Creates a new provider.
*
* @param[in] mid Margo instance
* @param[in] mplex_id multiplex id
* @param[in] pool Argobots pool
* @param[out] provider provider handle
*
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_register(
margo_instance_id mid,
uint8_t mplex_id,
......@@ -31,12 +41,13 @@ int sdskv_provider_register(
/**
* Makes the provider start managing a database.
*
* @param provider provider
* @param db_name name of the database
* @param db_type type of database
* @param db_id resulting id identifying the database
* @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
*
* @return 0 on success, -1 on failure
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_add_database(
sdskv_provider_t provider,
......@@ -46,12 +57,14 @@ int sdskv_provider_add_database(
sdskv_database_id_t* sb_id);
/**
* Makes the provider stop managing a database.
* 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.
*
* @param provider provider
* @param db_id id of the database to remove
*
* @return 0 on success, -1 on failure
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_remove_database(
sdskv_provider_t provider,
......@@ -62,7 +75,7 @@ int sdskv_provider_remove_database(
*
* @param provider provider
*
* @return 0 on success, -1 on failure
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_remove_all_databases(
sdskv_provider_t provider);
......@@ -73,7 +86,7 @@ int sdskv_provider_remove_all_databases(
* @param provider provider
* @param num_db resulting number of databases
*
* @return 0 on success, -1 on failure
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_count_databases(
sdskv_provider_t provider,
......@@ -85,10 +98,10 @@ int sdskv_provider_count_databases(
* space to hold all the ids (use sdskv_provider_count_databases
* to know how many databases are managed).
*
* @param provider provider
* @param databases resulting targer ids
* @param[in] provider provider
* @param[out] databases resulting database ids
*
* @return 0 on success, -1 on failure
* @return SDSKV_SUCCESS or error code defined in sdskv-common.h
*/
int sdskv_provider_list_databases(
sdskv_provider_t provider,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment