add deps test
This commit is contained in:
parent
36c20ec617
commit
25e569e129
|
@ -99,3 +99,4 @@ TAGS
|
||||||
|
|
||||||
deps/*
|
deps/*
|
||||||
!deps/CMakeLists.txt
|
!deps/CMakeLists.txt
|
||||||
|
!deps/test
|
||||||
|
|
|
@ -24,3 +24,9 @@ option(
|
||||||
"If build with lucene"
|
"If build with lucene"
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
BUILD_DEPENDENCY_TESTS
|
||||||
|
"If build dependency tests"
|
||||||
|
OFF
|
||||||
|
)
|
|
@ -1,3 +1,6 @@
|
||||||
|
# ================================================================================================
|
||||||
|
# DEPENDENCIES
|
||||||
|
# ================================================================================================
|
||||||
# googletest
|
# googletest
|
||||||
if(${BUILD_TEST})
|
if(${BUILD_TEST})
|
||||||
add_subdirectory(googletest)
|
add_subdirectory(googletest)
|
||||||
|
@ -63,3 +66,10 @@ if(${BUILD_WITH_LUCENE})
|
||||||
option(ENABLE_TEST "Enable the tests" OFF)
|
option(ENABLE_TEST "Enable the tests" OFF)
|
||||||
add_subdirectory(lucene)
|
add_subdirectory(lucene)
|
||||||
endif(${BUILD_WITH_LUCENE})
|
endif(${BUILD_WITH_LUCENE})
|
||||||
|
|
||||||
|
# ================================================================================================
|
||||||
|
# DEPENDENCY TEST
|
||||||
|
# ================================================================================================
|
||||||
|
if(${BUILD_DEPENDENCY_TESTS})
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif(${BUILD_DEPENDENCY_TESTS})
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# rocksdb
|
||||||
|
if(${BUILD_WITH_ROCKSDB})
|
||||||
|
add_subdirectory(rocksdb)
|
||||||
|
endif(${BUILD_WITH_ROCKSDB})
|
|
@ -0,0 +1,6 @@
|
||||||
|
add_executable(rocksdbTest "")
|
||||||
|
target_sources(rocksdbTest
|
||||||
|
PRIVATE
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/main.c"
|
||||||
|
)
|
||||||
|
target_link_libraries(rocksdbTest rocksdb)
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h> // sysconf() - get CPU count
|
||||||
|
#include "rocksdb/c.h"
|
||||||
|
|
||||||
|
// const char DBPath[] = "/tmp/rocksdb_c_simple_example";
|
||||||
|
const char DBPath[] = "rocksdb_c_simple_example";
|
||||||
|
const char DBBackupPath[] = "/tmp/rocksdb_c_simple_example_backup";
|
||||||
|
|
||||||
|
int main(int argc, char const *argv[]) {
|
||||||
|
rocksdb_t * db;
|
||||||
|
rocksdb_backup_engine_t *be;
|
||||||
|
rocksdb_options_t * options = rocksdb_options_create();
|
||||||
|
rocksdb_options_set_create_if_missing(options, 1);
|
||||||
|
|
||||||
|
// open DB
|
||||||
|
char *err = NULL;
|
||||||
|
db = rocksdb_open(options, DBPath, &err);
|
||||||
|
|
||||||
|
// Write
|
||||||
|
rocksdb_writeoptions_t *writeoptions = rocksdb_writeoptions_create();
|
||||||
|
rocksdb_put(db, writeoptions, "key", 3, "value", 5, &err);
|
||||||
|
|
||||||
|
// Read
|
||||||
|
rocksdb_readoptions_t *readoptions = rocksdb_readoptions_create();
|
||||||
|
rocksdb_readoptions_set_snapshot(readoptions, rocksdb_create_snapshot(db));
|
||||||
|
size_t vallen = 0;
|
||||||
|
char * val = rocksdb_get(db, readoptions, "key", 3, &vallen, &err);
|
||||||
|
printf("val:%s\n", val);
|
||||||
|
|
||||||
|
// Update
|
||||||
|
// rocksdb_put(db, writeoptions, "key", 3, "eulav", 5, &err);
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
rocksdb_delete(db, writeoptions, "key", 3, &err);
|
||||||
|
|
||||||
|
// Read again
|
||||||
|
val = rocksdb_get(db, readoptions, "key", 3, &vallen, &err);
|
||||||
|
printf("val:%s\n", val);
|
||||||
|
|
||||||
|
rocksdb_close(db);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue