commit
25617eca50
|
@ -30,12 +30,9 @@
|
||||||
#include "vnodeBufferPool.h"
|
#include "vnodeBufferPool.h"
|
||||||
#include "vnodeCfg.h"
|
#include "vnodeCfg.h"
|
||||||
#include "vnodeCommit.h"
|
#include "vnodeCommit.h"
|
||||||
#include "vnodeFS.h"
|
|
||||||
#include "vnodeMemAllocator.h"
|
#include "vnodeMemAllocator.h"
|
||||||
#include "vnodeQuery.h"
|
#include "vnodeQuery.h"
|
||||||
#include "vnodeRequest.h"
|
|
||||||
#include "vnodeStateMgr.h"
|
#include "vnodeStateMgr.h"
|
||||||
#include "vnodeSync.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -73,8 +70,6 @@ struct SVnode {
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
SWal* pWal;
|
SWal* pWal;
|
||||||
SVnodeSync* pSync;
|
|
||||||
SVnodeFS* pFs;
|
|
||||||
tsem_t canCommit;
|
tsem_t canCommit;
|
||||||
SQHandle* pQuery;
|
SQHandle* pQuery;
|
||||||
SDnode* pDnode;
|
SDnode* pDnode;
|
||||||
|
@ -84,6 +79,16 @@ int vnodeScheduleTask(SVnodeTask* task);
|
||||||
|
|
||||||
int32_t vnodePutReqToVQueryQ(SVnode *pVnode, struct SRpcMsg *pReq);
|
int32_t vnodePutReqToVQueryQ(SVnode *pVnode, struct SRpcMsg *pReq);
|
||||||
|
|
||||||
|
// For Log
|
||||||
|
extern int32_t vDebugFlag;
|
||||||
|
|
||||||
|
#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define vWarn(...) do { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define vInfo(...) do { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", 255, __VA_ARGS__); }} while(0)
|
||||||
|
#define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
|
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_VNODE_MAF_H_
|
|
||||||
#define _TD_VNODE_MAF_H_
|
|
||||||
|
|
||||||
#include "vnode.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int vnodeOpenMAF(SVnode *pVnode);
|
|
||||||
void vnodeCloseMAF(SVnode *pVnode);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_VNODE_MAF_H_*/
|
|
|
@ -19,12 +19,11 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include "vnodeInt.h"
|
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
|
#include "vnode.h"
|
||||||
|
|
||||||
typedef struct SQWorkerMgmt SQHandle;
|
typedef struct SQWorkerMgmt SQHandle;
|
||||||
|
|
||||||
|
|
||||||
int vnodeQueryOpen(SVnode *pVnode);
|
int vnodeQueryOpen(SVnode *pVnode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_VNODE_READ_H_
|
|
||||||
#define _TD_VNODE_READ_H_
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
#include "vnodeInt.h"
|
|
||||||
|
|
||||||
void vnodeProcessReadMsg(SVnode *pVnode, SVnodeMsg *pMsg);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_VNODE_READ_H_*/
|
|
|
@ -1,46 +0,0 @@
|
||||||
set(META_DB_IMPL_LIST "BDB" "SQLITE")
|
|
||||||
set(META_DB_IMPL "BDB" CACHE STRING "Use BDB as the default META implementation")
|
|
||||||
set_property(CACHE META_DB_IMPL PROPERTY STRINGS ${META_DB_IMPL_LIST})
|
|
||||||
|
|
||||||
if(META_DB_IMPL IN_LIST META_DB_IMPL_LIST)
|
|
||||||
message(STATUS "META DB Impl: ${META_DB_IMPL}==============")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Invalid META DB IMPL: ${META_DB_IMPL}==============")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
aux_source_directory(src META_SRC)
|
|
||||||
if(${META_DB_IMPL} STREQUAL "BDB")
|
|
||||||
list(REMOVE_ITEM META_SRC "src/metaSQLiteImpl.c")
|
|
||||||
elseif(${META_DB_IMPL} STREQUAL "SQLITE")
|
|
||||||
list(REMOVE_ITEM META_SRC "src/metaBDBImpl.c")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(meta STATIC ${META_SRC})
|
|
||||||
target_include_directories(
|
|
||||||
meta
|
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/vnode/meta"
|
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/index"
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
|
||||||
target_link_libraries(
|
|
||||||
meta
|
|
||||||
PUBLIC common
|
|
||||||
PUBLIC index
|
|
||||||
)
|
|
||||||
|
|
||||||
if(${META_DB_IMPL} STREQUAL "BDB")
|
|
||||||
target_link_libraries(
|
|
||||||
meta
|
|
||||||
PUBLIC bdb
|
|
||||||
)
|
|
||||||
elseif(${META_DB_IMPL} STREQUAL "SQLITE")
|
|
||||||
target_link_libraries(
|
|
||||||
meta
|
|
||||||
PUBLIC sqlite
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
|
||||||
add_subdirectory(test)
|
|
||||||
endif(${BUILD_TEST})
|
|
|
@ -1,20 +0,0 @@
|
||||||
aux_source_directory(src TQ_SRC)
|
|
||||||
add_library(tq ${TQ_SRC})
|
|
||||||
target_include_directories(
|
|
||||||
tq
|
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/vnode/tq"
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
tq
|
|
||||||
PUBLIC wal
|
|
||||||
PUBLIC os
|
|
||||||
PUBLIC util
|
|
||||||
PUBLIC common
|
|
||||||
PUBLIC transport
|
|
||||||
)
|
|
||||||
|
|
||||||
if(${BUILD_TEST})
|
|
||||||
add_subdirectory(test)
|
|
||||||
endif(${BUILD_TEST})
|
|
|
@ -1,34 +0,0 @@
|
||||||
aux_source_directory(src TSDB_SRC)
|
|
||||||
if(0)
|
|
||||||
add_library(tsdb ${TSDB_SRC})
|
|
||||||
else(0)
|
|
||||||
add_library(tsdb STATIC "")
|
|
||||||
target_sources(tsdb
|
|
||||||
PRIVATE
|
|
||||||
"src/tsdbCommit.c"
|
|
||||||
"src/tsdbMain.c"
|
|
||||||
"src/tsdbMemTable.c"
|
|
||||||
"src/tsdbOptions.c"
|
|
||||||
"src/tsdbWrite.c"
|
|
||||||
"src/tsdbReadImpl.c"
|
|
||||||
"src/tsdbFile.c"
|
|
||||||
"src/tsdbFS.c"
|
|
||||||
"src/tsdbRead.c"
|
|
||||||
)
|
|
||||||
endif(0)
|
|
||||||
|
|
||||||
target_include_directories(
|
|
||||||
tsdb
|
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/vnode/tsdb"
|
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(
|
|
||||||
tsdb
|
|
||||||
PUBLIC os
|
|
||||||
PUBLIC util
|
|
||||||
PUBLIC common
|
|
||||||
PUBLIC tkv
|
|
||||||
PUBLIC tfs
|
|
||||||
PUBLIC meta
|
|
||||||
)
|
|
|
@ -1,24 +0,0 @@
|
||||||
aux_source_directory(src VNODE_SRC)
|
|
||||||
add_library(vnode STATIC ${VNODE_SRC})
|
|
||||||
target_include_directories(
|
|
||||||
vnode
|
|
||||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/dnode/vnode"
|
|
||||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
|
||||||
)
|
|
||||||
target_link_libraries(
|
|
||||||
vnode
|
|
||||||
PUBLIC os
|
|
||||||
PUBLIC transport
|
|
||||||
PUBLIC meta
|
|
||||||
PUBLIC tq
|
|
||||||
PUBLIC tsdb
|
|
||||||
PUBLIC wal
|
|
||||||
PUBLIC sync
|
|
||||||
PUBLIC cjson
|
|
||||||
PUBLIC qworker
|
|
||||||
)
|
|
||||||
|
|
||||||
# test
|
|
||||||
if(${BUILD_TEST})
|
|
||||||
# add_subdirectory(test)
|
|
||||||
endif(${BUILD_TEST})
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vnodeDef.h"
|
|
|
@ -41,7 +41,7 @@ int vnodeInit(const SVnodeOpt *pOption) {
|
||||||
|
|
||||||
for (uint16_t i = 0; i < pOption->nthreads; i++) {
|
for (uint16_t i = 0; i < pOption->nthreads; i++) {
|
||||||
pthread_create(&(vnodeMgr.threads[i]), NULL, loop, NULL);
|
pthread_create(&(vnodeMgr.threads[i]), NULL, loop, NULL);
|
||||||
pthread_setname_np(vnodeMgr.threads[i], "VND Commit Thread");
|
// pthread_setname_np(vnodeMgr.threads[i], "VND Commit Thread");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: if no commit thread is set, then another mechanism should be
|
// TODO: if no commit thread is set, then another mechanism should be
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vnodeDef.h"
|
|
|
@ -1,119 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "vnodeDef.h"
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
static int vnodeBuildCreateTableReq(void **buf, const SVCreateTableReq *pReq);
|
|
||||||
static void *vnodeParseCreateTableReq(void *buf, SVCreateTableReq *pReq);
|
|
||||||
|
|
||||||
int vnodeBuildReq(void **buf, const SVnodeReq *pReq, tmsg_t type) {
|
|
||||||
int tsize = 0;
|
|
||||||
|
|
||||||
tsize += taosEncodeFixedU64(buf, pReq->ver);
|
|
||||||
switch (type) {
|
|
||||||
case TDMT_VND_CREATE_STB:
|
|
||||||
tsize += vnodeBuildCreateTableReq(buf, &(pReq->ctReq));
|
|
||||||
break;
|
|
||||||
case TDMT_VND_SUBMIT:
|
|
||||||
/* code */
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* TODO */
|
|
||||||
return tsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *vnodeParseReq(void *buf, SVnodeReq *pReq, tmsg_t type) {
|
|
||||||
buf = taosDecodeFixedU64(buf, &(pReq->ver));
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case TDMT_VND_CREATE_STB:
|
|
||||||
buf = vnodeParseCreateTableReq(buf, &(pReq->ctReq));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int vnodeBuildCreateTableReq(void **buf, const SVCreateTableReq *pReq) {
|
|
||||||
int tsize = 0;
|
|
||||||
|
|
||||||
tsize += taosEncodeString(buf, pReq->name);
|
|
||||||
tsize += taosEncodeFixedU32(buf, pReq->ttl);
|
|
||||||
tsize += taosEncodeFixedU32(buf, pReq->keep);
|
|
||||||
tsize += taosEncodeFixedU8(buf, pReq->type);
|
|
||||||
|
|
||||||
switch (pReq->type) {
|
|
||||||
case META_SUPER_TABLE:
|
|
||||||
tsize += taosEncodeFixedU64(buf, pReq->stbCfg.suid);
|
|
||||||
tsize += tdEncodeSchema(buf, pReq->stbCfg.pSchema);
|
|
||||||
tsize += tdEncodeSchema(buf, pReq->stbCfg.pTagSchema);
|
|
||||||
break;
|
|
||||||
case META_CHILD_TABLE:
|
|
||||||
tsize += taosEncodeFixedU64(buf, pReq->ctbCfg.suid);
|
|
||||||
tsize += tdEncodeKVRow(buf, pReq->ctbCfg.pTag);
|
|
||||||
break;
|
|
||||||
case META_NORMAL_TABLE:
|
|
||||||
tsize += tdEncodeSchema(buf, pReq->ntbCfg.pSchema);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *vnodeParseCreateTableReq(void *buf, SVCreateTableReq *pReq) {
|
|
||||||
buf = taosDecodeString(buf, &(pReq->name));
|
|
||||||
buf = taosDecodeFixedU32(buf, &(pReq->ttl));
|
|
||||||
buf = taosDecodeFixedU32(buf, &(pReq->keep));
|
|
||||||
buf = taosDecodeFixedU8(buf, &(pReq->type));
|
|
||||||
|
|
||||||
switch (pReq->type) {
|
|
||||||
case META_SUPER_TABLE:
|
|
||||||
buf = taosDecodeFixedU64(buf, &(pReq->stbCfg.suid));
|
|
||||||
buf = tdDecodeSchema(buf, &(pReq->stbCfg.pSchema));
|
|
||||||
buf = tdDecodeSchema(buf, &(pReq->stbCfg.pTagSchema));
|
|
||||||
break;
|
|
||||||
case META_CHILD_TABLE:
|
|
||||||
buf = taosDecodeFixedU64(buf, &(pReq->ctbCfg.suid));
|
|
||||||
buf = tdDecodeKVRow(buf, &(pReq->ctbCfg.pTag));
|
|
||||||
break;
|
|
||||||
case META_NORMAL_TABLE:
|
|
||||||
buf = tdDecodeSchema(buf, &(pReq->ntbCfg.pSchema));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vnodeBuildDropTableReq(void **buf, const SVDropTbReq *pReq) {
|
|
||||||
// TODO
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *vnodeParseDropTableReq(void *buf, SVDropTbReq *pReq) {
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
#endif
|
|
|
@ -1,14 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
|
@ -1,6 +1,6 @@
|
||||||
add_subdirectory(transport)
|
add_subdirectory(transport)
|
||||||
add_subdirectory(sync)
|
add_subdirectory(sync)
|
||||||
add_subdirectory(tkv)
|
add_subdirectory(tdb)
|
||||||
add_subdirectory(index)
|
add_subdirectory(index)
|
||||||
add_subdirectory(wal)
|
add_subdirectory(wal)
|
||||||
add_subdirectory(parser)
|
add_subdirectory(parser)
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
aux_source_directory(src TKV_SRC)
|
aux_source_directory(src TDB_SRC)
|
||||||
add_library(tkv STATIC ${TKV_SRC})
|
add_library(tdb STATIC ${TDB_SRC})
|
||||||
# target_include_directories(
|
# target_include_directories(
|
||||||
# tkv
|
# tkv
|
||||||
# PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/tkv"
|
# PUBLIC "${CMAKE_SOURCE_DIR}/include/libs/tkv"
|
||||||
# PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
# PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
# )
|
# )
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
tkv
|
tdb
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/inc"
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src/inc"
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
tkv
|
tdb
|
||||||
PUBLIC os
|
PUBLIC os
|
||||||
PUBLIC util
|
PUBLIC util
|
||||||
)
|
)
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_TKV_H_
|
#ifndef _TD_TDB_H_
|
||||||
#define _TD_TKV_H_
|
#define _TD_TDB_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ typedef struct TDB_ENV TDB_ENV;
|
||||||
|
|
||||||
// SKey
|
// SKey
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void * bdata;
|
void* bdata;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
} TDB_KEY, TDB_VALUE;
|
} TDB_KEY, TDB_VALUE;
|
||||||
|
|
||||||
|
@ -36,4 +36,4 @@ typedef struct {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_TKV_H_*/
|
#endif /*_TD_TDB_H_*/
|
|
@ -13,21 +13,21 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_VNODE_SYNC_H_
|
#ifndef _TD_TDB_BTREE_H_
|
||||||
#define _TD_VNODE_SYNC_H_
|
#define _TD_TDB_BTREE_H_
|
||||||
|
|
||||||
// #include "sync.h"
|
#include "tkvDef.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* data */
|
pgid_t root; // root page number
|
||||||
} SVnodeSync;
|
} TDB_BTREE;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_VNODE_SYNC_H_*/
|
#endif /*_TD_TDB_BTREE_H_*/
|
|
@ -13,35 +13,27 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_VNODE_FS_H_
|
#ifndef _TD_TDB_BUF_POOL_H_
|
||||||
#define _TD_VNODE_FS_H_
|
#define _TD_TDB_BUF_POOL_H_
|
||||||
|
|
||||||
#include "vnode.h"
|
#include "tdbPage.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct STdbBufPool STdbBufPool;
|
||||||
} SDir;
|
|
||||||
|
|
||||||
typedef struct {
|
int tbpOpen(STdbBufPool **ppTkvBufPool);
|
||||||
} SFile;
|
int tbpClose(STdbBufPool *pTkvBufPool);
|
||||||
|
STdbPage *tbpNewPage(STdbBufPool *pTkvBufPool);
|
||||||
typedef struct SFS {
|
int tbpDelPage(STdbBufPool *pTkvBufPool);
|
||||||
void *pImpl;
|
STdbPage *tbpFetchPage(STdbBufPool *pTkvBufPool, pgid_t pgid);
|
||||||
int (*startEdit)(struct SFS *);
|
int tbpUnpinPage(STdbBufPool *pTkvBufPool, pgid_t pgid);
|
||||||
int (*endEdit)(struct SFS *);
|
void tbpFlushPages(STdbBufPool *pTkvBufPool);
|
||||||
} SFS;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
} SVnodeFS;
|
|
||||||
|
|
||||||
int vnodeOpenFS(SVnode *pVnode);
|
|
||||||
void vnodeCloseFS(SVnode *pVnode);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_VNODE_FS_H_*/
|
#endif /*_TD_TDB_BUF_POOL_H_*/
|
|
@ -13,21 +13,33 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_VNODE_REQUEST_H_
|
#ifndef _TD_TDB_DB_H_
|
||||||
#define _TD_VNODE_REQUEST_H_
|
#define _TD_TDB_DB_H_
|
||||||
|
|
||||||
#include "vnode.h"
|
#include "tdbBtree.h"
|
||||||
|
#include "tdbHash.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// SVDropTbReq
|
typedef enum {
|
||||||
// int vnodeBuildDropTableReq(void **buf, const SVDropTbReq *pReq);
|
TDB_BTREE = 0,
|
||||||
// void *vnodeParseDropTableReq(void *buf, SVDropTbReq *pReq);
|
TDB_HASH,
|
||||||
|
TDB_HEAP,
|
||||||
|
} tdb_db_t;
|
||||||
|
|
||||||
|
struct TDB {
|
||||||
|
pgsize_t pageSize;
|
||||||
|
tdb_db_t type;
|
||||||
|
union {
|
||||||
|
STkvBtree btree;
|
||||||
|
STkvhash hash;
|
||||||
|
} dbimpl;
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_VNODE_REQUEST_H_*/
|
#endif /*_TD_TDB_DB_H_*/
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_TKV_DEF_H_
|
#ifndef _TD_TDB_DEF_H_
|
||||||
#define _TD_TKV_DEF_H_
|
#define _TD_TDB_DEF_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
|
@ -39,4 +39,4 @@ typedef int32_t pgsize_t;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_TKV_DEF_H_*/
|
#endif /*_TD_TDB_DEF_H_*/
|
|
@ -22,7 +22,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#include "tkvDef.h"
|
#include "tdbDef.h"
|
||||||
|
|
||||||
typedef struct STkvDiskMgr STkvDiskMgr;
|
typedef struct STkvDiskMgr STkvDiskMgr;
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_TKV_ENV_H_
|
#ifndef _TD_TDB_ENV_H_
|
||||||
#define _TD_TKV_ENV_H_
|
#define _TD_TDB_ENV_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -28,4 +28,4 @@ struct TDB_ENV {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_TKV_ENV_H_*/
|
#endif /*_TD_TDB_ENV_H_*/
|
|
@ -13,19 +13,21 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _TD_TKV_DB_H_
|
#ifndef _TD_TKV_HAHS_H_
|
||||||
#define _TD_TKV_DB_H_
|
#define _TD_TKV_HAHS_H_
|
||||||
|
|
||||||
|
#include "tdbDef.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct TDB {
|
typedef struct {
|
||||||
// TODO
|
// TODO
|
||||||
};
|
} TDB_HASH;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*_TD_TKV_DB_H_*/
|
#endif /*_TD_TKV_HAHS_H_*/
|
|
@ -17,30 +17,24 @@
|
||||||
#define _TD_TKV_PAGE_H_
|
#define _TD_TKV_PAGE_H_
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "tkvDef.h"
|
#include "tdbDef.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct STkvPage {
|
typedef struct {
|
||||||
pgid_t pgid;
|
pgid_t pgid;
|
||||||
int32_t pinCount;
|
int32_t pinCount;
|
||||||
bool idDirty;
|
bool idDirty;
|
||||||
char* pData;
|
char* pData;
|
||||||
} STkvPage;
|
} STdbPage;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t dbver;
|
uint16_t dbver;
|
||||||
uint16_t pgsize;
|
uint16_t pgsize;
|
||||||
uint32_t cksm;
|
uint32_t cksm;
|
||||||
} STkvPgHdr;
|
} STdbPgHdr;
|
||||||
|
|
||||||
// typedef struct {
|
|
||||||
// SPgHdr chdr;
|
|
||||||
// uint16_t used; // number of used slots
|
|
||||||
// uint16_t loffset; // the offset of the starting location of the last slot used
|
|
||||||
// } SSlottedPgHdr;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
|
@ -16,17 +16,17 @@
|
||||||
#include "thash.h"
|
#include "thash.h"
|
||||||
#include "tlist.h"
|
#include "tlist.h"
|
||||||
|
|
||||||
#include "tkvBufPool.h"
|
#include "tdbBufPool.h"
|
||||||
#include "tkvDiskMgr.h"
|
#include "tdbDiskMgr.h"
|
||||||
#include "tkvPage.h"
|
#include "tdbPage.h"
|
||||||
|
|
||||||
struct SFrameIdWrapper {
|
struct SFrameIdWrapper {
|
||||||
TD_SLIST_NODE(SFrameIdWrapper);
|
TD_SLIST_NODE(SFrameIdWrapper);
|
||||||
frame_id_t id;
|
frame_id_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct STkvBufPool {
|
struct STdbBufPool {
|
||||||
STkvPage* pages;
|
STdbPage* pages;
|
||||||
STkvDiskMgr* pDiskMgr;
|
STkvDiskMgr* pDiskMgr;
|
||||||
SHashObj* pgTb; // page_id_t --> frame_id_t
|
SHashObj* pgTb; // page_id_t --> frame_id_t
|
||||||
TD_SLIST(SFrameIdWrapper) freeList;
|
TD_SLIST(SFrameIdWrapper) freeList;
|
|
@ -13,7 +13,7 @@
|
||||||
* 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 "tkvDiskMgr.h"
|
#include "tdbDiskMgr.h"
|
||||||
|
|
||||||
struct STkvDiskMgr {
|
struct STkvDiskMgr {
|
||||||
char * fname;
|
char * fname;
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _TD_TKV_BUF_POOL_H_
|
|
||||||
#define _TD_TKV_BUF_POOL_H_
|
|
||||||
|
|
||||||
#include "tkvPage.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct STkvBufPool STkvBufPool;
|
|
||||||
|
|
||||||
int tbpOpen(STkvBufPool **ppTkvBufPool);
|
|
||||||
int tbpClose(STkvBufPool *pTkvBufPool);
|
|
||||||
STkvPage *tbpNewPage(STkvBufPool *pTkvBufPool);
|
|
||||||
int tbpDelPage(STkvBufPool *pTkvBufPool);
|
|
||||||
STkvPage *tbpFetchPage(STkvBufPool *pTkvBufPool, pgid_t pgid);
|
|
||||||
int tbpUnpinPage(STkvBufPool *pTkvBufPool, pgid_t pgid);
|
|
||||||
void tbpFlushPages(STkvBufPool *pTkvBufPool);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /*_TD_TKV_BUF_POOL_H_*/
|
|
Loading…
Reference in New Issue