未验证 提交 69b7348e 编写于 作者: H Hongze Cheng 提交者: GitHub

Merge pull request #17316 from taosdata/feat/tdlite

refact: adjust some code for further dev
...@@ -17,11 +17,12 @@ include(${TD_SUPPORT_DIR}/cmake.platform) ...@@ -17,11 +17,12 @@ include(${TD_SUPPORT_DIR}/cmake.platform)
include(${TD_SUPPORT_DIR}/cmake.define) include(${TD_SUPPORT_DIR}/cmake.define)
include(${TD_SUPPORT_DIR}/cmake.options) include(${TD_SUPPORT_DIR}/cmake.options)
include(${TD_SUPPORT_DIR}/cmake.version) include(${TD_SUPPORT_DIR}/cmake.version)
include(${TD_SUPPORT_DIR}/cmake.install)
# contrib # contrib
add_subdirectory(contrib) add_subdirectory(contrib)
set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES OFF)
# api # api
add_library(api INTERFACE) add_library(api INTERFACE)
target_include_directories(api INTERFACE "include/client") target_include_directories(api INTERFACE "include/client")
...@@ -36,8 +37,7 @@ add_subdirectory(source) ...@@ -36,8 +37,7 @@ add_subdirectory(source)
add_subdirectory(tools) add_subdirectory(tools)
add_subdirectory(utils) add_subdirectory(utils)
add_subdirectory(examples/c) add_subdirectory(examples/c)
include(${TD_SUPPORT_DIR}/cmake.install)
# docs # docs
add_subdirectory(docs/doxgen) add_subdirectory(docs/doxgen)
\ No newline at end of file
# tests (TODO)
...@@ -35,7 +35,11 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) { ...@@ -35,7 +35,11 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
*ppMeta = NULL; *ppMeta = NULL;
// create handle // create handle
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3; if (pVnode->pTfs) {
slen = strlen(tfsGetPrimaryPath(pVnode->pTfs)) + strlen(pVnode->path) + strlen(VNODE_META_DIR) + 3;
} else {
slen = strlen(pVnode->path) + strlen(VNODE_META_DIR) + 2;
}
if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) { if ((pMeta = taosMemoryCalloc(1, sizeof(*pMeta) + slen)) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1; return -1;
...@@ -43,8 +47,12 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) { ...@@ -43,8 +47,12 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
metaInitLock(pMeta); metaInitLock(pMeta);
pMeta->path = (char *)&pMeta[1]; pMeta->path = (char *)&pMeta[1];
sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP, if (pVnode->pTfs) {
VNODE_META_DIR); sprintf(pMeta->path, "%s%s%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path, TD_DIRSEP,
VNODE_META_DIR);
} else {
sprintf(pMeta->path, "%s%s%s", pVnode->path, TD_DIRSEP, VNODE_META_DIR);
}
taosRealPath(pMeta->path, NULL, slen); taosRealPath(pMeta->path, NULL, slen);
pMeta->pVnode = pVnode; pMeta->pVnode = pVnode;
......
...@@ -417,6 +417,7 @@ _err: ...@@ -417,6 +417,7 @@ _err:
// EXPOSED APIS ==================================================================================== // EXPOSED APIS ====================================================================================
int32_t tsdbFSOpen(STsdb *pTsdb) { int32_t tsdbFSOpen(STsdb *pTsdb) {
int32_t code = 0; int32_t code = 0;
SVnode *pVnode = pTsdb->pVnode;
// open handle // open handle
pTsdb->fs.pDelFile = NULL; pTsdb->fs.pDelFile = NULL;
...@@ -429,8 +430,12 @@ int32_t tsdbFSOpen(STsdb *pTsdb) { ...@@ -429,8 +430,12 @@ int32_t tsdbFSOpen(STsdb *pTsdb) {
// load fs or keep empty // load fs or keep empty
char fname[TSDB_FILENAME_LEN]; char fname[TSDB_FILENAME_LEN];
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sCURRENT", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), TD_DIRSEP, if (pVnode->pTfs) {
pTsdb->path, TD_DIRSEP); snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sCURRENT", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), TD_DIRSEP,
pTsdb->path, TD_DIRSEP);
} else {
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%sCURRENT", pTsdb->path, TD_DIRSEP);
}
if (!taosCheckExistFile(fname)) { if (!taosCheckExistFile(fname)) {
// empty one // empty one
......
...@@ -57,10 +57,13 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee ...@@ -57,10 +57,13 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
} else { } else {
memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(STsdbKeepCfg)); memcpy(&pTsdb->keepCfg, pKeepCfg, sizeof(STsdbKeepCfg));
} }
// pTsdb->fs = tsdbNewFS(REPO_KEEP_CFG(pTsdb));
// create dir // create dir
tfsMkdir(pVnode->pTfs, pTsdb->path); if (pVnode->pTfs) {
tfsMkdir(pVnode->pTfs, pTsdb->path);
} else {
taosMkDir(pTsdb->path);
}
// open tsdb // open tsdb
if (tsdbFSOpen(pTsdb) < 0) { if (tsdbFSOpen(pTsdb) < 0) {
......
...@@ -227,7 +227,11 @@ int vnodeCommit(SVnode *pVnode) { ...@@ -227,7 +227,11 @@ int vnodeCommit(SVnode *pVnode) {
info.state.committed = pVnode->state.applied; info.state.committed = pVnode->state.applied;
info.state.commitTerm = pVnode->state.applyTerm; info.state.commitTerm = pVnode->state.applyTerm;
info.state.commitID = pVnode->state.commitID; info.state.commitID = pVnode->state.commitID;
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path); if (pVnode->pTfs) {
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path);
} else {
snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path);
}
if (vnodeSaveInfo(dir, &info) < 0) { if (vnodeSaveInfo(dir, &info) < 0) {
ASSERT(0); ASSERT(0);
return -1; return -1;
......
...@@ -138,12 +138,6 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { ...@@ -138,12 +138,6 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR); sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
taosRealPath(tdir, NULL, sizeof(tdir)); taosRealPath(tdir, NULL, sizeof(tdir));
// for test tsdb snapshot
#if 0
pVnode->config.walCfg.segSize = 200;
pVnode->config.walCfg.retentionSize = 2000;
#endif
pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg)); pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg));
if (pVnode->pWal == NULL) { if (pVnode->pWal == NULL) {
vError("vgId:%d, failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno)); vError("vgId:%d, failed to open vnode wal since %s", TD_VID(pVnode), tstrerror(terrno));
...@@ -159,12 +153,14 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { ...@@ -159,12 +153,14 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
goto _err; goto _err;
} }
#if !VNODE_AS_LIB
// open query // open query
if (vnodeQueryOpen(pVnode)) { if (vnodeQueryOpen(pVnode)) {
vError("vgId:%d, failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno)); vError("vgId:%d, failed to open vnode query since %s", TD_VID(pVnode), tstrerror(terrno));
terrno = TSDB_CODE_OUT_OF_MEMORY; terrno = TSDB_CODE_OUT_OF_MEMORY;
goto _err; goto _err;
} }
#endif
// vnode begin // vnode begin
if (vnodeBegin(pVnode) < 0) { if (vnodeBegin(pVnode) < 0) {
...@@ -173,11 +169,13 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { ...@@ -173,11 +169,13 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
goto _err; goto _err;
} }
#if !VNODE_AS_LIB
// open sync // open sync
if (vnodeSyncOpen(pVnode, dir)) { if (vnodeSyncOpen(pVnode, dir)) {
vError("vgId:%d, failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno)); vError("vgId:%d, failed to open sync since %s", TD_VID(pVnode), tstrerror(terrno));
goto _err; goto _err;
} }
#endif
return pVnode; return pVnode;
......
add_subdirectory(tdb)
add_subdirectory(cache)
add_subdirectory(transport) add_subdirectory(transport)
add_subdirectory(wal)
add_subdirectory(monitor)
add_subdirectory(tfs)
add_subdirectory(sync) add_subdirectory(sync)
add_subdirectory(tdb) add_subdirectory(qcom)
add_subdirectory(nodes)
add_subdirectory(catalog)
add_subdirectory(scalar)
add_subdirectory(function)
add_subdirectory(index) add_subdirectory(index)
add_subdirectory(wal)
add_subdirectory(parser) add_subdirectory(parser)
add_subdirectory(scheduler) add_subdirectory(scheduler)
add_subdirectory(cache)
add_subdirectory(catalog)
add_subdirectory(executor) add_subdirectory(executor)
add_subdirectory(stream) add_subdirectory(stream)
add_subdirectory(planner) add_subdirectory(planner)
add_subdirectory(function)
add_subdirectory(qcom)
add_subdirectory(qworker) add_subdirectory(qworker)
add_subdirectory(tfs)
add_subdirectory(monitor)
add_subdirectory(nodes)
add_subdirectory(scalar)
add_subdirectory(command) add_subdirectory(command)
\ No newline at end of file
...@@ -14,7 +14,14 @@ target_include_directories( ...@@ -14,7 +14,14 @@ target_include_directories(
target_link_libraries( target_link_libraries(
function function
PRIVATE os util common nodes scalar qcom transport stream PRIVATE os
PRIVATE util
PRIVATE common
PRIVATE nodes
PRIVATE qcom
PRIVATE scalar
PRIVATE transport
PRIVATE stream
PUBLIC uv_a PUBLIC uv_a
) )
......
...@@ -8,7 +8,7 @@ target_include_directories( ...@@ -8,7 +8,7 @@ target_include_directories(
target_link_libraries( target_link_libraries(
qcom qcom
PRIVATE os util transport nodes PRIVATE os util transport
) )
if(${BUILD_TEST}) if(${BUILD_TEST})
......
...@@ -8,8 +8,14 @@ target_include_directories( ...@@ -8,8 +8,14 @@ target_include_directories(
) )
target_link_libraries(scalar target_link_libraries(scalar
PRIVATE os util common nodes function qcom vnode PRIVATE os
) PRIVATE util
PRIVATE common
PRIVATE nodes
PRIVATE function
PRIVATE qcom
PRIVATE vnode
)
if(${BUILD_TEST}) if(${BUILD_TEST})
ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(test)
......
...@@ -16,11 +16,6 @@ target_link_libraries( ...@@ -16,11 +16,6 @@ target_link_libraries(
) )
if (${BUILD_WITH_UV_TRANS}) if (${BUILD_WITH_UV_TRANS})
if (${BUILD_WITH_UV}) if (${BUILD_WITH_UV})
target_include_directories(
transport
PUBLIC "${TD_SOURCE_DIR}/contrib/libuv/include"
)
target_link_libraries( target_link_libraries(
transport transport
PUBLIC uv_a PUBLIC uv_a
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册