refact
This commit is contained in:
parent
6dc0ce0b9c
commit
b50676b6c0
|
@ -42,7 +42,7 @@ if(${BUILD_WITH_LEVELDB})
|
|||
endif(${BUILD_WITH_LEVELDB})
|
||||
|
||||
## rocksdb
|
||||
option(BUILD_WITH_ROCKSDB "If build with rocksdb" OFF)
|
||||
option(BUILD_WITH_ROCKSDB "If build with rocksdb" ON)
|
||||
if(${BUILD_WITH_ROCKSDB})
|
||||
cat("${CMAKE_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${DEPS_TMP_FILE})
|
||||
endif(${BUILD_WITH_ROCKSDB})
|
||||
|
|
|
@ -48,6 +48,7 @@ endif(${BUILD_WITH_LEVELDB})
|
|||
if(${BUILD_WITH_ROCKSDB})
|
||||
option(WITH_TESTS "" OFF)
|
||||
option(WITH_BENCHMARK_TOOLS "" OFF)
|
||||
option(ROCKSDB_BUILD_SHARED "Build shared versions of the RocksDB libraries" OFF)
|
||||
add_subdirectory(rocksdb)
|
||||
target_include_directories(
|
||||
rocksdb
|
||||
|
|
|
@ -20,6 +20,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SRow SRow;
|
||||
|
||||
#define rowType(r)
|
||||
#define rowLen(r)
|
||||
#define rowVersion(r)
|
||||
#define rowNCols(r)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,7 @@ add_subdirectory(tq)
|
|||
add_subdirectory(tsdb)
|
||||
|
||||
aux_source_directory(src VNODE_SRC)
|
||||
add_library(vnode ${VNODE_SRC})
|
||||
add_library(vnode STATIC ${VNODE_SRC})
|
||||
target_include_directories(
|
||||
vnode
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
aux_source_directory(src META_SRC)
|
||||
add_library(meta ${META_SRC})
|
||||
add_library(meta STATIC ${META_SRC})
|
||||
target_include_directories(
|
||||
meta
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode/meta"
|
||||
|
@ -8,4 +8,9 @@ target_include_directories(
|
|||
target_link_libraries(
|
||||
meta
|
||||
PUBLIC common
|
||||
)
|
||||
)
|
||||
target_link_libraries(meta PUBLIC rocksdb)
|
||||
|
||||
# if(${BUILD_TEST})
|
||||
# add_subdirectory(test)
|
||||
# endif(${BUILD_TEST})
|
||||
|
|
|
@ -13,6 +13,72 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <rocksdb/c.h>
|
||||
|
||||
#include "thash.h"
|
||||
#include "tlist.h"
|
||||
#include "tlockfree.h"
|
||||
#include "ttypes.h"
|
||||
|
||||
#include "meta.h"
|
||||
|
||||
typedef struct STable {
|
||||
uint64_t uid;
|
||||
tstr * name;
|
||||
uint64_t suid;
|
||||
SArray * schema;
|
||||
} STable;
|
||||
|
||||
typedef struct STableObj {
|
||||
bool pin;
|
||||
uint64_t ref;
|
||||
SRWLatch latch;
|
||||
uint64_t offset;
|
||||
SList * ctbList; // child table list
|
||||
STable * pTable;
|
||||
} STableObj;
|
||||
|
||||
struct SMeta {
|
||||
pthread_rwlock_t rwLock;
|
||||
|
||||
SHashObj * pTableObjHash; // uid --> STableObj
|
||||
SList * stbList; // super table list
|
||||
rocksdb_t *tbnameDb; // tbname --> uid
|
||||
rocksdb_t *tagDb; // uid --> tag
|
||||
rocksdb_t *schemaDb;
|
||||
size_t totalUsed;
|
||||
};
|
||||
|
||||
SMeta *metaOpen(SMetaOptions *options) {
|
||||
SMeta *pMeta = NULL;
|
||||
char * err = NULL;
|
||||
|
||||
pMeta = (SMeta *)calloc(1, sizeof(*pMeta));
|
||||
if (pMeta == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pthread_rwlock_init(&(pMeta->rwLock), NULL);
|
||||
|
||||
pMeta->pTableObjHash = taosHashInit(1024, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
|
||||
|
||||
pMeta->stbList = tdListNew(sizeof(STableObj *));
|
||||
|
||||
// Open tbname DB
|
||||
rocksdb_options_t *tbnameDbOptions = rocksdb_options_create();
|
||||
pMeta->tbnameDb = rocksdb_open(tbnameDbOptions, "tbname_uid_db", &err);
|
||||
|
||||
// Open tag DB
|
||||
pMeta->tagDb = rocksdb_open(tbnameDbOptions, "uid_tag_db", &err);
|
||||
|
||||
// Open schema DB
|
||||
pMeta->schemaDb = rocksdb_open(tbnameDbOptions, "schema_db", &err);
|
||||
|
||||
return pMeta;
|
||||
}
|
||||
|
||||
void metaClose(SMeta *pMeta) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
int metaCommit(SMeta *meta) { return 0; }
|
|
@ -0,0 +1,18 @@
|
|||
add_executable(metaTest "")
|
||||
target_sources(metaTest
|
||||
PRIVATE
|
||||
"../src/meta.c"
|
||||
"metaTests.cpp"
|
||||
)
|
||||
target_include_directories(metaTest
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/include/server/vnode/meta"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
)
|
||||
target_link_libraries(metaTest
|
||||
os
|
||||
util
|
||||
common
|
||||
rocksdb
|
||||
gtest_main
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "meta.h"
|
||||
|
||||
TEST(MetaTest, meta_open_test) {
|
||||
std::cout << "Hello META!" << std::endl;
|
||||
}
|
Loading…
Reference in New Issue