-
-
Save mm304321141/eddc16a78f6bd021b29032a13799c8b8 to your computer and use it in GitHub Desktop.
API ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
API | |
option { | |
bool instantaneous = false | |
sync_level sync_level = write_file | |
handle snapshoot = nullptr | |
} | |
// column | |
void create_column(option, name, key_type, value_type, callback) | |
key_type | |
var_binary, fixed_binary, integer_u32, integer_u64, integer_i32, integer_i64, float_32, float_64 | |
value_type | |
var_binary, fixed_binary, integer_u32, integer_i32, integer_u64, integer_i64, integer_u128, integer_i128, float_32, float_64 | |
callback(error_code, column_id, name, key_type, value_type) | |
void get_column(option, column_id, callback) | |
callback(error_code, column_id, name, key_type, value_type) | |
void get_column(option, name, callback) | |
callback(error_code, column_id, name, key_type, value_type) | |
void enum_column(option, callback) | |
callback(error_code, column_id, name, key_type, value_type) | |
void delete_column(option, column_id, callback) | |
callback(error_code, column_id) | |
// record | |
handle get_snapshoot() | |
void get(option, column_id, key, callback) | |
callback(error_code, column_id, key, value, snapshoot) | |
void put(option, column_id, key, value, callback) | |
callback(error_code, column_id, key, value, snapshoot) | |
void del(option, column_id, key, callback) | |
callback(error_code, column_id, key, snapshoot) | |
void scan(option, column_id, scan_type, key, callback) | |
seek_type | |
front, back, for_next, for_less | |
callback(error_code, column_id, key, value, snapshoot) | |
void eliminate_range(option, column_id, key_left, key_right, include_left, include_right, callback) | |
callback(error_code, column_id, key) | |
// info | |
size_t estimate(option, column_id, key_left, key_right, callback) | |
callback(error_code, column_id, key_left, key_right, key_count) | |
... | |
DEMO | |
uint32_t cid = uint32_t(-1); | |
db->create_column(option{true}, "default", var_binary, var_binary, | |
[&](error_code, column_id, key_type, value_type){ | |
assert(!error_code); | |
cid = column_id; | |
} | |
); | |
db->put(option{false}, cid, "abc", "123", | |
[](error_code, column_id, key, value, snapshoot){ | |
assert(!error_code); | |
fprintf(stderr, "async put abc sunccess\n"); | |
} | |
); // sync | |
db->put(option{true}, cid, "def", "456", | |
[](error_code, column_id, key, value, snapshoot){ | |
assert(!error_code); | |
fprintf(stderr, "sync put def success\n"); | |
} | |
); // async | |
db->scan(option{true}, cid, front, nullptr, | |
[](error_code, column_id, key, value, snapshoot) { | |
if (error_code == scan_invalid) { | |
return false; | |
} | |
fprintf(stderr, "key %s value %s\n", key, value); | |
return true; | |
} | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment