提交 b50676b6 编写于 作者: H Hongze Cheng

refact

上级 6dc0ce0b
...@@ -42,7 +42,7 @@ if(${BUILD_WITH_LEVELDB}) ...@@ -42,7 +42,7 @@ if(${BUILD_WITH_LEVELDB})
endif(${BUILD_WITH_LEVELDB}) endif(${BUILD_WITH_LEVELDB})
## rocksdb ## rocksdb
option(BUILD_WITH_ROCKSDB "If build with rocksdb" OFF) option(BUILD_WITH_ROCKSDB "If build with rocksdb" ON)
if(${BUILD_WITH_ROCKSDB}) if(${BUILD_WITH_ROCKSDB})
cat("${CMAKE_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${DEPS_TMP_FILE}) cat("${CMAKE_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${DEPS_TMP_FILE})
endif(${BUILD_WITH_ROCKSDB}) endif(${BUILD_WITH_ROCKSDB})
......
...@@ -48,6 +48,7 @@ endif(${BUILD_WITH_LEVELDB}) ...@@ -48,6 +48,7 @@ endif(${BUILD_WITH_LEVELDB})
if(${BUILD_WITH_ROCKSDB}) if(${BUILD_WITH_ROCKSDB})
option(WITH_TESTS "" OFF) option(WITH_TESTS "" OFF)
option(WITH_BENCHMARK_TOOLS "" OFF) option(WITH_BENCHMARK_TOOLS "" OFF)
option(ROCKSDB_BUILD_SHARED "Build shared versions of the RocksDB libraries" OFF)
add_subdirectory(rocksdb) add_subdirectory(rocksdb)
target_include_directories( target_include_directories(
rocksdb rocksdb
......
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
extern "C" { extern "C" {
#endif #endif
typedef struct SRow SRow;
#define rowType(r)
#define rowLen(r)
#define rowVersion(r)
#define rowNCols(r)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -3,7 +3,7 @@ add_subdirectory(tq) ...@@ -3,7 +3,7 @@ add_subdirectory(tq)
add_subdirectory(tsdb) add_subdirectory(tsdb)
aux_source_directory(src VNODE_SRC) aux_source_directory(src VNODE_SRC)
add_library(vnode ${VNODE_SRC}) add_library(vnode STATIC ${VNODE_SRC})
target_include_directories( target_include_directories(
vnode vnode
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode" PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode"
......
aux_source_directory(src META_SRC) aux_source_directory(src META_SRC)
add_library(meta ${META_SRC}) add_library(meta STATIC ${META_SRC})
target_include_directories( target_include_directories(
meta meta
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode/meta" PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode/meta"
...@@ -9,3 +9,8 @@ target_link_libraries( ...@@ -9,3 +9,8 @@ target_link_libraries(
meta meta
PUBLIC common PUBLIC common
) )
target_link_libraries(meta PUBLIC rocksdb)
# if(${BUILD_TEST})
# add_subdirectory(test)
# endif(${BUILD_TEST})
...@@ -13,6 +13,72 @@ ...@@ -13,6 +13,72 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * 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" #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; } int metaCommit(SMeta *meta) { return 0; }
\ No newline at end of file
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
)
\ No newline at end of file
#include <gtest/gtest.h>
#include <iostream>
#include "meta.h"
TEST(MetaTest, meta_open_test) {
std::cout << "Hello META!" << std::endl;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册