Skip to content

Commit

Permalink
Update to new sds-keyval API.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelkgutierrez committed Aug 29, 2018
1 parent 0513f0f commit 896356f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/sdsdkv-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class sdsdkv_iconfig {
//
sdsdkv_config_db db_type;
//
sdsdkv_compare_fn cmp_fn;
std::string cmp_fn_name;
//
std::string group_name;
//
Expand All @@ -91,7 +91,12 @@ class sdsdkv_iconfig {
rpc_thread_count = config.rpc_thread_count;
hash_be = config.hash_be;
db_type = config.db_type;
cmp_fn = config.cmp_fn;
if (config.cmp_fn_name == SDSDKV_COMPARE_DEFAULT) {
cmp_fn_name = string("");
}
else {
cmp_fn_name = string(config.cmp_fn_name);
}
group_name = string(config.group_name);
db_path = string(config.db_path);
comm_protocol = string(config.comm_protocol);
Expand Down
10 changes: 9 additions & 1 deletion src/sdsdkv-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ struct sdsdkv_server : public personality {
return SDSDKV_SUCCESS;
}
//
const char *
m_get_cmp_fn_name(
const std::string &i_name
) {
if (i_name.empty()) return SDSDKV_COMPARE_DEFAULT;
else return i_name.c_str();
}
//
int
m_keyval_add_db(void)
{
Expand All @@ -126,7 +134,7 @@ struct sdsdkv_server : public personality {
db_name.c_str(),
m_config->db_path.c_str(),
sdsdkv_iconfig::get_real_db_type(m_config->db_type),
m_config->cmp_fn,
m_get_cmp_fn_name(m_config->cmp_fn_name),
db_no_overwrite
};
int rc = sdskv_provider_attach_database(
Expand Down
5 changes: 3 additions & 2 deletions src/sdsdkv.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ extern "C" {
#define SDSDKV 1

/** Default comparison function type. */
// TODO(skg) Add registration function for custom compare.
#define SDSDKV_COMPARE_DEFAULT NULL

/** Custom comparison function type. */
Expand Down Expand Up @@ -120,8 +121,8 @@ typedef struct sdsdkv_config {
sdsdkv_config_hashing hash_be;
/** Database type. */
sdsdkv_config_db db_type;
/** Key comparison function. */
sdsdkv_compare_fn cmp_fn;
/** Name of registered key comparison function. */
char *cmp_fn_name;
/** Group name. */
char *group_name;
/** If applicable, the path where database files will be written. */
Expand Down

0 comments on commit 896356f

Please sign in to comment.