Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a8f740bc
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a8f740bc
编写于
4月 09, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/qnode
上级
e9f7bf86
f072afe7
变更
89
隐藏空白更改
内联
并排
Showing
89 changed file
with
2248 addition
and
1987 deletion
+2248
-1987
cmake/bdb_CMakeLists.txt.in.bak
cmake/bdb_CMakeLists.txt.in.bak
+0
-0
cmake/cmake.options
cmake/cmake.options
+0
-11
contrib/CMakeLists.txt
contrib/CMakeLists.txt
+3
-3
contrib/test/CMakeLists.txt
contrib/test/CMakeLists.txt
+3
-3
include/common/tcommon.h
include/common/tcommon.h
+1
-1
include/common/tdatablock.h
include/common/tdatablock.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+13
-3
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+2
-0
include/util/taoserror.h
include/util/taoserror.h
+11
-10
source/client/src/tmq.c
source/client/src/tmq.c
+3
-2
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+53
-6
source/common/src/tglobal.c
source/common/src/tglobal.c
+4
-4
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+1
-2
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+11
-9
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+56
-34
source/dnode/vnode/inc/meta.h
source/dnode/vnode/inc/meta.h
+0
-86
source/dnode/vnode/inc/tsdb.h
source/dnode/vnode/inc/tsdb.h
+0
-288
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+318
-2
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+3
-7
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+87
-8
source/dnode/vnode/src/inc/tqCommit.h
source/dnode/vnode/src/inc/tqCommit.h
+0
-14
source/dnode/vnode/src/inc/tqMetaStore.h
source/dnode/vnode/src/inc/tqMetaStore.h
+0
-51
source/dnode/vnode/src/inc/tqOffset.h
source/dnode/vnode/src/inc/tqOffset.h
+0
-40
source/dnode/vnode/src/inc/tqPush.h
source/dnode/vnode/src/inc/tqPush.h
+0
-80
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+936
-0
source/dnode/vnode/src/inc/tsdbCommit.h
source/dnode/vnode/src/inc/tsdbCommit.h
+0
-77
source/dnode/vnode/src/inc/tsdbCompact.h
source/dnode/vnode/src/inc/tsdbCompact.h
+0
-32
source/dnode/vnode/src/inc/tsdbDBDef.h
source/dnode/vnode/src/inc/tsdbDBDef.h
+0
-45
source/dnode/vnode/src/inc/tsdbDef.h
source/dnode/vnode/src/inc/tsdbDef.h
+0
-84
source/dnode/vnode/src/inc/tsdbFS.h
source/dnode/vnode/src/inc/tsdbFS.h
+0
-141
source/dnode/vnode/src/inc/tsdbLog.h
source/dnode/vnode/src/inc/tsdbLog.h
+0
-38
source/dnode/vnode/src/inc/tsdbMemTable.h
source/dnode/vnode/src/inc/tsdbMemTable.h
+0
-81
source/dnode/vnode/src/inc/tsdbMemory.h
source/dnode/vnode/src/inc/tsdbMemory.h
+0
-81
source/dnode/vnode/src/inc/tsdbOptions.h
source/dnode/vnode/src/inc/tsdbOptions.h
+0
-32
source/dnode/vnode/src/inc/tsdbReadImpl.h
source/dnode/vnode/src/inc/tsdbReadImpl.h
+0
-256
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+0
-89
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+21
-6
source/dnode/vnode/src/inc/vnodeQuery.h
source/dnode/vnode/src/inc/vnodeQuery.h
+0
-35
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+1
-2
source/dnode/vnode/src/meta/metaCfg.c
source/dnode/vnode/src/meta/metaCfg.c
+1
-1
source/dnode/vnode/src/meta/metaIdx.c
source/dnode/vnode/src/meta/metaIdx.c
+1
-1
source/dnode/vnode/src/meta/metaMain.c
source/dnode/vnode/src/meta/metaMain.c
+1
-1
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+1
-1
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+1
-1
source/dnode/vnode/src/meta/metaTbCfg.c
source/dnode/vnode/src/meta/metaTbCfg.c
+1
-1
source/dnode/vnode/src/meta/metaTbUid.c
source/dnode/vnode/src/meta/metaTbUid.c
+1
-2
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+13
-12
source/dnode/vnode/src/tq/tqMetaStore.c
source/dnode/vnode/src/tq/tqMetaStore.c
+1
-1
source/dnode/vnode/src/tq/tqOffset.c
source/dnode/vnode/src/tq/tqOffset.c
+1
-2
source/dnode/vnode/src/tq/tqPush.c
source/dnode/vnode/src/tq/tqPush.c
+1
-1
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
+0
-2
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbMain.c
source/dnode/vnode/src/tsdb/tsdbMain.c
+4
-4
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbOptions.c
source/dnode/vnode/src/tsdb/tsdbOptions.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+2
-9
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+1
-1
source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c
source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c
+1
-1
source/dnode/vnode/src/vnd/vnodeBufferPool.c
source/dnode/vnode/src/vnd/vnodeBufferPool.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+1
-1
source/dnode/vnode/src/vnd/vnodeInt.c
source/dnode/vnode/src/vnd/vnodeInt.c
+1
-1
source/dnode/vnode/src/vnd/vnodeMain.c
source/dnode/vnode/src/vnd/vnodeMain.c
+1
-1
source/dnode/vnode/src/vnd/vnodeMgr.c
source/dnode/vnode/src/vnd/vnodeMgr.c
+1
-1
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+1
-2
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+13
-13
source/dnode/vnode/test/CMakeLists.txt
source/dnode/vnode/test/CMakeLists.txt
+11
-11
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+2
-2
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+32
-3
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+127
-85
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+258
-59
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+1
-1
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+1
-3
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+1
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+43
-2
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+133
-31
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+2
-0
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+8
-8
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+18
-17
source/util/src/tpagedbuf.c
source/util/src/tpagedbuf.c
+1
-3
tests/script/tsim/query/charScalarFunction.sim
tests/script/tsim/query/charScalarFunction.sim
+19
-19
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+0
-6
未找到文件。
cmake/bdb_CMakeLists.txt.in
→
cmake/bdb_CMakeLists.txt.in
.bak
浏览文件 @
a8f740bc
文件已移动
cmake/cmake.options
浏览文件 @
a8f740bc
...
@@ -55,17 +55,6 @@ option(
...
@@ -55,17 +55,6 @@ option(
OFF
OFF
)
)
IF(${TD_WINDOWS})
MESSAGE("Not build BDB on Windows")
ELSE ()
option(
BUILD_WITH_BDB
"If build with BerkleyDB"
ON
)
ENDIF ()
option(
option(
BUILD_WITH_LUCENE
BUILD_WITH_LUCENE
"If build with lucene"
"If build with lucene"
...
...
contrib/CMakeLists.txt
浏览文件 @
a8f740bc
...
@@ -63,9 +63,9 @@ if(${BUILD_WITH_UV})
...
@@ -63,9 +63,9 @@ if(${BUILD_WITH_UV})
endif
(
${
BUILD_WITH_UV
}
)
endif
(
${
BUILD_WITH_UV
}
)
# bdb
# bdb
if
(
${
BUILD_WITH_BDB
}
)
#
if(${BUILD_WITH_BDB})
cat
(
"
${
CMAKE_SUPPORT_DIR
}
/bdb_CMakeLists.txt.in"
${
CONTRIB_TMP_FILE
}
)
#
cat("${CMAKE_SUPPORT_DIR}/bdb_CMakeLists.txt.in" ${CONTRIB_TMP_FILE})
endif
(
${
BUILD_WITH_BDB
}
)
#
endif(${BUILD_WITH_BDB})
# sqlite
# sqlite
if
(
${
BUILD_WITH_SQLITE
}
)
if
(
${
BUILD_WITH_SQLITE
}
)
...
...
contrib/test/CMakeLists.txt
浏览文件 @
a8f740bc
...
@@ -7,9 +7,9 @@ if(${BUILD_WITH_LUCENE})
...
@@ -7,9 +7,9 @@ if(${BUILD_WITH_LUCENE})
add_subdirectory
(
lucene
)
add_subdirectory
(
lucene
)
endif
(
${
BUILD_WITH_LUCENE
}
)
endif
(
${
BUILD_WITH_LUCENE
}
)
if
(
${
BUILD_WITH_BDB
}
)
#
if(${BUILD_WITH_BDB})
add_subdirectory
(
bdb
)
#
add_subdirectory(bdb)
endif
(
${
BUILD_WITH_BDB
}
)
#
endif(${BUILD_WITH_BDB})
if
(
${
BUILD_WITH_SQLITE
}
)
if
(
${
BUILD_WITH_SQLITE
}
)
add_subdirectory
(
sqlite
)
add_subdirectory
(
sqlite
)
...
...
include/common/tcommon.h
浏览文件 @
a8f740bc
...
@@ -71,7 +71,7 @@ typedef struct SDataBlockInfo {
...
@@ -71,7 +71,7 @@ typedef struct SDataBlockInfo {
int64_t
uid
;
int64_t
uid
;
int64_t
blockId
;
int64_t
blockId
;
};
};
int64_t
groupId
;
// no need to serialize
uint64_t
groupId
;
// no need to serialize
}
SDataBlockInfo
;
}
SDataBlockInfo
;
typedef
struct
SSDataBlock
{
typedef
struct
SSDataBlock
{
...
...
include/common/tdatablock.h
浏览文件 @
a8f740bc
...
@@ -182,6 +182,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
...
@@ -182,6 +182,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
int32_t
pageSize
);
int32_t
pageSize
);
int32_t
blockDataToBuf
(
char
*
buf
,
const
SSDataBlock
*
pBlock
);
int32_t
blockDataToBuf
(
char
*
buf
,
const
SSDataBlock
*
pBlock
);
int32_t
blockDataFromBuf
(
SSDataBlock
*
pBlock
,
const
char
*
buf
);
int32_t
blockDataFromBuf
(
SSDataBlock
*
pBlock
,
const
char
*
buf
);
int32_t
blockDataFromBuf1
(
SSDataBlock
*
pBlock
,
const
char
*
buf
,
size_t
capacity
);
SSDataBlock
*
blockDataExtractBlock
(
SSDataBlock
*
pBlock
,
int32_t
startIndex
,
int32_t
rowCount
);
SSDataBlock
*
blockDataExtractBlock
(
SSDataBlock
*
pBlock
,
int32_t
startIndex
,
int32_t
rowCount
);
...
...
include/common/tmsg.h
浏览文件 @
a8f740bc
...
@@ -2328,6 +2328,7 @@ typedef struct {
...
@@ -2328,6 +2328,7 @@ typedef struct {
char
cgroup
[
TSDB_CGROUP_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
int64_t
currentOffset
;
int64_t
currentOffset
;
uint64_t
reqId
;
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
}
SMqPollReq
;
}
SMqPollReq
;
...
...
include/libs/nodes/nodes.h
浏览文件 @
a8f740bc
...
@@ -30,11 +30,19 @@ extern "C" {
...
@@ -30,11 +30,19 @@ extern "C" {
#define FOREACH(node, list) \
#define FOREACH(node, list) \
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext)
for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext)
// only be use in FOREACH
#define ERASE_NODE(list) cell = nodesListErase(list, cell);
#define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode)
#define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode)
#define INSERT_LIST(target, src) nodesListInsertList((target), cell, src)
#define WHERE_EACH(node, list) \
SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \
while (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false))
#define WHERE_NEXT cell = cell->pNext
// only be use in WHERE_EACH
#define ERASE_NODE(list) cell = nodesListErase((list), cell)
#define FORBOTH(node1, list1, node2, list2) \
#define FORBOTH(node1, list1, node2, list2) \
for (SListCell* cell1 = (NULL != (list1) ? (list1)->pHead : NULL), *cell2 = (NULL != (list2) ? (list2)->pHead : NULL); \
for (SListCell* cell1 = (NULL != (list1) ? (list1)->pHead : NULL), *cell2 = (NULL != (list2) ? (list2)->pHead : NULL); \
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
(NULL == cell1 ? (node1 = NULL, false) : (node1 = cell1->pNode, true)), (NULL == cell2 ? (node2 = NULL, false) : (node2 = cell2->pNode, true)), (node1 != NULL && node2 != NULL); \
...
@@ -202,7 +210,9 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
...
@@ -202,7 +210,9 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode);
int32_t
nodesListMakeAppend
(
SNodeList
**
pList
,
SNodeptr
pNode
);
int32_t
nodesListMakeAppend
(
SNodeList
**
pList
,
SNodeptr
pNode
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListStrictAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListStrictAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListPushFront
(
SNodeList
*
pList
,
SNodeptr
pNode
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
void
nodesListInsertList
(
SNodeList
*
pTarget
,
SListCell
*
pPos
,
SNodeList
*
pSrc
);
SNodeptr
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
SNodeptr
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
void
nodesDestroyList
(
SNodeList
*
pList
);
void
nodesDestroyList
(
SNodeList
*
pList
);
// Only clear the linked list structure, without releasing the elements inside
// Only clear the linked list structure, without releasing the elements inside
...
...
include/libs/nodes/querynodes.h
浏览文件 @
a8f740bc
...
@@ -124,6 +124,7 @@ typedef struct STableNode {
...
@@ -124,6 +124,7 @@ typedef struct STableNode {
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
char
tableAlias
[
TSDB_TABLE_NAME_LEN
];
uint8_t
precision
;
}
STableNode
;
}
STableNode
;
struct
STableMeta
;
struct
STableMeta
;
...
@@ -236,6 +237,7 @@ typedef struct SSelectStmt {
...
@@ -236,6 +237,7 @@ typedef struct SSelectStmt {
SNode
*
pLimit
;
SNode
*
pLimit
;
SNode
*
pSlimit
;
SNode
*
pSlimit
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
uint8_t
precision
;
}
SSelectStmt
;
}
SSelectStmt
;
typedef
enum
ESetOperatorType
{
typedef
enum
ESetOperatorType
{
...
...
include/util/taoserror.h
浏览文件 @
a8f740bc
...
@@ -484,16 +484,17 @@ int32_t* taosGetErrno();
...
@@ -484,16 +484,17 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617)
#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617)
#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618)
#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618)
#define TSDB_CODE_PAR_INVALID_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2619)
#define TSDB_CODE_PAR_INVALID_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2619)
#define TSDB_CODE_PAR_INVALID_STR_OPTION TAOS_DEF_ERROR_CODE(0, 0x2620)
#define TSDB_CODE_PAR_INVALID_STR_OPTION TAOS_DEF_ERROR_CODE(0, 0x261A)
#define TSDB_CODE_PAR_INVALID_ENUM_OPTION TAOS_DEF_ERROR_CODE(0, 0x2621)
#define TSDB_CODE_PAR_INVALID_ENUM_OPTION TAOS_DEF_ERROR_CODE(0, 0x261B)
#define TSDB_CODE_PAR_INVALID_TTL_OPTION TAOS_DEF_ERROR_CODE(0, 0x2622)
#define TSDB_CODE_PAR_INVALID_TTL_OPTION TAOS_DEF_ERROR_CODE(0, 0x261C)
#define TSDB_CODE_PAR_INVALID_KEEP_NUM TAOS_DEF_ERROR_CODE(0, 0x2623)
#define TSDB_CODE_PAR_INVALID_KEEP_NUM TAOS_DEF_ERROR_CODE(0, 0x261D)
#define TSDB_CODE_PAR_INVALID_KEEP_ORDER TAOS_DEF_ERROR_CODE(0, 0x2624)
#define TSDB_CODE_PAR_INVALID_KEEP_ORDER TAOS_DEF_ERROR_CODE(0, 0x261E)
#define TSDB_CODE_PAR_INVALID_KEEP_VALUE TAOS_DEF_ERROR_CODE(0, 0x2625)
#define TSDB_CODE_PAR_INVALID_KEEP_VALUE TAOS_DEF_ERROR_CODE(0, 0x261F)
#define TSDB_CODE_PAR_INVALID_COMMENT_OPTION TAOS_DEF_ERROR_CODE(0, 0x2626)
#define TSDB_CODE_PAR_INVALID_COMMENT_OPTION TAOS_DEF_ERROR_CODE(0, 0x2620)
#define TSDB_CODE_PAR_INVALID_F_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2627)
#define TSDB_CODE_PAR_INVALID_F_RANGE_OPTION TAOS_DEF_ERROR_CODE(0, 0x2621)
#define TSDB_CODE_PAR_INVALID_ROLLUP_OPTION TAOS_DEF_ERROR_CODE(0, 0x2628)
#define TSDB_CODE_PAR_INVALID_ROLLUP_OPTION TAOS_DEF_ERROR_CODE(0, 0x2622)
#define TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION TAOS_DEF_ERROR_CODE(0, 0x2629)
#define TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION TAOS_DEF_ERROR_CODE(0, 0x2623)
#define TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST TAOS_DEF_ERROR_CODE(0, 0x2624)
//planner
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/client/src/tmq.c
浏览文件 @
a8f740bc
...
@@ -1149,6 +1149,7 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClientTo
...
@@ -1149,6 +1149,7 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t blockingTime, SMqClientTo
pReq
->
consumerId
=
tmq
->
consumerId
;
pReq
->
consumerId
=
tmq
->
consumerId
;
pReq
->
epoch
=
tmq
->
epoch
;
pReq
->
epoch
=
tmq
->
epoch
;
pReq
->
currentOffset
=
reqOffset
;
pReq
->
currentOffset
=
reqOffset
;
pReq
->
reqId
=
generateRequestId
();
pReq
->
head
.
vgId
=
htonl
(
pVg
->
vgId
);
pReq
->
head
.
vgId
=
htonl
(
pVg
->
vgId
);
pReq
->
head
.
contLen
=
htonl
(
sizeof
(
SMqPollReq
));
pReq
->
head
.
contLen
=
htonl
(
sizeof
(
SMqPollReq
));
...
@@ -1279,7 +1280,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
...
@@ -1279,7 +1280,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
.
len
=
sizeof
(
SMqPollReq
),
.
len
=
sizeof
(
SMqPollReq
),
.
handle
=
NULL
,
.
handle
=
NULL
,
};
};
sendInfo
->
requestId
=
generateRequestId
()
;
sendInfo
->
requestId
=
pReq
->
reqId
;
sendInfo
->
requestObjRefId
=
0
;
sendInfo
->
requestObjRefId
=
0
;
sendInfo
->
param
=
pParam
;
sendInfo
->
param
=
pParam
;
sendInfo
->
fp
=
tmqPollCb
;
sendInfo
->
fp
=
tmqPollCb
;
...
@@ -1288,7 +1289,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
...
@@ -1288,7 +1289,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
int64_t
transporterId
=
0
;
int64_t
transporterId
=
0
;
/*printf("send poll\n");*/
/*printf("send poll\n");*/
atomic_add_fetch_32
(
&
tmq
->
waitingRequest
,
1
);
atomic_add_fetch_32
(
&
tmq
->
waitingRequest
,
1
);
tscDebug
(
"consumer %ld send poll
: vg %d, epoch %d, req offset %ld"
,
tmq
->
consumerId
,
pVg
->
vgId
,
tmq
->
epoch
,
pVg
->
currentOffset
);
tscDebug
(
"consumer %ld send poll
to %s : vg %d, epoch %d, req offset %ld, reqId %lu"
,
tmq
->
consumerId
,
pTopic
->
topicName
,
pVg
->
vgId
,
tmq
->
epoch
,
pVg
->
currentOffset
,
pReq
->
reqId
);
/*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/
/*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/
asyncSendMsgToServer
(
tmq
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
pVg
->
epSet
,
&
transporterId
,
sendInfo
);
asyncSendMsgToServer
(
tmq
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
pVg
->
epSet
,
&
transporterId
,
sendInfo
);
pVg
->
pollCnt
++
;
pVg
->
pollCnt
++
;
...
...
source/common/src/tdatablock.c
浏览文件 @
a8f740bc
...
@@ -415,10 +415,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
...
@@ -415,10 +415,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pColInfoData
=
TARRAY_GET_ELEM
(
pBlock
->
pDataBlock
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
bool
isNull
=
colDataIsNull
(
pColInfoData
,
numOfRows
,
j
,
NULL
);
if
(
pColInfoData
->
varmeta
.
offset
[
j
]
!=
-
1
)
{
if
(
isNull
)
{
// do nothing
}
else
{
char
*
p
=
colDataGetData
(
pColInfoData
,
j
);
char
*
p
=
colDataGetData
(
pColInfoData
,
j
);
size
+=
varDataTLen
(
p
);
size
+=
varDataTLen
(
p
);
}
}
...
@@ -547,8 +544,8 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
...
@@ -547,8 +544,8 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
size_t
metaSize
=
pBlock
->
info
.
rows
*
sizeof
(
int32_t
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
size_t
metaSize
=
pBlock
->
info
.
rows
*
sizeof
(
int32_t
);
memcpy
(
pCol
->
varmeta
.
offset
,
pStart
,
metaSize
);
memcpy
(
pCol
->
varmeta
.
offset
,
pStart
,
metaSize
);
pStart
+=
metaSize
;
pStart
+=
metaSize
;
}
else
{
}
else
{
...
@@ -581,6 +578,49 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
...
@@ -581,6 +578,49 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
blockDataFromBuf1
(
SSDataBlock
*
pBlock
,
const
char
*
buf
,
size_t
capacity
)
{
pBlock
->
info
.
rows
=
*
(
int32_t
*
)
buf
;
int32_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
const
char
*
pStart
=
buf
+
sizeof
(
uint32_t
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
size_t
metaSize
=
capacity
*
sizeof
(
int32_t
);
memcpy
(
pCol
->
varmeta
.
offset
,
pStart
,
metaSize
);
pStart
+=
metaSize
;
}
else
{
memcpy
(
pCol
->
nullbitmap
,
pStart
,
BitmapLen
(
capacity
));
pStart
+=
BitmapLen
(
capacity
);
}
int32_t
colLength
=
*
(
int32_t
*
)
pStart
;
pStart
+=
sizeof
(
int32_t
);
if
(
IS_VAR_DATA_TYPE
(
pCol
->
info
.
type
))
{
if
(
pCol
->
varmeta
.
allocLen
<
colLength
)
{
char
*
tmp
=
taosMemoryRealloc
(
pCol
->
pData
,
colLength
);
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCol
->
pData
=
tmp
;
pCol
->
varmeta
.
allocLen
=
colLength
;
}
pCol
->
varmeta
.
length
=
colLength
;
ASSERT
(
pCol
->
varmeta
.
length
<=
pCol
->
varmeta
.
allocLen
);
}
memcpy
(
pCol
->
pData
,
pStart
,
colLength
);
pStart
+=
pCol
->
info
.
bytes
*
capacity
;
}
return
TSDB_CODE_SUCCESS
;
}
size_t
blockDataGetRowSize
(
SSDataBlock
*
pBlock
)
{
size_t
blockDataGetRowSize
(
SSDataBlock
*
pBlock
)
{
ASSERT
(
pBlock
!=
NULL
);
ASSERT
(
pBlock
!=
NULL
);
if
(
pBlock
->
info
.
rowSize
==
0
)
{
if
(
pBlock
->
info
.
rowSize
==
0
)
{
...
@@ -627,6 +667,10 @@ double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
...
@@ -627,6 +667,10 @@ double blockDataGetSerialRowSize(const SSDataBlock* pBlock) {
return
rowSize
;
return
rowSize
;
}
}
int32_t
getAllowedRowsForPage
(
const
SSDataBlock
*
pBlock
,
size_t
pgSize
)
{
return
(
int32_t
)
((
pgSize
-
blockDataGetSerialMetaSize
(
pBlock
))
/
blockDataGetSerialRowSize
(
pBlock
));
}
typedef
struct
SSDataBlockSortHelper
{
typedef
struct
SSDataBlockSortHelper
{
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
SSDataBlock
*
pDataBlock
;
SSDataBlock
*
pDataBlock
;
...
@@ -1178,6 +1222,9 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
...
@@ -1178,6 +1222,9 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
)
{
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
numOfRows
==
0
)
{
return
TSDB_CODE_SUCCESS
;
}
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
p
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
...
@@ -1220,7 +1267,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
...
@@ -1220,7 +1267,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
}
}
size_t
blockDataGetCapacityInRow
(
const
SSDataBlock
*
pBlock
,
size_t
pageSize
)
{
size_t
blockDataGetCapacityInRow
(
const
SSDataBlock
*
pBlock
,
size_t
pageSize
)
{
return
pageSize
/
(
blockDataGetSerialRowSize
(
pBlock
)
+
blockDataGetSerialMeta
Size
(
pBlock
));
return
(
int32_t
)
((
pageSize
-
blockDataGetSerialMetaSize
(
pBlock
))
/
blockDataGetSerialRow
Size
(
pBlock
));
}
}
void
colDataDestroy
(
SColumnInfoData
*
pColData
)
{
void
colDataDestroy
(
SColumnInfoData
*
pColData
)
{
...
...
source/common/src/tglobal.c
浏览文件 @
a8f740bc
...
@@ -394,7 +394,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
...
@@ -394,7 +394,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if
(
cfgAddInt32
(
pCfg
,
"numOfMnodeReadThreads"
,
tsNumOfMnodeReadThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfMnodeReadThreads"
,
tsNumOfMnodeReadThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeQueryThreads
=
tsNumOfCores
/
2
;
tsNumOfVnodeQueryThreads
=
tsNumOfCores
/
2
;
tsNumOfVnodeQueryThreads
=
TM
IN
(
tsNumOfVnodeQueryThreads
,
1
);
tsNumOfVnodeQueryThreads
=
TM
AX
(
tsNumOfVnodeQueryThreads
,
1
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeQueryThreads"
,
tsNumOfVnodeQueryThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeQueryThreads"
,
tsNumOfVnodeQueryThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeFetchThreads
=
tsNumOfCores
/
2
;
tsNumOfVnodeFetchThreads
=
tsNumOfCores
/
2
;
...
@@ -402,11 +402,11 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
...
@@ -402,11 +402,11 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeFetchThreads"
,
tsNumOfVnodeFetchThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeFetchThreads"
,
tsNumOfVnodeFetchThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeWriteThreads
=
tsNumOfCores
;
tsNumOfVnodeWriteThreads
=
tsNumOfCores
;
tsNumOfVnodeWriteThreads
=
TM
IN
(
tsNumOfVnodeWriteThreads
,
1
);
tsNumOfVnodeWriteThreads
=
TM
AX
(
tsNumOfVnodeWriteThreads
,
1
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeWriteThreads"
,
tsNumOfVnodeWriteThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeWriteThreads"
,
tsNumOfVnodeWriteThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeSyncThreads
=
tsNumOfCores
/
2
;
tsNumOfVnodeSyncThreads
=
tsNumOfCores
/
2
;
tsNumOfVnodeSyncThreads
=
TM
IN
(
tsNumOfVnodeSyncThreads
,
1
);
tsNumOfVnodeSyncThreads
=
TM
AX
(
tsNumOfVnodeSyncThreads
,
1
);
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeSyncThreads"
,
tsNumOfVnodeSyncThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeSyncThreads"
,
tsNumOfVnodeSyncThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfVnodeMergeThreads
=
tsNumOfCores
/
8
;
tsNumOfVnodeMergeThreads
=
tsNumOfCores
/
8
;
...
@@ -414,7 +414,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
...
@@ -414,7 +414,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeMergeThreads"
,
tsNumOfVnodeMergeThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfVnodeMergeThreads"
,
tsNumOfVnodeMergeThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfQnodeQueryThreads
=
tsNumOfCores
/
2
;
tsNumOfQnodeQueryThreads
=
tsNumOfCores
/
2
;
tsNumOfQnodeQueryThreads
=
TM
IN
(
tsNumOfQnodeQueryThreads
,
1
);
tsNumOfQnodeQueryThreads
=
TM
AX
(
tsNumOfQnodeQueryThreads
,
1
);
if
(
cfgAddInt32
(
pCfg
,
"numOfQnodeQueryThreads"
,
tsNumOfQnodeQueryThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfQnodeQueryThreads"
,
tsNumOfQnodeQueryThreads
,
1
,
1024
,
0
)
!=
0
)
return
-
1
;
tsNumOfQnodeFetchThreads
=
tsNumOfCores
/
2
;
tsNumOfQnodeFetchThreads
=
tsNumOfCores
/
2
;
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
a8f740bc
...
@@ -416,8 +416,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre
...
@@ -416,8 +416,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SNodeMsg *pReq, SMCreateSmaReq *pCre
streamObj
.
version
=
1
;
streamObj
.
version
=
1
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
sql
=
pCreate
->
sql
;
streamObj
.
createdBy
=
STREAM_CREATED_BY__SMA
;
streamObj
.
createdBy
=
STREAM_CREATED_BY__SMA
;
// TODO
streamObj
.
fixedSinkVgId
=
smaObj
.
dstVgId
;
streamObj
.
fixedSinkVgId
=
0
;
streamObj
.
smaId
=
smaObj
.
uid
;
streamObj
.
smaId
=
smaObj
.
uid
;
/*streamObj.physicalPlan = "";*/
/*streamObj.physicalPlan = "";*/
streamObj
.
logicalPlan
=
"not implemented"
;
streamObj
.
logicalPlan
=
"not implemented"
;
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
a8f740bc
...
@@ -60,7 +60,7 @@ static int32_t mndProcessResetOffsetReq(SNodeMsg *pMsg);
...
@@ -60,7 +60,7 @@ static int32_t mndProcessResetOffsetReq(SNodeMsg *pMsg);
static
int32_t
mndPersistMqSetConnReq
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqTopicObj
*
pTopic
,
const
char
*
cgroup
,
static
int32_t
mndPersistMqSetConnReq
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqTopicObj
*
pTopic
,
const
char
*
cgroup
,
const
SMqConsumerEp
*
pConsumerEp
);
const
SMqConsumerEp
*
pConsumerEp
);
static
int32_t
mndPersistRebalanceMsg
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqConsumerEp
*
pConsumerEp
);
static
int32_t
mndPersistRebalanceMsg
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqConsumerEp
*
pConsumerEp
,
const
char
*
topicName
);
static
int32_t
mndPersistCancelConnReq
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqConsumerEp
*
pConsumerEp
,
const
char
*
oldTopicName
);
static
int32_t
mndPersistCancelConnReq
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqConsumerEp
*
pConsumerEp
,
const
char
*
oldTopicName
);
int32_t
mndInitSubscribe
(
SMnode
*
pMnode
)
{
int32_t
mndInitSubscribe
(
SMnode
*
pMnode
)
{
...
@@ -102,12 +102,13 @@ static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj
...
@@ -102,12 +102,13 @@ static SMqSubscribeObj *mndCreateSubscription(SMnode *pMnode, const SMqTopicObj
return
pSub
;
return
pSub
;
}
}
static
int32_t
mndBuildRebalanceMsg
(
void
**
pBuf
,
int32_t
*
pLen
,
const
SMqConsumerEp
*
pConsumerEp
)
{
static
int32_t
mndBuildRebalanceMsg
(
void
**
pBuf
,
int32_t
*
pLen
,
const
SMqConsumerEp
*
pConsumerEp
,
const
char
*
topicName
)
{
SMqMVRebReq
req
=
{
SMqMVRebReq
req
=
{
.
vgId
=
pConsumerEp
->
vgId
,
.
vgId
=
pConsumerEp
->
vgId
,
.
oldConsumerId
=
pConsumerEp
->
oldConsumerId
,
.
oldConsumerId
=
pConsumerEp
->
oldConsumerId
,
.
newConsumerId
=
pConsumerEp
->
consumerId
,
.
newConsumerId
=
pConsumerEp
->
consumerId
,
};
};
req
.
topic
=
strdup
(
topicName
);
int32_t
tlen
=
tEncodeSMqMVRebReq
(
NULL
,
&
req
);
int32_t
tlen
=
tEncodeSMqMVRebReq
(
NULL
,
&
req
);
void
*
buf
=
taosMemoryMalloc
(
sizeof
(
SMsgHead
)
+
tlen
);
void
*
buf
=
taosMemoryMalloc
(
sizeof
(
SMsgHead
)
+
tlen
);
...
@@ -122,6 +123,7 @@ static int32_t mndBuildRebalanceMsg(void **pBuf, int32_t *pLen, const SMqConsume
...
@@ -122,6 +123,7 @@ static int32_t mndBuildRebalanceMsg(void **pBuf, int32_t *pLen, const SMqConsume
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
tEncodeSMqMVRebReq
(
&
abuf
,
&
req
);
tEncodeSMqMVRebReq
(
&
abuf
,
&
req
);
taosMemoryFree
(
req
.
topic
);
*
pBuf
=
buf
;
*
pBuf
=
buf
;
*
pLen
=
tlen
;
*
pLen
=
tlen
;
...
@@ -129,12 +131,12 @@ static int32_t mndBuildRebalanceMsg(void **pBuf, int32_t *pLen, const SMqConsume
...
@@ -129,12 +131,12 @@ static int32_t mndBuildRebalanceMsg(void **pBuf, int32_t *pLen, const SMqConsume
return
0
;
return
0
;
}
}
static
int32_t
mndPersistRebalanceMsg
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqConsumerEp
*
pConsumerEp
)
{
static
int32_t
mndPersistRebalanceMsg
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
const
SMqConsumerEp
*
pConsumerEp
,
const
char
*
topicName
)
{
ASSERT
(
pConsumerEp
->
oldConsumerId
!=
-
1
);
ASSERT
(
pConsumerEp
->
oldConsumerId
!=
-
1
);
void
*
buf
;
void
*
buf
;
int32_t
tlen
;
int32_t
tlen
;
if
(
mndBuildRebalanceMsg
(
&
buf
,
&
tlen
,
pConsumerEp
)
<
0
)
{
if
(
mndBuildRebalanceMsg
(
&
buf
,
&
tlen
,
pConsumerEp
,
topicName
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -502,10 +504,10 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
...
@@ -502,10 +504,10 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
pConsumerEp
->
epoch
=
0
;
pConsumerEp
->
epoch
=
0
;
taosArrayPush
(
pSubConsumer
->
vgInfo
,
pConsumerEp
);
taosArrayPush
(
pSubConsumer
->
vgInfo
,
pConsumerEp
);
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
mndSplitSubscribeKey
(
pSub
->
key
,
topic
,
cgroup
);
if
(
pConsumerEp
->
oldConsumerId
==
-
1
)
{
if
(
pConsumerEp
->
oldConsumerId
==
-
1
)
{
char
topic
[
TSDB_TOPIC_FNAME_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
mndSplitSubscribeKey
(
pSub
->
key
,
topic
,
cgroup
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
topic
);
SMqTopicObj
*
pTopic
=
mndAcquireTopic
(
pMnode
,
topic
);
mInfo
(
"mq set conn: assign vgroup %d of topic %s to consumer %"
PRId64
" cgroup: %s"
,
pConsumerEp
->
vgId
,
mInfo
(
"mq set conn: assign vgroup %d of topic %s to consumer %"
PRId64
" cgroup: %s"
,
pConsumerEp
->
vgId
,
...
@@ -517,7 +519,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
...
@@ -517,7 +519,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
mInfo
(
"mq rebalance: assign vgroup %d, from consumer %"
PRId64
" to consumer %"
PRId64
""
,
mInfo
(
"mq rebalance: assign vgroup %d, from consumer %"
PRId64
" to consumer %"
PRId64
""
,
pConsumerEp
->
vgId
,
pConsumerEp
->
oldConsumerId
,
pConsumerEp
->
consumerId
);
pConsumerEp
->
vgId
,
pConsumerEp
->
oldConsumerId
,
pConsumerEp
->
consumerId
);
mndPersistRebalanceMsg
(
pMnode
,
pTrans
,
pConsumerEp
);
mndPersistRebalanceMsg
(
pMnode
,
pTrans
,
pConsumerEp
,
topic
);
}
}
}
}
}
}
...
@@ -849,7 +851,7 @@ static int32_t mndProcessSubscribeReq(SNodeMsg *pMsg) {
...
@@ -849,7 +851,7 @@ static int32_t mndProcessSubscribeReq(SNodeMsg *pMsg) {
pConsumerEp
->
consumerId
);
pConsumerEp
->
consumerId
);
mndPersistMqSetConnReq
(
pMnode
,
pTrans
,
pTopic
,
cgroup
,
pConsumerEp
);
mndPersistMqSetConnReq
(
pMnode
,
pTrans
,
pTopic
,
cgroup
,
pConsumerEp
);
}
else
{
}
else
{
mndPersistRebalanceMsg
(
pMnode
,
pTrans
,
pConsumerEp
);
mndPersistRebalanceMsg
(
pMnode
,
pTrans
,
pConsumerEp
,
newTopicName
);
}
}
// to trigger rebalance at once, do not set status active
// to trigger rebalance at once, do not set status active
/*atomic_store_32(&pConsumer->status, MQ_CONSUMER_STATUS__ACTIVE);*/
/*atomic_store_32(&pConsumer->status, MQ_CONSUMER_STATUS__ACTIVE);*/
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
a8f740bc
set
(
META_DB_IMPL_LIST
"BDB"
"TDB"
)
# vnode
set
(
META_DB_IMPL
"TDB"
CACHE STRING
"Use BDB as the default META implementation"
)
add_library
(
vnode STATIC
""
)
set_property
(
CACHE META_DB_IMPL PROPERTY STRINGS
${
META_DB_IMPL_LIST
}
)
target_sources
(
vnode
if
(
META_DB_IMPL IN_LIST META_DB_IMPL_LIST
)
PRIVATE
message
(
STATUS
"META DB Impl:
${
META_DB_IMPL
}
=============="
)
# vnode
else
()
"src/vnd/vnodeArenaMAImpl.c"
message
(
FATAL_ERROR
"Invalid META DB IMPL:
${
META_DB_IMPL
}
=============="
)
"src/vnd/vnodeBufferPool.c"
endif
()
"src/vnd/vnodeCfg.c"
"src/vnd/vnodeCommit.c"
"src/vnd/vnodeInt.c"
"src/vnd/vnodeMain.c"
"src/vnd/vnodeMgr.c"
"src/vnd/vnodeQuery.c"
"src/vnd/vnodeStateMgr.c"
"src/vnd/vnodeWrite.c"
aux_source_directory
(
src/meta META_SRC
)
# meta
if
(
${
META_DB_IMPL
}
STREQUAL
"BDB"
)
# "src/meta/metaBDBImpl.c"
list
(
REMOVE_ITEM META_SRC
"src/meta/metaTDBImpl.c"
)
"src/meta/metaCache.c"
elseif
(
${
META_DB_IMPL
}
STREQUAL
"TDB"
)
"src/meta/metaCfg.c"
list
(
REMOVE_ITEM META_SRC
"src/meta/metaBDBImpl.c"
)
"src/meta/metaIdx.c"
endif
()
"src/meta/metaMain.c"
"src/meta/metaQuery.c"
"src/meta/metaTable.c"
"src/meta/metaTbCfg.c"
"src/meta/metaTbTag.c"
"src/meta/metaTbUid.c"
"src/meta/metaTDBImpl.c"
aux_source_directory
(
src/tq TQ_SRC
)
# tsdb
aux_source_directory
(
src/tsdb TSDB_SRC
)
# "src/tsdb/tsdbBDBImpl.c"
aux_source_directory
(
src/vnd VND_SRC
)
"src/tsdb/tsdbCommit.c"
"src/tsdb/tsdbCompact.c"
"src/tsdb/tsdbFile.c"
"src/tsdb/tsdbFS.c"
"src/tsdb/tsdbMain.c"
"src/tsdb/tsdbMemTable.c"
"src/tsdb/tsdbOptions.c"
"src/tsdb/tsdbRead.c"
"src/tsdb/tsdbReadImpl.c"
"src/tsdb/tsdbScan.c"
# "src/tsdb/tsdbSma.c"
"src/tsdb/tsdbWrite.c"
list
(
APPEND
# tq
VNODE_SRC
"src/tq/tq.c"
${
META_SRC
}
"src/tq/tqCommit.c"
${
TQ_SRC
}
"src/tq/tqMetaStore.c"
${
TSDB_SRC
}
"src/tq/tqOffset.c"
${
VND_SRC
}
"src/tq/tqPush.c"
"src/tq/tqRead.c"
)
)
add_library
(
vnode STATIC
${
VNODE_SRC
}
)
target_include_directories
(
target_include_directories
(
vnode
vnode
PUBLIC
inc
PUBLIC
"inc"
PRIVATE
src/inc
PRIVATE
"src/inc"
)
)
target_link_libraries
(
target_link_libraries
(
vnode
vnode
PUBLIC os
PUBLIC os
PUBLIC util
PUBLIC util
PUBLIC common
PUBLIC common
PUBLIC transport
PUBLIC tfs
PUBLIC tfs
PUBLIC wal
PUBLIC wal
PUBLIC scheduler
PUBLIC executor
PUBLIC stream
PUBLIC qworker
PUBLIC qworker
PUBLIC sync
PUBLIC sync
# TODO: get rid of BDB
PUBLIC executor
PUBLIC
bdb
PUBLIC
scheduler
PUBLIC tdb
PUBLIC tdb
#PUBLIC bdb
PUBLIC transport
PUBLIC stream
)
)
if
(
${
BUILD_TEST
}
)
if
(
${
BUILD_TEST
}
)
...
...
source/dnode/vnode/inc/meta.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_META_H_
#define _TD_META_H_
#include "tmallocator.h"
#include "tmsg.h"
#include "trow.h"
#ifdef __cplusplus
extern
"C"
{
#endif
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
// Types exported
typedef
struct
SMeta
SMeta
;
typedef
struct
SMetaCfg
{
/// LRU cache size
uint64_t
lruSize
;
}
SMetaCfg
;
typedef
struct
SMTbCursor
SMTbCursor
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMSmaCursor
SMSmaCursor
;
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTSmaReq
SSmaCfg
;
// SMeta operations
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
void
metaClose
(
SMeta
*
pMeta
);
void
metaRemove
(
const
char
*
path
);
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
// For Query
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
STSma
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
,
bool
isDup
);
int
metaGetTbNum
(
SMeta
*
pMeta
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseSmaCurosr
(
SMSmaCursor
*
pSmaCur
);
const
char
*
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
// Options
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsClear
(
SMetaCfg
*
pMetaCfg
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_META_H_*/
source/dnode/vnode/inc/tsdb.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_H_
#define _TD_TSDB_H_
#include "tmallocator.h"
#include "meta.h"
#include "tcommon.h"
#include "tfs.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SDataStatis
{
int16_t
colId
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
int64_t
sum
;
int64_t
max
;
int64_t
min
;
}
SDataStatis
;
typedef
struct
STable
{
uint64_t
tid
;
uint64_t
uid
;
STSchema
*
pSchema
;
}
STable
;
#define BLOCK_LOAD_OFFSET_SEQ_ORDER 1
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_RR_ORDER 3
#define TABLE_TID(t) (t)->tid
#define TABLE_UID(t) (t)->uid
// TYPES EXPOSED
typedef
struct
STsdb
STsdb
;
typedef
struct
STsdbCfg
{
int8_t
precision
;
int8_t
update
;
int8_t
compression
;
int32_t
daysPerFile
;
int32_t
minRowsPerFileBlock
;
int32_t
maxRowsPerFileBlock
;
int32_t
keep
;
int32_t
keep1
;
int32_t
keep2
;
uint64_t
lruCacheSize
;
SArray
*
retentions
;
}
STsdbCfg
;
// query condition to build multi-table data block iterator
typedef
struct
STsdbQueryCond
{
STimeWindow
twindow
;
int32_t
order
;
// desc|asc order to iterate the data block
int32_t
numOfCols
;
SColumnInfo
*
colList
;
bool
loadExternalRows
;
// load external rows or not
int32_t
type
;
// data block load type:
}
STsdbQueryCond
;
typedef
struct
{
TSKEY
lastKey
;
uint64_t
uid
;
}
STableKeyInfo
;
// STsdb
STsdb
*
tsdbOpen
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STfs
*
pTfs
);
void
tsdbClose
(
STsdb
*
);
void
tsdbRemove
(
const
char
*
path
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbInitSma
(
STsdb
*
pTsdb
);
int32_t
tsdbCreateTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbDropTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
/**
* @brief When submit msg received, update the relative expired window synchronously.
*
* @param pTsdb
* @param msg
* @return int32_t
*/
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
/**
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
*
* @param pTsdb
* @param indexUid
* @param msg
* @return int32_t
*/
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
,
const
char
*
msg
);
/**
* @brief Drop tSma data and local cache.
*
* @param pTsdb
* @param indexUid
* @return int32_t
*/
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
);
/**
* @brief Insert RSma(Rollup SMA) data.
*
* @param pTsdb
* @param msg
* @return int32_t
*/
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
// TODO: This is the basic params, and should wrap the params to a queryHandle.
/**
* @brief Get tSma(Time-range-wise SMA) data.
*
* @param pTsdb
* @param pData
* @param indexUid
* @param querySKey
* @param nMaxResult
* @return int32_t
*/
int32_t
tsdbGetTSmaData
(
STsdb
*
pTsdb
,
char
*
pData
,
int64_t
indexUid
,
TSKEY
querySKey
,
int32_t
nMaxResult
);
// STsdbCfg
int
tsdbOptionsInit
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
typedef
void
*
tsdbReaderT
;
/**
* Get the data block iterator, starting from position according to the query condition
*
* @param tsdb tsdb handle
* @param pCond query condition, including time window, result set order, and basic required columns for each block
* @param tableInfoGroup table object list in the form of set, grouped into different sets according to the
* group by condition
* @param qinfo query info handle from query processor
* @return
*/
tsdbReaderT
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
);
/**
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
* Note that only one data block with only row will be returned while invoking retrieve data block function for
* all tables in this group.
*
* @param tsdb tsdb handle
* @param pCond query condition, including time window, result set order, and basic required columns for each block
* @param tableInfo table list.
* @return
*/
//tsdbReaderT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfo, uint64_t qId,
// SMemRef *pRef);
tsdbReaderT
tsdbQueryCacheLast
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
int32_t
tsdbGetFileBlocksDistInfo
(
tsdbReaderT
*
pReader
,
STableBlockDistInfo
*
pTableBlockInfo
);
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
/**
*
* @param tsdb
* @param uid
* @param skey
* @param pTagCond
* @param len
* @param tagNameRelType
* @param tbnameCond
* @param pGroupInfo
* @param pColIndex
* @param numOfCols
* @param reqId
* @return
*/
int32_t
tsdbQuerySTableByTagCond
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
);
/**
* get num of rows in mem table
*
* @param pHandle
* @return row size
*/
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
/**
* move to next block if exists
*
* @param pTsdbReadHandle
* @return
*/
bool
tsdbNextDataBlock
(
tsdbReaderT
pTsdbReadHandle
);
/**
* Get current data block information
*
* @param pTsdbReadHandle
* @param pBlockInfo
* @return
*/
void
tsdbRetrieveDataBlockInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
/**
*
* Get the pre-calculated information w.r.t. current data block.
*
* In case of data block in cache, the pBlockStatis will always be NULL.
* If a block is not completed loaded from disk, the pBlockStatis will be NULL.
* @pBlockStatis the pre-calculated value for current data blocks. if the block is a cache block, always return 0
* @return
*/
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataStatis
**
pBlockStatis
);
/**
*
* The query condition with primary timestamp is passed to iterator during its constructor function,
* the returned data block must be satisfied with the time window condition in any cases,
* which means the SData data block is not actually the completed disk data blocks.
*
* @param pTsdbReadHandle query handle
* @param pColumnIdList required data columns id list
* @return
*/
SArray
*
tsdbRetrieveDataBlock
(
tsdbReaderT
*
pTsdbReadHandle
,
SArray
*
pColumnIdList
);
/**
* destroy the created table group list, which is generated by tag query
* @param pGroupList
*/
void
tsdbDestroyTableGroup
(
STableGroupInfo
*
pGroupList
);
/**
* create the table group result including only one table, used to handle the normal table query
*
* @param tsdb tsdbHandle
* @param uid table uid
* @param pGroupInfo the generated result
* @return
*/
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
/**
*
* @param tsdb
* @param pTableIdList
* @param pGroupInfo
* @return
*/
int32_t
tsdbGetTableGroupFromIdList
(
STsdb
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
);
/**
* clean up the query handle
* @param queryHandle
*/
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
int32_t
tdScanAndConvertSubmitMsg
(
SSubmitReq
*
pMsg
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_H_*/
source/dnode/vnode/inc/vnode.h
浏览文件 @
a8f740bc
...
@@ -21,12 +21,17 @@
...
@@ -21,12 +21,17 @@
#include "tqueue.h"
#include "tqueue.h"
#include "trpc.h"
#include "trpc.h"
#include "meta.h"
#include "tarray.h"
#include "tarray.h"
#include "tfs.h"
#include "tfs.h"
#include "tsdb.h"
#include "wal.h"
#include "wal.h"
#include "tmallocator.h"
#include "tmsg.h"
#include "trow.h"
#include "tmallocator.h"
#include "tcommon.h"
#include "tfs.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
...
@@ -34,6 +39,82 @@ extern "C" {
...
@@ -34,6 +39,82 @@ extern "C" {
/* ------------------------ TYPES EXPOSED ------------------------ */
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef
struct
SMgmtWrapper
SMgmtWrapper
;
typedef
struct
SMgmtWrapper
SMgmtWrapper
;
typedef
struct
SVnode
SVnode
;
typedef
struct
SVnode
SVnode
;
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
// Types exported
typedef
struct
SMeta
SMeta
;
typedef
struct
SMetaCfg
{
/// LRU cache size
uint64_t
lruSize
;
}
SMetaCfg
;
typedef
struct
SMTbCursor
SMTbCursor
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMSmaCursor
SMSmaCursor
;
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTSmaReq
SSmaCfg
;
typedef
struct
SDataStatis
{
int16_t
colId
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
int64_t
sum
;
int64_t
max
;
int64_t
min
;
}
SDataStatis
;
typedef
struct
STsdbQueryCond
{
STimeWindow
twindow
;
int32_t
order
;
// desc|asc order to iterate the data block
int32_t
numOfCols
;
SColumnInfo
*
colList
;
bool
loadExternalRows
;
// load external rows or not
int32_t
type
;
// data block load type:
}
STsdbQueryCond
;
typedef
struct
{
TSKEY
lastKey
;
uint64_t
uid
;
}
STableKeyInfo
;
typedef
struct
STable
{
uint64_t
tid
;
uint64_t
uid
;
STSchema
*
pSchema
;
}
STable
;
#define BLOCK_LOAD_OFFSET_SEQ_ORDER 1
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_RR_ORDER 3
#define TABLE_TID(t) (t)->tid
#define TABLE_UID(t) (t)->uid
// TYPES EXPOSED
typedef
struct
STsdb
STsdb
;
typedef
struct
STsdbCfg
{
int8_t
precision
;
int8_t
update
;
int8_t
compression
;
int32_t
daysPerFile
;
int32_t
minRowsPerFileBlock
;
int32_t
maxRowsPerFileBlock
;
int32_t
keep
;
int32_t
keep1
;
int32_t
keep2
;
uint64_t
lruCacheSize
;
SArray
*
retentions
;
}
STsdbCfg
;
typedef
struct
{
typedef
struct
{
// TODO
// TODO
int32_t
reserved
;
int32_t
reserved
;
...
@@ -263,6 +344,241 @@ int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockIn
...
@@ -263,6 +344,241 @@ int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockIn
// return SArray<SColumnInfoData>
// return SArray<SColumnInfoData>
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
// meta.h
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
void
metaClose
(
SMeta
*
pMeta
);
void
metaRemove
(
const
char
*
path
);
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
STSma
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
,
bool
isDup
);
int
metaGetTbNum
(
SMeta
*
pMeta
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseSmaCurosr
(
SMSmaCursor
*
pSmaCur
);
const
char
*
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
// Options
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
void
metaOptionsClear
(
SMetaCfg
*
pMetaCfg
);
// query condition to build multi-table data block iterator
// STsdb
STsdb
*
tsdbOpen
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STfs
*
pTfs
);
void
tsdbClose
(
STsdb
*
);
void
tsdbRemove
(
const
char
*
path
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbInitSma
(
STsdb
*
pTsdb
);
int32_t
tsdbCreateTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbDropTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
/**
* @brief When submit msg received, update the relative expired window synchronously.
*
* @param pTsdb
* @param msg
* @return int32_t
*/
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
/**
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
*
* @param pTsdb
* @param indexUid
* @param msg
* @return int32_t
*/
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
,
const
char
*
msg
);
/**
* @brief Drop tSma data and local cache.
*
* @param pTsdb
* @param indexUid
* @return int32_t
*/
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
);
/**
* @brief Insert RSma(Rollup SMA) data.
*
* @param pTsdb
* @param msg
* @return int32_t
*/
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
// TODO: This is the basic params, and should wrap the params to a queryHandle.
/**
* @brief Get tSma(Time-range-wise SMA) data.
*
* @param pTsdb
* @param pData
* @param indexUid
* @param querySKey
* @param nMaxResult
* @return int32_t
*/
int32_t
tsdbGetTSmaData
(
STsdb
*
pTsdb
,
char
*
pData
,
int64_t
indexUid
,
TSKEY
querySKey
,
int32_t
nMaxResult
);
// STsdbCfg
int
tsdbOptionsInit
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
typedef
void
*
tsdbReaderT
;
/**
* Get the data block iterator, starting from position according to the query condition
*
* @param tsdb tsdb handle
* @param pCond query condition, including time window, result set order, and basic required columns for each block
* @param tableInfoGroup table object list in the form of set, grouped into different sets according to the
* group by condition
* @param qinfo query info handle from query processor
* @return
*/
tsdbReaderT
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
);
/**
* Get the last row of the given query time window for all the tables in STableGroupInfo object.
* Note that only one data block with only row will be returned while invoking retrieve data block function for
* all tables in this group.
*
* @param tsdb tsdb handle
* @param pCond query condition, including time window, result set order, and basic required columns for each block
* @param tableInfo table list.
* @return
*/
//tsdbReaderT tsdbQueryLastRow(STsdbRepo *tsdb, STsdbQueryCond *pCond, STableGroupInfo *tableInfo, uint64_t qId,
// SMemRef *pRef);
tsdbReaderT
tsdbQueryCacheLast
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
int32_t
tsdbGetFileBlocksDistInfo
(
tsdbReaderT
*
pReader
,
STableBlockDistInfo
*
pTableBlockInfo
);
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
/**
*
* @param tsdb
* @param uid
* @param skey
* @param pTagCond
* @param len
* @param tagNameRelType
* @param tbnameCond
* @param pGroupInfo
* @param pColIndex
* @param numOfCols
* @param reqId
* @return
*/
int32_t
tsdbQuerySTableByTagCond
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
);
/**
* get num of rows in mem table
*
* @param pHandle
* @return row size
*/
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
/**
* move to next block if exists
*
* @param pTsdbReadHandle
* @return
*/
bool
tsdbNextDataBlock
(
tsdbReaderT
pTsdbReadHandle
);
/**
* Get current data block information
*
* @param pTsdbReadHandle
* @param pBlockInfo
* @return
*/
void
tsdbRetrieveDataBlockInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
/**
*
* Get the pre-calculated information w.r.t. current data block.
*
* In case of data block in cache, the pBlockStatis will always be NULL.
* If a block is not completed loaded from disk, the pBlockStatis will be NULL.
* @pBlockStatis the pre-calculated value for current data blocks. if the block is a cache block, always return 0
* @return
*/
int32_t
tsdbRetrieveDataBlockStatisInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataStatis
**
pBlockStatis
);
/**
*
* The query condition with primary timestamp is passed to iterator during its constructor function,
* the returned data block must be satisfied with the time window condition in any cases,
* which means the SData data block is not actually the completed disk data blocks.
*
* @param pTsdbReadHandle query handle
* @param pColumnIdList required data columns id list
* @return
*/
SArray
*
tsdbRetrieveDataBlock
(
tsdbReaderT
*
pTsdbReadHandle
,
SArray
*
pColumnIdList
);
/**
* destroy the created table group list, which is generated by tag query
* @param pGroupList
*/
void
tsdbDestroyTableGroup
(
STableGroupInfo
*
pGroupList
);
/**
* create the table group result including only one table, used to handle the normal table query
*
* @param tsdb tsdbHandle
* @param uid table uid
* @param pGroupInfo the generated result
* @return
*/
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
/**
*
* @param tsdb
* @param pTableIdList
* @param pGroupInfo
* @return
*/
int32_t
tsdbGetTableGroupFromIdList
(
STsdb
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
);
/**
* clean up the query handle
* @param queryHandle
*/
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
int32_t
tdScanAndConvertSubmitMsg
(
SSubmitReq
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/inc/meta
Def
.h
→
source/dnode/vnode/src/inc/meta.h
浏览文件 @
a8f740bc
...
@@ -13,12 +13,8 @@
...
@@ -13,12 +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_META_DEF_H_
#ifndef _TD_VNODE_META_H_
#define _TD_META_DEF_H_
#define _TD_VNODE_META_H_
#include "tmallocator.h"
#include "meta.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -78,4 +74,4 @@ struct SMeta {
...
@@ -78,4 +74,4 @@ struct SMeta {
}
}
#endif
#endif
#endif
/*_TD_
META_DEF
_H_*/
#endif
/*_TD_
VNODE_META
_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/tq
Int
.h
→
source/dnode/vnode/src/inc/tq.h
浏览文件 @
a8f740bc
...
@@ -13,18 +13,14 @@
...
@@ -13,18 +13,14 @@
* 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_TQ_INT_H_
#ifndef _TD_VNODE_TQ_H_
#define _TD_TQ_INT_H_
#define _TD_VNODE_TQ_H_
#include "meta.h"
#include "tlog.h"
#include "tqPush.h"
#include "vnd.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
// tqInt.h
#define tqFatal(...) \
#define tqFatal(...) \
{ \
{ \
if (tqDebugFlag & DEBUG_FATAL) { \
if (tqDebugFlag & DEBUG_FATAL) { \
...
@@ -106,6 +102,9 @@ static const int8_t TQ_CONST_DELETE = TQ_ACTION_CONST;
...
@@ -106,6 +102,9 @@ static const int8_t TQ_CONST_DELETE = TQ_ACTION_CONST;
typedef
enum
{
TQ_ITEM_READY
,
TQ_ITEM_PROCESS
,
TQ_ITEM_EMPTY
}
STqItemStatus
;
typedef
enum
{
TQ_ITEM_READY
,
TQ_ITEM_PROCESS
,
TQ_ITEM_EMPTY
}
STqItemStatus
;
typedef
struct
STqOffsetCfg
STqOffsetCfg
;
typedef
struct
STqOffsetStore
STqOffsetStore
;
typedef
struct
{
typedef
struct
{
int16_t
ver
;
int16_t
ver
;
int16_t
action
;
int16_t
action
;
...
@@ -211,13 +210,93 @@ typedef struct {
...
@@ -211,13 +210,93 @@ typedef struct {
SArray
*
topics
;
// SArray<STqTopic>
SArray
*
topics
;
// SArray<STqTopic>
}
STqConsumer
;
}
STqConsumer
;
enum
{
TQ_PUSHER_TYPE__CLIENT
=
1
,
TQ_PUSHER_TYPE__STREAM
,
};
typedef
struct
{
int8_t
type
;
int8_t
reserved
[
3
];
int32_t
ttl
;
int64_t
consumerId
;
SRpcMsg
*
pMsg
;
// SMqPollRsp* rsp;
}
STqClientPusher
;
typedef
struct
{
int8_t
type
;
int8_t
nodeType
;
int8_t
reserved
[
6
];
int64_t
streamId
;
qTaskInfo_t
task
;
// TODO sync function
}
STqStreamPusher
;
typedef
struct
{
int8_t
type
;
// mq or stream
}
STqPusher
;
typedef
struct
{
SHashObj
*
pHash
;
// <id, STqPush*>
}
STqPushMgr
;
typedef
struct
{
int8_t
inited
;
tmr_h
timer
;
}
STqPushMgmt
;
static
STqPushMgmt
tqPushMgmt
;
int32_t
tqSerializeConsumer
(
const
STqConsumer
*
,
STqSerializedHead
**
);
int32_t
tqSerializeConsumer
(
const
STqConsumer
*
,
STqSerializedHead
**
);
int32_t
tqDeserializeConsumer
(
STQ
*
,
const
STqSerializedHead
*
,
STqConsumer
**
);
int32_t
tqDeserializeConsumer
(
STQ
*
,
const
STqSerializedHead
*
,
STqConsumer
**
);
static
int
FORCE_INLINE
tqQueryExecuting
(
int32_t
status
)
{
return
status
;
}
static
int
FORCE_INLINE
tqQueryExecuting
(
int32_t
status
)
{
return
status
;
}
// tqMetaStore.h
STqMetaStore
*
tqStoreOpen
(
STQ
*
pTq
,
const
char
*
path
,
FTqSerialize
pSerializer
,
FTqDeserialize
pDeserializer
,
FTqDelete
pDeleter
,
int32_t
tqConfigFlag
);
int32_t
tqStoreClose
(
STqMetaStore
*
);
// int32_t tqStoreDelete(TqMetaStore*);
// int32_t tqStoreCommitAll(TqMetaStore*);
int32_t
tqStorePersist
(
STqMetaStore
*
);
// clean deleted idx and data from persistent file
int32_t
tqStoreCompact
(
STqMetaStore
*
);
void
*
tqHandleGet
(
STqMetaStore
*
,
int64_t
key
);
// make it unpersist
void
*
tqHandleTouchGet
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandleMovePut
(
STqMetaStore
*
,
int64_t
key
,
void
*
value
);
int32_t
tqHandleCopyPut
(
STqMetaStore
*
,
int64_t
key
,
void
*
value
,
size_t
vsize
);
// delete committed kv pair
// notice that a delete action still needs to be committed
int32_t
tqHandleDel
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandlePurge
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandleCommit
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandleAbort
(
STqMetaStore
*
,
int64_t
key
);
// tqOffset
STqOffsetStore
*
STqOffsetOpen
(
STqOffsetCfg
*
);
void
STqOffsetClose
(
STqOffsetStore
*
);
int64_t
tqOffsetFetch
(
STqOffsetStore
*
pStore
,
const
char
*
subscribeKey
);
int32_t
tqOffsetCommit
(
STqOffsetStore
*
pStore
,
const
char
*
subscribeKey
,
int64_t
offset
);
int32_t
tqOffsetPersist
(
STqOffsetStore
*
pStore
,
const
char
*
subscribeKey
);
int32_t
tqOffsetPersistAll
(
STqOffsetStore
*
pStore
);
// tqPush
int32_t
tqPushMgrInit
();
void
tqPushMgrCleanUp
();
STqPushMgr
*
tqPushMgrOpen
();
void
tqPushMgrClose
(
STqPushMgr
*
pushMgr
);
STqClientPusher
*
tqAddClientPusher
(
STqPushMgr
*
pushMgr
,
SRpcMsg
*
pMsg
,
int64_t
consumerId
,
int64_t
ttl
);
STqStreamPusher
*
tqAddStreamPusher
(
STqPushMgr
*
pushMgr
,
int64_t
streamId
,
SEpSet
*
pEpSet
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/*_TD_
TQ_INT
_H_*/
#endif
/*_TD_
VNODE_TQ
_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/tqCommit.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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/>.
*/
source/dnode/vnode/src/inc/tqMetaStore.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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 _TQ_META_STORE_H_
#define _TQ_META_STORE_H_
#include "os.h"
#include "tqInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
STqMetaStore
*
tqStoreOpen
(
STQ
*
pTq
,
const
char
*
path
,
FTqSerialize
pSerializer
,
FTqDeserialize
pDeserializer
,
FTqDelete
pDeleter
,
int32_t
tqConfigFlag
);
int32_t
tqStoreClose
(
STqMetaStore
*
);
// int32_t tqStoreDelete(TqMetaStore*);
// int32_t tqStoreCommitAll(TqMetaStore*);
int32_t
tqStorePersist
(
STqMetaStore
*
);
// clean deleted idx and data from persistent file
int32_t
tqStoreCompact
(
STqMetaStore
*
);
void
*
tqHandleGet
(
STqMetaStore
*
,
int64_t
key
);
// make it unpersist
void
*
tqHandleTouchGet
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandleMovePut
(
STqMetaStore
*
,
int64_t
key
,
void
*
value
);
int32_t
tqHandleCopyPut
(
STqMetaStore
*
,
int64_t
key
,
void
*
value
,
size_t
vsize
);
// delete committed kv pair
// notice that a delete action still needs to be committed
int32_t
tqHandleDel
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandlePurge
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandleCommit
(
STqMetaStore
*
,
int64_t
key
);
int32_t
tqHandleAbort
(
STqMetaStore
*
,
int64_t
key
);
#ifdef __cplusplus
}
#endif
#endif
/* ifndef _TQ_META_STORE_H_ */
source/dnode/vnode/src/inc/tqOffset.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TQ_OFFSET_H_
#define _TD_TQ_OFFSET_H_
#include "tqInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
STqOffsetCfg
STqOffsetCfg
;
typedef
struct
STqOffsetStore
STqOffsetStore
;
STqOffsetStore
*
STqOffsetOpen
(
STqOffsetCfg
*
);
void
STqOffsetClose
(
STqOffsetStore
*
);
int64_t
tqOffsetFetch
(
STqOffsetStore
*
pStore
,
const
char
*
subscribeKey
);
int32_t
tqOffsetCommit
(
STqOffsetStore
*
pStore
,
const
char
*
subscribeKey
,
int64_t
offset
);
int32_t
tqOffsetPersist
(
STqOffsetStore
*
pStore
,
const
char
*
subscribeKey
);
int32_t
tqOffsetPersistAll
(
STqOffsetStore
*
pStore
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TQ_OFFSET_H_*/
source/dnode/vnode/src/inc/tqPush.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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 _TQ_PUSH_H_
#define _TQ_PUSH_H_
#include "executor.h"
#include "thash.h"
#include "trpc.h"
#include "ttimer.h"
#include "vnode.h"
#ifdef __cplusplus
extern
"C"
{
#endif
enum
{
TQ_PUSHER_TYPE__CLIENT
=
1
,
TQ_PUSHER_TYPE__STREAM
,
};
typedef
struct
{
int8_t
type
;
int8_t
reserved
[
3
];
int32_t
ttl
;
int64_t
consumerId
;
SRpcMsg
*
pMsg
;
// SMqPollRsp* rsp;
}
STqClientPusher
;
typedef
struct
{
int8_t
type
;
int8_t
nodeType
;
int8_t
reserved
[
6
];
int64_t
streamId
;
qTaskInfo_t
task
;
// TODO sync function
}
STqStreamPusher
;
typedef
struct
{
int8_t
type
;
// mq or stream
}
STqPusher
;
typedef
struct
{
SHashObj
*
pHash
;
// <id, STqPush*>
}
STqPushMgr
;
typedef
struct
{
int8_t
inited
;
tmr_h
timer
;
}
STqPushMgmt
;
static
STqPushMgmt
tqPushMgmt
;
int32_t
tqPushMgrInit
();
void
tqPushMgrCleanUp
();
STqPushMgr
*
tqPushMgrOpen
();
void
tqPushMgrClose
(
STqPushMgr
*
pushMgr
);
STqClientPusher
*
tqAddClientPusher
(
STqPushMgr
*
pushMgr
,
SRpcMsg
*
pMsg
,
int64_t
consumerId
,
int64_t
ttl
);
STqStreamPusher
*
tqAddStreamPusher
(
STqPushMgr
*
pushMgr
,
int64_t
streamId
,
SEpSet
*
pEpSet
);
#ifdef __cplusplus
}
#endif
#endif
/*_TQ_PUSH_H_*/
source/dnode/vnode/src/inc/tsdb
File
.h
→
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
a8f740bc
...
@@ -13,40 +13,16 @@
...
@@ -13,40 +13,16 @@
* 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 _TS_TSDB_FILE_H_
#ifndef _TD_VNODE_TSDB_H_
#define _TS_TSDB_FILE_H_
#define _TD_VNODE_TSDB_H_
#include "tchecksum.h"
#include "tfs.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
#define TSDB_FILE_HEAD_SIZE 512
typedef
struct
SSmaStat
SSmaStat
;
#define TSDB_FILE_DELIMITER 0xF00AFA0F
typedef
struct
SSmaEnv
SSmaEnv
;
#define TSDB_FILE_INIT_MAGIC 0xFFFFFFFF
typedef
struct
SSmaEnvs
SSmaEnvs
;
#define TSDB_IVLD_FID INT_MIN
#define TSDB_FILE_STATE_OK 0
#define TSDB_FILE_STATE_BAD 1
#define TSDB_FILE_INFO(tf) (&((tf)->info))
#define TSDB_FILE_F(tf) (&((tf)->f))
#define TSDB_FILE_PFILE(tf) ((tf)->pFile)
#define TSDB_FILE_FULL_NAME(tf) (TSDB_FILE_F(tf)->aname)
#define TSDB_FILE_OPENED(tf) (TSDB_FILE_PFILE(tf) != NULL)
#define TSDB_FILE_CLOSED(tf) (!TSDB_FILE_OPENED(tf))
#define TSDB_FILE_SET_CLOSED(f) (TSDB_FILE_PFILE(f) = NULL)
#define TSDB_FILE_LEVEL(tf) (TSDB_FILE_F(tf)->did.level)
#define TSDB_FILE_ID(tf) (TSDB_FILE_F(tf)->did.id)
#define TSDB_FILE_DID(tf) (TSDB_FILE_F(tf)->did)
#define TSDB_FILE_REL_NAME(tf) (TSDB_FILE_F(tf)->rname)
#define TSDB_FILE_ABS_NAME(tf) (TSDB_FILE_F(tf)->aname)
#define TSDB_FILE_FSYNC(tf) taosFsyncFile(TSDB_FILE_PFILE(tf))
#define TSDB_FILE_STATE(tf) ((tf)->state)
#define TSDB_FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
typedef
enum
{
typedef
enum
{
TSDB_FILE_HEAD
=
0
,
// .head
TSDB_FILE_HEAD
=
0
,
// .head
...
@@ -60,165 +36,543 @@ typedef enum {
...
@@ -60,165 +36,543 @@ typedef enum {
TSDB_FILE_RSMA
,
// v2r100.${sma_index_name}, Time-range-wise Rollup SMA
TSDB_FILE_RSMA
,
// v2r100.${sma_index_name}, Time-range-wise Rollup SMA
}
E_TSDB_FILE_T
;
}
E_TSDB_FILE_T
;
typedef
int32_t
TSDB_FILE_T
;
typedef
struct
{
typedef
enum
{
uint32_t
magic
;
TSDB_FS_VER_0
=
0
,
uint32_t
fver
;
TSDB_FS_VER_MAX
,
uint32_t
len
;
}
ETsdbFsVer
;
uint32_t
totalBlocks
;
uint32_t
totalSubBlocks
;
uint32_t
offset
;
uint64_t
size
;
uint64_t
tombSize
;
}
SDFInfo
;
#define TSDB_LATEST_FVER TSDB_FS_VER_0 // latest version for DFile
typedef
struct
{
#define TSDB_LATEST_SFS_VER TSDB_FS_VER_0 // latest version for 'current' file
SDFInfo
info
;
STfsFile
f
;
TdFilePtr
pFile
;
uint8_t
state
;
}
SDFile
;
static
FORCE_INLINE
uint32_t
tsdbGetDFSVersion
(
TSDB_FILE_T
fType
)
{
// latest version for DFile
struct
SSmaEnvs
{
switch
(
fType
)
{
int16_t
nTSma
;
case
TSDB_FILE_HEAD
:
// .head
int16_t
nRSma
;
case
TSDB_FILE_DATA
:
// .data
SSmaEnv
*
pTSmaEnv
;
case
TSDB_FILE_LAST
:
// .last
SSmaEnv
*
pRSmaEnv
;
case
TSDB_FILE_SMAD
:
// .smad(Block-wise SMA)
};
case
TSDB_FILE_SMAL
:
// .smal(Block-wise SMA)
default:
typedef
struct
{
return
TSDB_LATEST_FVER
;
int
fid
;
}
int8_t
state
;
// -128~127
uint8_t
ver
;
// 0~255, DFileSet version
uint16_t
reserve
;
SDFile
files
[
TSDB_FILE_MAX
];
}
SDFileSet
;
typedef
struct
{
int
minFid
;
int
midFid
;
int
maxFid
;
TSKEY
minKey
;
}
SRtn
;
typedef
struct
STbData
{
tb_uid_t
uid
;
TSKEY
keyMin
;
TSKEY
keyMax
;
int64_t
nrows
;
SSkipList
*
pData
;
}
STbData
;
typedef
struct
STsdbMemTable
{
T_REF_DECLARE
()
SRWLatch
latch
;
TSKEY
keyMin
;
TSKEY
keyMax
;
uint64_t
nRow
;
SMemAllocator
*
pMA
;
// Container
SSkipList
*
pSlIdx
;
// SSkiplist<STbData>
SHashObj
*
pHashIdx
;
}
STsdbMemTable
;
typedef
struct
{
uint32_t
version
;
// Commit version from 0 to increase
int64_t
totalPoints
;
// total points
int64_t
totalStorage
;
// Uncompressed total storage
}
STsdbFSMeta
;
// ==================
typedef
struct
{
STsdbFSMeta
meta
;
// FS meta
SArray
*
df
;
// data file array
SArray
*
sf
;
// sma data file array v2f1900.index_name_1
}
SFSStatus
;
typedef
struct
{
TdThreadRwlock
lock
;
SFSStatus
*
cstatus
;
// current status
SHashObj
*
metaCache
;
// meta cache
SHashObj
*
metaCacheComp
;
// meta cache for compact
bool
intxn
;
SFSStatus
*
nstatus
;
// new status
}
STsdbFS
;
struct
STsdb
{
int32_t
vgId
;
bool
repoLocked
;
TdThreadMutex
mutex
;
char
*
path
;
STsdbCfg
config
;
STsdbMemTable
*
mem
;
STsdbMemTable
*
imem
;
SRtn
rtn
;
SMemAllocatorFactory
*
pmaf
;
STsdbFS
*
fs
;
SMeta
*
pMeta
;
STfs
*
pTfs
;
SSmaEnvs
smaEnvs
;
};
#define REPO_ID(r) ((r)->vgId)
#define REPO_CFG(r) (&(r)->config)
#define REPO_FS(r) ((r)->fs)
#define REPO_META(r) ((r)->pMeta)
#define REPO_TFS(r) ((r)->pTfs)
#define IS_REPO_LOCKED(r) ((r)->repoLocked)
#define REPO_TSMA_NUM(r) ((r)->smaEnvs.nTSma)
#define REPO_RSMA_NUM(r) ((r)->smaEnvs.nRSma)
#define REPO_TSMA_ENV(r) ((r)->smaEnvs.pTSmaEnv)
#define REPO_RSMA_ENV(r) ((r)->smaEnvs.pRSmaEnv)
int
tsdbLockRepo
(
STsdb
*
pTsdb
);
int
tsdbUnlockRepo
(
STsdb
*
pTsdb
);
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STable
*
pTable
,
bool
lock
,
bool
copy
,
int32_t
version
)
{
return
pTable
->
pSchema
;
}
}
#if 0
// tsdbLog
// =============== SMFile
extern
int32_t
tsdbDebugFlag
;
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TSDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TSDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TSDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TSDB ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSDB ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// tsdbMemTable.h
typedef
struct
{
typedef
struct
{
int64_t size;
int
rowsInserted
;
int64_t tombSize;
int
rowsUpdated
;
int64_t nRecords;
int
rowsDeleteSucceed
;
int64_t nDels;
int
rowsDeleteFailed
;
uint32_t magic;
int
nOperations
;
} SMFInfo;
TSKEY
keyFirst
;
TSKEY
keyLast
;
}
SMergeInfo
;
static
void
*
taosTMalloc
(
size_t
size
);
static
void
*
taosTCalloc
(
size_t
nmemb
,
size_t
size
);
static
void
*
taosTRealloc
(
void
*
ptr
,
size_t
size
);
static
void
*
taosTZfree
(
void
*
ptr
);
static
size_t
taosTSizeof
(
void
*
ptr
);
static
void
taosTMemset
(
void
*
ptr
,
int
c
);
STsdbMemTable
*
tsdbNewMemTable
(
STsdb
*
pTsdb
);
void
tsdbFreeMemTable
(
STsdb
*
pTsdb
,
STsdbMemTable
*
pMemTable
);
int
tsdbMemTableInsert
(
STsdb
*
pTsdb
,
STsdbMemTable
*
pMemTable
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbLoadDataFromCache
(
STable
*
pTable
,
SSkipListIterator
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
static
FORCE_INLINE
STSRow
*
tsdbNextIterRow
(
SSkipListIterator
*
pIter
)
{
if
(
pIter
==
NULL
)
return
NULL
;
SSkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
if
(
node
==
NULL
)
return
NULL
;
return
(
STSRow
*
)
SL_GET_NODE_DATA
(
node
);
}
static
FORCE_INLINE
TSKEY
tsdbNextIterKey
(
SSkipListIterator
*
pIter
)
{
STSRow
*
row
=
tsdbNextIterRow
(
pIter
);
if
(
row
==
NULL
)
return
TSDB_DATA_TIMESTAMP_NULL
;
return
TD_ROW_KEY
(
row
);
}
// tsdbOptions
extern
const
STsdbCfg
defautlTsdbOptions
;
int
tsdbValidateOptions
(
const
STsdbCfg
*
);
void
tsdbOptionsCopy
(
STsdbCfg
*
pDest
,
const
STsdbCfg
*
pSrc
);
// tsdbReadImpl
typedef
struct
SReadH
SReadH
;
typedef
struct
{
typedef
struct
{
SMFInfo info;
uint32_t
len
;
STfsFile f;
uint32_t
offset
;
int fd;
uint32_t
hasLast
:
2
;
uint8_t state;
uint32_t
numOfBlocks
:
30
;
} SMFile;
uint64_t
uid
;
TSKEY
maxKey
;
void tsdbInitMFile(SMFile* pMFile, SDiskID did, int vid, uint32_t ver);
}
SBlockIdx
;
void tsdbInitMFileEx(SMFile* pMFile, const SMFile* pOMFile);
int tsdbEncodeSMFile(void** buf, SMFile* pMFile);
void* tsdbDecodeSMFile(void* buf, SMFile* pMFile);
int tsdbEncodeSMFileEx(void** buf, SMFile* pMFile);
void* tsdbDecodeSMFileEx(void* buf, SMFile* pMFile);
int tsdbApplyMFileChange(SMFile* from, SMFile* to);
int tsdbCreateMFile(SMFile* pMFile, bool updateHeader);
int tsdbUpdateMFileHeader(SMFile* pMFile);
int tsdbLoadMFileHeader(SMFile* pMFile, SMFInfo* pInfo);
int tsdbScanAndTryFixMFile(STsdb* pRepo);
int tsdbEncodeMFInfo(void** buf, SMFInfo* pInfo);
void* tsdbDecodeMFInfo(void* buf, SMFInfo* pInfo);
static FORCE_INLINE void tsdbSetMFileInfo(SMFile* pMFile, SMFInfo* pInfo) { pMFile->info = *pInfo; }
static FORCE_INLINE int tsdbOpenMFile(SMFile* pMFile, int flags) {
ASSERT(TSDB_FILE_CLOSED(pMFile));
pMFile->fd = open(TSDB_FILE_FULL_NAME(pMFile), flags);
if (pMFile->fd < 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
return 0;
#ifdef TD_REFACTOR_3
typedef
struct
{
int64_t
last
:
1
;
int64_t
offset
:
63
;
int32_t
algorithm
:
8
;
int32_t
numOfRows
:
24
;
int32_t
len
;
int32_t
keyLen
;
// key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols
int16_t
numOfSubBlocks
;
int16_t
numOfCols
;
// not including timestamp column
TSKEY
keyFirst
;
TSKEY
keyLast
;
}
SBlock
;
#else
typedef
enum
{
TSDB_SBLK_VER_0
=
0
,
TSDB_SBLK_VER_MAX
,
}
ESBlockVer
;
#define SBlockVerLatest TSDB_SBLK_VER_0
typedef
struct
{
uint8_t
last
:
1
;
uint8_t
blkVer
:
7
;
uint8_t
numOfSubBlocks
;
col_id_t
numOfCols
;
// not including timestamp column
uint32_t
len
;
// data block length
uint32_t
keyLen
:
20
;
// key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols
uint32_t
algorithm
:
4
;
uint32_t
reserve
:
8
;
col_id_t
numOfBSma
;
uint16_t
numOfRows
;
int64_t
offset
;
uint64_t
aggrStat
:
1
;
uint64_t
aggrOffset
:
63
;
TSKEY
keyFirst
;
TSKEY
keyLast
;
}
SBlockV0
;
#define SBlock SBlockV0 // latest SBlock definition
#endif
typedef
struct
{
int32_t
delimiter
;
// For recovery usage
int32_t
tid
;
uint64_t
uid
;
SBlock
blocks
[];
}
SBlockInfo
;
#ifdef TD_REFACTOR_3
typedef
struct
{
int16_t
colId
;
uint16_t
bitmap
:
1
;
// 0: has bitmap if has NULL/NORM rows, 1: no bitmap if all rows are NORM
uint16_t
reserve
:
15
;
int32_t
len
;
uint32_t
type
:
8
;
uint32_t
offset
:
24
;
int64_t
sum
;
int64_t
max
;
int64_t
min
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
uint8_t
offsetH
;
char
padding
[
1
];
}
SBlockCol
;
#else
typedef
struct
{
int16_t
colId
;
uint16_t
type
:
6
;
uint16_t
blen
:
10
;
// bitmap length(TODO: full UT for the bitmap compress of various data input)
uint32_t
bitmap
:
1
;
// 0: has bitmap if has NULL/NORM rows, 1: no bitmap if all rows are NORM
uint32_t
len
:
31
;
// data length + bitmap length
uint32_t
offset
;
}
SBlockColV0
;
#define SBlockCol SBlockColV0 // latest SBlockCol definition
typedef
struct
{
int16_t
colId
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
int64_t
sum
;
int64_t
max
;
int64_t
min
;
}
SAggrBlkColV0
;
#define SAggrBlkCol SAggrBlkColV0 // latest SAggrBlkCol definition
#endif
// Code here just for back-ward compatibility
static
FORCE_INLINE
void
tsdbSetBlockColOffset
(
SBlockCol
*
pBlockCol
,
uint32_t
offset
)
{
#ifdef TD_REFACTOR_3
pBlockCol
->
offset
=
offset
&
((((
uint32_t
)
1
)
<<
24
)
-
1
);
pBlockCol
->
offsetH
=
(
uint8_t
)(
offset
>>
24
);
#else
pBlockCol
->
offset
=
offset
;
#endif
}
static
FORCE_INLINE
uint32_t
tsdbGetBlockColOffset
(
SBlockCol
*
pBlockCol
)
{
#ifdef TD_REFACTOR_3
uint32_t
offset1
=
pBlockCol
->
offset
;
uint32_t
offset2
=
pBlockCol
->
offsetH
;
return
(
offset1
|
(
offset2
<<
24
));
#else
return
pBlockCol
->
offset
;
#endif
}
}
static FORCE_INLINE void tsdbCloseMFile(SMFile* pMFile) {
typedef
struct
{
if (TSDB_FILE_OPENED(pMFile)) {
int32_t
delimiter
;
// For recovery usage
close(pMFile->fd);
int32_t
numOfCols
;
// For recovery usage
TSDB_FILE_SET_CLOSED(pMFile);
uint64_t
uid
;
// For recovery usage
SBlockCol
cols
[];
}
SBlockData
;
typedef
void
SAggrBlkData
;
// SBlockCol cols[];
struct
SReadH
{
STsdb
*
pRepo
;
SDFileSet
rSet
;
// FSET to read
SArray
*
aBlkIdx
;
// SBlockIdx array
STable
*
pTable
;
// table to read
SBlockIdx
*
pBlkIdx
;
// current reading table SBlockIdx
int
cidx
;
SBlockInfo
*
pBlkInfo
;
SBlockData
*
pBlkData
;
// Block info
SAggrBlkData
*
pAggrBlkData
;
// Aggregate Block info
SDataCols
*
pDCols
[
2
];
void
*
pBuf
;
// buffer
void
*
pCBuf
;
// compression buffer
void
*
pExBuf
;
// extra buffer
};
#define TSDB_READ_REPO(rh) ((rh)->pRepo)
#define TSDB_READ_REPO_ID(rh) REPO_ID(TSDB_READ_REPO(rh))
#define TSDB_READ_FSET(rh) (&((rh)->rSet))
#define TSDB_READ_TABLE(rh) ((rh)->pTable)
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
#define TSDB_READ_SMAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_SMAD)
#define TSDB_READ_SMAL_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_SMAL)
#define TSDB_READ_BUF(rh) ((rh)->pBuf)
#define TSDB_READ_COMP_BUF(rh) ((rh)->pCBuf)
#define TSDB_READ_EXBUF(rh) ((rh)->pExBuf)
#define TSDB_BLOCK_STATIS_SIZE(ncols, blkVer) \
(sizeof(SBlockData) + sizeof(SBlockColV##blkVer) * (ncols) + sizeof(TSCKSUM))
static
FORCE_INLINE
size_t
tsdbBlockStatisSize
(
int
nCols
,
uint32_t
blkVer
)
{
switch
(
blkVer
)
{
case
TSDB_SBLK_VER_0
:
default:
return
TSDB_BLOCK_STATIS_SIZE
(
nCols
,
0
);
}
}
}
}
static FORCE_INLINE int64_t tsdbSeekMFile(SMFile* pMFile, int64_t offset, int whence) {
#define TSDB_BLOCK_AGGR_SIZE(ncols, blkVer) (sizeof(SAggrBlkColV##blkVer) * (ncols) + sizeof(TSCKSUM))
ASSERT(TSDB_FILE_OPENED(pMFile));
int64_t loffset = taosLSeekFile(TSDB_FILE_FD(pMFile), offset, whence);
static
FORCE_INLINE
size_t
tsdbBlockAggrSize
(
int
nCols
,
uint32_t
blkVer
)
{
if (loffset < 0) {
switch
(
blkVer
)
{
terrno = TAOS_SYSTEM_ERROR(errno);
case
TSDB_SBLK_VER_0
:
return -1;
default:
return
TSDB_BLOCK_AGGR_SIZE
(
nCols
,
0
);
}
}
return loffset;
}
}
static FORCE_INLINE int64_t tsdbWriteMFile(SMFile* pMFile, void* buf, int64_t nbyte) {
int
tsdbInitReadH
(
SReadH
*
pReadh
,
STsdb
*
pRepo
);
ASSERT(TSDB_FILE_OPENED(pMFile));
void
tsdbDestroyReadH
(
SReadH
*
pReadh
);
int
tsdbSetAndOpenReadFSet
(
SReadH
*
pReadh
,
SDFileSet
*
pSet
);
void
tsdbCloseAndUnsetFSet
(
SReadH
*
pReadh
);
int
tsdbLoadBlockIdx
(
SReadH
*
pReadh
);
int
tsdbSetReadTable
(
SReadH
*
pReadh
,
STable
*
pTable
);
int
tsdbLoadBlockInfo
(
SReadH
*
pReadh
,
void
*
pTarget
);
int
tsdbLoadBlockData
(
SReadH
*
pReadh
,
SBlock
*
pBlock
,
SBlockInfo
*
pBlockInfo
);
int
tsdbLoadBlockDataCols
(
SReadH
*
pReadh
,
SBlock
*
pBlock
,
SBlockInfo
*
pBlkInfo
,
const
int16_t
*
colIds
,
int
numOfColsIds
);
int
tsdbLoadBlockStatis
(
SReadH
*
pReadh
,
SBlock
*
pBlock
);
int
tsdbEncodeSBlockIdx
(
void
**
buf
,
SBlockIdx
*
pIdx
);
void
*
tsdbDecodeSBlockIdx
(
void
*
buf
,
SBlockIdx
*
pIdx
);
void
tsdbGetBlockStatis
(
SReadH
*
pReadh
,
SDataStatis
*
pStatis
,
int
numOfCols
,
SBlock
*
pBlock
);
static
FORCE_INLINE
int
tsdbMakeRoom
(
void
**
ppBuf
,
size_t
size
)
{
void
*
pBuf
=
*
ppBuf
;
size_t
tsize
=
taosTSizeof
(
pBuf
);
if
(
tsize
<
size
)
{
if
(
tsize
==
0
)
tsize
=
1024
;
while
(
tsize
<
size
)
{
tsize
*=
2
;
}
int64_t nwrite = taosWriteFile(pMFile->fd, buf, nbyte);
*
ppBuf
=
taosTRealloc
(
pBuf
,
tsize
);
if (nwrite < nbyte) {
if
(
*
ppBuf
==
NULL
)
{
terrno = TAOS_SYSTEM_ERROR(errno);
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return -1;
return
-
1
;
}
}
}
return nwrite;
return
0
;
}
// tsdbMemory
static
FORCE_INLINE
void
*
taosTMalloc
(
size_t
size
)
{
if
(
size
<=
0
)
return
NULL
;
void
*
ret
=
taosMemoryMalloc
(
size
+
sizeof
(
size_t
));
if
(
ret
==
NULL
)
return
NULL
;
*
(
size_t
*
)
ret
=
size
;
return
(
void
*
)((
char
*
)
ret
+
sizeof
(
size_t
));
}
}
static FORCE_INLINE void tsdbUpdateMFileMagic(SMFile* pMFile, void* pCksum) {
static
FORCE_INLINE
void
*
taosTCalloc
(
size_t
nmemb
,
size_t
size
)
{
pMFile->info.magic = taosCalcChecksum(pMFile->info.magic, (uint8_t*)(pCksum), sizeof(TSCKSUM));
size_t
tsize
=
nmemb
*
size
;
void
*
ret
=
taosTMalloc
(
tsize
);
if
(
ret
==
NULL
)
return
NULL
;
taosTMemset
(
ret
,
0
);
return
ret
;
}
}
static FORCE_INLINE int tsdbAppendMFile(SMFile* pMFile, void* buf, int64_t nbyte, int64_t* offset) {
static
FORCE_INLINE
size_t
taosTSizeof
(
void
*
ptr
)
{
return
(
ptr
)
?
(
*
(
size_t
*
)((
char
*
)
ptr
-
sizeof
(
size_t
)))
:
0
;
}
ASSERT(TSDB_FILE_OPENED(pMFile));
int64_t toffset;
static
FORCE_INLINE
void
taosTMemset
(
void
*
ptr
,
int
c
)
{
memset
(
ptr
,
c
,
taosTSizeof
(
ptr
));
}
if ((toffset = tsdbSeekMFile(pMFile, 0, SEEK_END)) < 0) {
static
FORCE_INLINE
void
*
taosTRealloc
(
void
*
ptr
,
size_t
size
)
{
return -1;
if
(
ptr
==
NULL
)
return
taosTMalloc
(
size
);
if
(
size
<=
taosTSizeof
(
ptr
))
return
ptr
;
void
*
tptr
=
(
void
*
)((
char
*
)
ptr
-
sizeof
(
size_t
));
size_t
tsize
=
size
+
sizeof
(
size_t
);
void
*
tptr1
=
taosMemoryRealloc
(
tptr
,
tsize
);
if
(
tptr1
==
NULL
)
return
NULL
;
tptr
=
tptr1
;
*
(
size_t
*
)
tptr
=
size
;
return
(
void
*
)((
char
*
)
tptr
+
sizeof
(
size_t
));
}
static
FORCE_INLINE
void
*
taosTZfree
(
void
*
ptr
)
{
if
(
ptr
)
{
taosMemoryFree
((
void
*
)((
char
*
)
ptr
-
sizeof
(
size_t
)));
}
}
return
NULL
;
}
ASSERT(pMFile->info.size == toffset);
// tsdbCommit
if (offset) {
typedef
struct
{
*offset = toffset;
uint64_t
uid
;
int64_t
offset
;
int64_t
size
;
}
SKVRecord
;
void
tsdbGetRtnSnap
(
STsdb
*
pRepo
,
SRtn
*
pRtn
);
static
FORCE_INLINE
int
TSDB_KEY_FID
(
TSKEY
key
,
int32_t
days
,
int8_t
precision
)
{
if
(
key
<
0
)
{
return
(
int
)((
key
+
1
)
/
tsTickPerDay
[
precision
]
/
days
-
1
);
}
else
{
return
(
int
)((
key
/
tsTickPerDay
[
precision
]
/
days
));
}
}
}
if (tsdbWriteMFile(pMFile, buf, nbyte) < 0) {
static
FORCE_INLINE
int
tsdbGetFidLevel
(
int
fid
,
SRtn
*
pRtn
)
{
if
(
fid
>=
pRtn
->
maxFid
)
{
return
0
;
}
else
if
(
fid
>=
pRtn
->
midFid
)
{
return
1
;
}
else
if
(
fid
>=
pRtn
->
minFid
)
{
return
2
;
}
else
{
return
-
1
;
return
-
1
;
}
}
}
pMFile->info.size += nbyte;
// tsdbDBDef
// typedef struct SDBFile SDBFile;
// typedef DB_ENV* TDBEnv;
return (int)nbyte;
// struct SDBFile {
}
// int32_t fid;
// DB* pDB;
// char* path;
// };
static FORCE_INLINE int tsdbRemoveMFile(SMFile* pMFile) { return tfsremove(TSDB_FILE_F(pMFile)); }
// int32_t tsdbOpenDBF(TDBEnv pEnv, SDBFile* pDBF);
// void tsdbCloseDBF(SDBFile* pDBF);
// int32_t tsdbOpenBDBEnv(DB_ENV** ppEnv, const char* path);
// void tsdbCloseBDBEnv(DB_ENV* pEnv);
// int32_t tsdbSaveSmaToDB(SDBFile* pDBF, void* key, uint32_t keySize, void* data, uint32_t dataSize);
// void* tsdbGetSmaDataByKey(SDBFile* pDBF, void* key, uint32_t keySize, uint32_t* valueSize);
static FORCE_INLINE int64_t tsdbReadMFile(SMFile* pMFile, void* buf, int64_t nbyte) {
// tsdbFile
ASSERT(TSDB_FILE_OPENED(pMFile));
#define TSDB_FILE_HEAD_SIZE 512
#define TSDB_FILE_DELIMITER 0xF00AFA0F
#define TSDB_FILE_INIT_MAGIC 0xFFFFFFFF
#define TSDB_IVLD_FID INT_MIN
#define TSDB_FILE_STATE_OK 0
#define TSDB_FILE_STATE_BAD 1
int64_t nread = taosReadFile(pMFile->fd, buf, nbyte);
#define TSDB_FILE_INFO(tf) (&((tf)->info))
if (nread < 0) {
#define TSDB_FILE_F(tf) (&((tf)->f))
terrno = TAOS_SYSTEM_ERROR(errno);
#define TSDB_FILE_PFILE(tf) ((tf)->pFile)
return -1;
#define TSDB_FILE_FULL_NAME(tf) (TSDB_FILE_F(tf)->aname)
}
#define TSDB_FILE_OPENED(tf) (TSDB_FILE_PFILE(tf) != NULL)
#define TSDB_FILE_CLOSED(tf) (!TSDB_FILE_OPENED(tf))
#define TSDB_FILE_SET_CLOSED(f) (TSDB_FILE_PFILE(f) = NULL)
#define TSDB_FILE_LEVEL(tf) (TSDB_FILE_F(tf)->did.level)
#define TSDB_FILE_ID(tf) (TSDB_FILE_F(tf)->did.id)
#define TSDB_FILE_DID(tf) (TSDB_FILE_F(tf)->did)
#define TSDB_FILE_REL_NAME(tf) (TSDB_FILE_F(tf)->rname)
#define TSDB_FILE_ABS_NAME(tf) (TSDB_FILE_F(tf)->aname)
#define TSDB_FILE_FSYNC(tf) taosFsyncFile(TSDB_FILE_PFILE(tf))
#define TSDB_FILE_STATE(tf) ((tf)->state)
#define TSDB_FILE_SET_STATE(tf, s) ((tf)->state = (s))
#define TSDB_FILE_IS_OK(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_OK)
#define TSDB_FILE_IS_BAD(tf) (TSDB_FILE_STATE(tf) == TSDB_FILE_STATE_BAD)
return nread;
typedef
int32_t
TSDB_FILE_T
;
}
typedef
enum
{
TSDB_FS_VER_0
=
0
,
TSDB_FS_VER_MAX
,
}
ETsdbFsVer
;
#endif
#define TSDB_LATEST_FVER TSDB_FS_VER_0 // latest version for DFile
#define TSDB_LATEST_SFS_VER TSDB_FS_VER_0 // latest version for 'current' file
// =============== S
DFile
static
FORCE_INLINE
uint32_t
tsdbGetDFSVersion
(
TSDB_FILE_T
fType
)
{
// latest version for
DFile
typedef
struct
{
switch
(
fType
)
{
uint32_t
magic
;
case
TSDB_FILE_HEAD
:
// .head
uint32_t
fver
;
case
TSDB_FILE_DATA
:
// .data
uint32_t
len
;
case
TSDB_FILE_LAST
:
// .last
uint32_t
totalBlocks
;
case
TSDB_FILE_SMAD
:
// .smad(Block-wise SMA)
uint32_t
totalSubBlocks
;
case
TSDB_FILE_SMAL
:
// .smal(Block-wise SMA)
uint32_t
offset
;
default:
uint64_t
size
;
return
TSDB_LATEST_FVER
;
uint64_t
tombSize
;
}
}
SDFInfo
;
}
typedef
struct
{
SDFInfo
info
;
STfsFile
f
;
TdFilePtr
pFile
;
uint8_t
state
;
}
SDFile
;
void
tsdbInitDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
,
SDiskID
did
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
);
void
tsdbInitDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
,
SDiskID
did
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
);
void
tsdbInitDFileEx
(
SDFile
*
pDFile
,
SDFile
*
pODFile
);
void
tsdbInitDFileEx
(
SDFile
*
pDFile
,
SDFile
*
pODFile
);
...
@@ -327,13 +681,6 @@ static FORCE_INLINE int tsdbCopyDFile(SDFile* pSrc, SDFile* pDest) {
...
@@ -327,13 +681,6 @@ static FORCE_INLINE int tsdbCopyDFile(SDFile* pSrc, SDFile* pDest) {
}
}
// =============== SDFileSet
// =============== SDFileSet
typedef
struct
{
int
fid
;
int8_t
state
;
// -128~127
uint8_t
ver
;
// 0~255, DFileSet version
uint16_t
reserve
;
SDFile
files
[
TSDB_FILE_MAX
];
}
SDFileSet
;
typedef
struct
{
typedef
struct
{
int
fid
;
int
fid
;
...
@@ -428,8 +775,162 @@ static FORCE_INLINE bool tsdbFSetIsOk(SDFileSet* pSet) {
...
@@ -428,8 +775,162 @@ static FORCE_INLINE bool tsdbFSetIsOk(SDFileSet* pSet) {
return
true
;
return
true
;
}
}
// tsdbFS
// ================== TSDB global config
extern
bool
tsdbForceKeepFile
;
// ================== CURRENT file header info
typedef
struct
{
uint32_t
version
;
// Current file system version (relating to code)
uint32_t
len
;
// Encode content length (including checksum)
}
SFSHeader
;
// ================== TSDB File System Meta
/**
* @brief Directory structure of .tsma data files.
*
* /vnode2/tsdb $ tree tsma/
* tsma/
* ├── v2f100.index_name_1
* ├── v2f101.index_name_1
* ├── v2f102.index_name_1
* ├── v2f1900.index_name_3
* ├── v2f1901.index_name_3
* ├── v2f1902.index_name_3
* ├── v2f200.index_name_2
* ├── v2f201.index_name_2
* └── v2f202.index_name_2
*
* 0 directories, 9 files
*/
#define FS_CURRENT_STATUS(pfs) ((pfs)->cstatus)
#define FS_NEW_STATUS(pfs) ((pfs)->nstatus)
#define FS_IN_TXN(pfs) (pfs)->intxn
#define FS_VERSION(pfs) ((pfs)->cstatus->meta.version)
#define FS_TXN_VERSION(pfs) ((pfs)->nstatus->meta.version)
typedef
struct
{
int
direction
;
uint64_t
version
;
// current FS version
STsdbFS
*
pfs
;
int
index
;
// used to position next fset when version the same
int
fid
;
// used to seek when version is changed
SDFileSet
*
pSet
;
}
SFSIter
;
#define TSDB_FS_ITER_FORWARD TSDB_ORDER_ASC
#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC
STsdbFS
*
tsdbNewFS
(
const
STsdbCfg
*
pCfg
);
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
);
int
tsdbOpenFS
(
STsdb
*
pRepo
);
void
tsdbCloseFS
(
STsdb
*
pRepo
);
void
tsdbStartFSTxn
(
STsdb
*
pRepo
,
int64_t
pointsAdd
,
int64_t
storageAdd
);
int
tsdbEndFSTxn
(
STsdb
*
pRepo
);
int
tsdbEndFSTxnWithError
(
STsdbFS
*
pfs
);
void
tsdbUpdateFSTxnMeta
(
STsdbFS
*
pfs
,
STsdbFSMeta
*
pMeta
);
// void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile);
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
);
void
tsdbFSIterInit
(
SFSIter
*
pIter
,
STsdbFS
*
pfs
,
int
direction
);
void
tsdbFSIterSeek
(
SFSIter
*
pIter
,
int
fid
);
SDFileSet
*
tsdbFSIterNext
(
SFSIter
*
pIter
);
int
tsdbLoadMetaCache
(
STsdb
*
pRepo
,
bool
recoverMeta
);
static
FORCE_INLINE
int
tsdbRLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockRdlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbWLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockWrlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbUnLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockUnlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
// tsdbSma
// #define TSDB_SMA_TEST // remove after test finished
// struct SSmaEnv {
// TdThreadRwlock lock;
// SDiskID did;
// TDBEnv dbEnv; // TODO: If it's better to put it in smaIndex level?
// char *path; // relative path
// SSmaStat *pStat;
// };
// #define SMA_ENV_LOCK(env) ((env)->lock)
// #define SMA_ENV_DID(env) ((env)->did)
// #define SMA_ENV_ENV(env) ((env)->dbEnv)
// #define SMA_ENV_PATH(env) ((env)->path)
// #define SMA_ENV_STAT(env) ((env)->pStat)
// #define SMA_ENV_STAT_ITEMS(env) ((env)->pStat->smaStatItems)
// void tsdbDestroySmaEnv(SSmaEnv *pSmaEnv);
// void *tsdbFreeSmaEnv(SSmaEnv *pSmaEnv);
// #if 0
// int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result);
// int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
// #endif
// // internal func
// static FORCE_INLINE int32_t tsdbEncodeTSmaKey(int64_t groupId, TSKEY tsKey, void **pData) {
// int32_t len = 0;
// len += taosEncodeFixedI64(pData, tsKey);
// len += taosEncodeFixedI64(pData, groupId);
// return len;
// }
// static FORCE_INLINE int32_t tsdbRLockSma(SSmaEnv *pEnv) {
// int code = taosThreadRwlockRdlock(&(pEnv->lock));
// if (code != 0) {
// terrno = TAOS_SYSTEM_ERROR(code);
// return -1;
// }
// return 0;
// }
// static FORCE_INLINE int32_t tsdbWLockSma(SSmaEnv *pEnv) {
// int code = taosThreadRwlockWrlock(&(pEnv->lock));
// if (code != 0) {
// terrno = TAOS_SYSTEM_ERROR(code);
// return -1;
// }
// return 0;
// }
// static FORCE_INLINE int32_t tsdbUnLockSma(SSmaEnv *pEnv) {
// int code = taosThreadRwlockUnlock(&(pEnv->lock));
// if (code != 0) {
// terrno = TAOS_SYSTEM_ERROR(code);
// return -1;
// }
// return 0;
// }
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif
/* _TS_TSDB_FILE_H_ */
\ No newline at end of file
#endif
/*_TD_VNODE_TSDB_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/tsdbCommit.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_COMMIT_H_
#define _TD_TSDB_COMMIT_H_
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
int
minFid
;
int
midFid
;
int
maxFid
;
TSKEY
minKey
;
}
SRtn
;
typedef
struct
{
uint64_t
uid
;
int64_t
offset
;
int64_t
size
;
}
SKVRecord
;
void
tsdbGetRtnSnap
(
STsdb
*
pRepo
,
SRtn
*
pRtn
);
static
FORCE_INLINE
int
TSDB_KEY_FID
(
TSKEY
key
,
int32_t
days
,
int8_t
precision
)
{
if
(
key
<
0
)
{
return
(
int
)((
key
+
1
)
/
tsTickPerDay
[
precision
]
/
days
-
1
);
}
else
{
return
(
int
)((
key
/
tsTickPerDay
[
precision
]
/
days
));
}
}
static
FORCE_INLINE
int
tsdbGetFidLevel
(
int
fid
,
SRtn
*
pRtn
)
{
if
(
fid
>=
pRtn
->
maxFid
)
{
return
0
;
}
else
if
(
fid
>=
pRtn
->
midFid
)
{
return
1
;
}
else
if
(
fid
>=
pRtn
->
minFid
)
{
return
2
;
}
else
{
return
-
1
;
}
}
#if 0
#define TSDB_DEFAULT_BLOCK_ROWS(maxRows) ((maxRows)*4 / 5)
int tsdbEncodeKVRecord(void **buf, SKVRecord *pRecord);
void *tsdbDecodeKVRecord(void *buf, SKVRecord *pRecord);
void *tsdbCommitData(STsdbRepo *pRepo);
int tsdbApplyRtnOnFSet(STsdbRepo *pRepo, SDFileSet *pSet, SRtn *pRtn);
int tsdbWriteBlockInfoImpl(SDFile *pHeadf, STable *pTable, SArray *pSupA, SArray *pSubA, void **ppBuf, SBlockIdx *pIdx);
int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf);
int tsdbWriteBlockImpl(STsdbRepo *pRepo, STable *pTable, SDFile *pDFile, SDataCols *pDataCols, SBlock *pBlock,
bool isLast, bool isSuper, void **ppBuf, void **ppCBuf);
int tsdbApplyRtn(STsdbRepo *pRepo);
#endif
#ifdef __cplusplus
}
#endif
#endif
/* _TD_TSDB_COMMIT_H_ */
source/dnode/vnode/src/inc/tsdbCompact.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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/>.
*/
#if 0
#ifndef _TD_TSDB_COMPACT_H_
#define _TD_TSDB_COMPACT_H_
#ifdef __cplusplus
extern "C" {
#endif
void *tsdbCompactImpl(STsdbRepo *pRepo);
#ifdef __cplusplus
}
#endif
#endif /* _TD_TSDB_COMPACT_H_ */
#endif
\ No newline at end of file
source/dnode/vnode/src/inc/tsdbDBDef.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_DB_DEF_H_
#define _TD_TSDB_DB_DEF_H_
#include "db.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SDBFile
SDBFile
;
typedef
DB_ENV
*
TDBEnv
;
struct
SDBFile
{
int32_t
fid
;
DB
*
pDB
;
char
*
path
;
};
int32_t
tsdbOpenDBF
(
TDBEnv
pEnv
,
SDBFile
*
pDBF
);
void
tsdbCloseDBF
(
SDBFile
*
pDBF
);
int32_t
tsdbOpenBDBEnv
(
DB_ENV
**
ppEnv
,
const
char
*
path
);
void
tsdbCloseBDBEnv
(
DB_ENV
*
pEnv
);
int32_t
tsdbSaveSmaToDB
(
SDBFile
*
pDBF
,
void
*
key
,
uint32_t
keySize
,
void
*
data
,
uint32_t
dataSize
);
void
*
tsdbGetSmaDataByKey
(
SDBFile
*
pDBF
,
void
*
key
,
uint32_t
keySize
,
uint32_t
*
valueSize
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_DB_DEF_H_*/
source/dnode/vnode/src/inc/tsdbDef.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_DEF_H_
#define _TD_TSDB_DEF_H_
#include "tsdbDBDef.h"
#include "tmallocator.h"
#include "meta.h"
#include "tcompression.h"
#include "tglobal.h"
#include "thash.h"
#include "tlist.h"
#include "tmsg.h"
#include "tskiplist.h"
#include "ttime.h"
#include "tsdb.h"
#include "tsdbCommit.h"
#include "tsdbFS.h"
#include "tsdbFile.h"
#include "tsdbLog.h"
#include "tsdbMemTable.h"
#include "tsdbMemory.h"
#include "tsdbOptions.h"
#include "tsdbReadImpl.h"
#include "tsdbSma.h"
#ifdef __cplusplus
extern
"C"
{
#endif
struct
STsdb
{
int32_t
vgId
;
bool
repoLocked
;
TdThreadMutex
mutex
;
char
*
path
;
STsdbCfg
config
;
STsdbMemTable
*
mem
;
STsdbMemTable
*
imem
;
SRtn
rtn
;
SMemAllocatorFactory
*
pmaf
;
STsdbFS
*
fs
;
SMeta
*
pMeta
;
STfs
*
pTfs
;
SSmaEnvs
smaEnvs
;
};
#define REPO_ID(r) ((r)->vgId)
#define REPO_CFG(r) (&(r)->config)
#define REPO_FS(r) ((r)->fs)
#define REPO_META(r) ((r)->pMeta)
#define REPO_TFS(r) ((r)->pTfs)
#define IS_REPO_LOCKED(r) ((r)->repoLocked)
#define REPO_TSMA_NUM(r) ((r)->smaEnvs.nTSma)
#define REPO_RSMA_NUM(r) ((r)->smaEnvs.nRSma)
#define REPO_TSMA_ENV(r) ((r)->smaEnvs.pTSmaEnv)
#define REPO_RSMA_ENV(r) ((r)->smaEnvs.pRSmaEnv)
int
tsdbLockRepo
(
STsdb
*
pTsdb
);
int
tsdbUnlockRepo
(
STsdb
*
pTsdb
);
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STable
*
pTable
,
bool
lock
,
bool
copy
,
int32_t
version
)
{
return
pTable
->
pSchema
;
}
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_DEF_H_*/
source/dnode/vnode/src/inc/tsdbFS.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_FS_H_
#define _TD_TSDB_FS_H_
#include "tsdbFile.h"
#ifdef __cplusplus
extern
"C"
{
#endif
// ================== TSDB global config
extern
bool
tsdbForceKeepFile
;
// ================== CURRENT file header info
typedef
struct
{
uint32_t
version
;
// Current file system version (relating to code)
uint32_t
len
;
// Encode content length (including checksum)
}
SFSHeader
;
// ================== TSDB File System Meta
typedef
struct
{
uint32_t
version
;
// Commit version from 0 to increase
int64_t
totalPoints
;
// total points
int64_t
totalStorage
;
// Uncompressed total storage
}
STsdbFSMeta
;
// ==================
typedef
struct
{
STsdbFSMeta
meta
;
// FS meta
SArray
*
df
;
// data file array
SArray
*
sf
;
// sma data file array v2f1900.index_name_1
}
SFSStatus
;
/**
* @brief Directory structure of .tsma data files.
*
* /vnode2/tsdb $ tree tsma/
* tsma/
* ├── v2f100.index_name_1
* ├── v2f101.index_name_1
* ├── v2f102.index_name_1
* ├── v2f1900.index_name_3
* ├── v2f1901.index_name_3
* ├── v2f1902.index_name_3
* ├── v2f200.index_name_2
* ├── v2f201.index_name_2
* └── v2f202.index_name_2
*
* 0 directories, 9 files
*/
typedef
struct
{
TdThreadRwlock
lock
;
SFSStatus
*
cstatus
;
// current status
SHashObj
*
metaCache
;
// meta cache
SHashObj
*
metaCacheComp
;
// meta cache for compact
bool
intxn
;
SFSStatus
*
nstatus
;
// new status
}
STsdbFS
;
#define FS_CURRENT_STATUS(pfs) ((pfs)->cstatus)
#define FS_NEW_STATUS(pfs) ((pfs)->nstatus)
#define FS_IN_TXN(pfs) (pfs)->intxn
#define FS_VERSION(pfs) ((pfs)->cstatus->meta.version)
#define FS_TXN_VERSION(pfs) ((pfs)->nstatus->meta.version)
typedef
struct
{
int
direction
;
uint64_t
version
;
// current FS version
STsdbFS
*
pfs
;
int
index
;
// used to position next fset when version the same
int
fid
;
// used to seek when version is changed
SDFileSet
*
pSet
;
}
SFSIter
;
#define TSDB_FS_ITER_FORWARD TSDB_ORDER_ASC
#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC
STsdbFS
*
tsdbNewFS
(
const
STsdbCfg
*
pCfg
);
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
);
int
tsdbOpenFS
(
STsdb
*
pRepo
);
void
tsdbCloseFS
(
STsdb
*
pRepo
);
void
tsdbStartFSTxn
(
STsdb
*
pRepo
,
int64_t
pointsAdd
,
int64_t
storageAdd
);
int
tsdbEndFSTxn
(
STsdb
*
pRepo
);
int
tsdbEndFSTxnWithError
(
STsdbFS
*
pfs
);
void
tsdbUpdateFSTxnMeta
(
STsdbFS
*
pfs
,
STsdbFSMeta
*
pMeta
);
// void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile);
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
);
void
tsdbFSIterInit
(
SFSIter
*
pIter
,
STsdbFS
*
pfs
,
int
direction
);
void
tsdbFSIterSeek
(
SFSIter
*
pIter
,
int
fid
);
SDFileSet
*
tsdbFSIterNext
(
SFSIter
*
pIter
);
int
tsdbLoadMetaCache
(
STsdb
*
pRepo
,
bool
recoverMeta
);
static
FORCE_INLINE
int
tsdbRLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockRdlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbWLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockWrlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbUnLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockUnlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
#ifdef __cplusplus
}
#endif
#endif
/* _TD_TSDB_FS_H_ */
source/dnode/vnode/src/inc/tsdbLog.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_LOG_H_
#define _TD_TSDB_LOG_H_
#include "tlog.h"
#ifdef __cplusplus
extern
"C"
{
#endif
extern
int32_t
tsdbDebugFlag
;
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TSDB FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TSDB ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TSDB WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TSDB ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSDB ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TSDB ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#ifdef __cplusplus
}
#endif
#endif
/* _TD_TSDB_LOG_H_ */
\ No newline at end of file
source/dnode/vnode/src/inc/tsdbMemTable.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_MEM_TABLE_H_
#define _TD_TSDB_MEM_TABLE_H_
#include "tsdb.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
{
int
rowsInserted
;
int
rowsUpdated
;
int
rowsDeleteSucceed
;
int
rowsDeleteFailed
;
int
nOperations
;
TSKEY
keyFirst
;
TSKEY
keyLast
;
}
SMergeInfo
;
typedef
struct
STbData
{
tb_uid_t
uid
;
TSKEY
keyMin
;
TSKEY
keyMax
;
int64_t
nrows
;
SSkipList
*
pData
;
}
STbData
;
typedef
struct
STsdbMemTable
{
T_REF_DECLARE
()
SRWLatch
latch
;
TSKEY
keyMin
;
TSKEY
keyMax
;
uint64_t
nRow
;
SMemAllocator
*
pMA
;
// Container
SSkipList
*
pSlIdx
;
// SSkiplist<STbData>
SHashObj
*
pHashIdx
;
}
STsdbMemTable
;
STsdbMemTable
*
tsdbNewMemTable
(
STsdb
*
pTsdb
);
void
tsdbFreeMemTable
(
STsdb
*
pTsdb
,
STsdbMemTable
*
pMemTable
);
int
tsdbMemTableInsert
(
STsdb
*
pTsdb
,
STsdbMemTable
*
pMemTable
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbLoadDataFromCache
(
STable
*
pTable
,
SSkipListIterator
*
pIter
,
TSKEY
maxKey
,
int
maxRowsToRead
,
SDataCols
*
pCols
,
TKEY
*
filterKeys
,
int
nFilterKeys
,
bool
keepDup
,
SMergeInfo
*
pMergeInfo
);
static
FORCE_INLINE
STSRow
*
tsdbNextIterRow
(
SSkipListIterator
*
pIter
)
{
if
(
pIter
==
NULL
)
return
NULL
;
SSkipListNode
*
node
=
tSkipListIterGet
(
pIter
);
if
(
node
==
NULL
)
return
NULL
;
return
(
STSRow
*
)
SL_GET_NODE_DATA
(
node
);
}
static
FORCE_INLINE
TSKEY
tsdbNextIterKey
(
SSkipListIterator
*
pIter
)
{
STSRow
*
row
=
tsdbNextIterRow
(
pIter
);
if
(
row
==
NULL
)
return
TSDB_DATA_TIMESTAMP_NULL
;
return
TD_ROW_KEY
(
row
);
}
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_MEM_TABLE_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/tsdbMemory.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_MEMORY_H_
#define _TD_TSDB_MEMORY_H_
#ifdef __cplusplus
extern
"C"
{
#endif
static
void
*
taosTMalloc
(
size_t
size
);
static
void
*
taosTCalloc
(
size_t
nmemb
,
size_t
size
);
static
void
*
taosTRealloc
(
void
*
ptr
,
size_t
size
);
static
void
*
taosTZfree
(
void
*
ptr
);
static
size_t
taosTSizeof
(
void
*
ptr
);
static
void
taosTMemset
(
void
*
ptr
,
int
c
);
static
FORCE_INLINE
void
*
taosTMalloc
(
size_t
size
)
{
if
(
size
<=
0
)
return
NULL
;
void
*
ret
=
taosMemoryMalloc
(
size
+
sizeof
(
size_t
));
if
(
ret
==
NULL
)
return
NULL
;
*
(
size_t
*
)
ret
=
size
;
return
(
void
*
)((
char
*
)
ret
+
sizeof
(
size_t
));
}
static
FORCE_INLINE
void
*
taosTCalloc
(
size_t
nmemb
,
size_t
size
)
{
size_t
tsize
=
nmemb
*
size
;
void
*
ret
=
taosTMalloc
(
tsize
);
if
(
ret
==
NULL
)
return
NULL
;
taosTMemset
(
ret
,
0
);
return
ret
;
}
static
FORCE_INLINE
size_t
taosTSizeof
(
void
*
ptr
)
{
return
(
ptr
)
?
(
*
(
size_t
*
)((
char
*
)
ptr
-
sizeof
(
size_t
)))
:
0
;
}
static
FORCE_INLINE
void
taosTMemset
(
void
*
ptr
,
int
c
)
{
memset
(
ptr
,
c
,
taosTSizeof
(
ptr
));
}
static
FORCE_INLINE
void
*
taosTRealloc
(
void
*
ptr
,
size_t
size
)
{
if
(
ptr
==
NULL
)
return
taosTMalloc
(
size
);
if
(
size
<=
taosTSizeof
(
ptr
))
return
ptr
;
void
*
tptr
=
(
void
*
)((
char
*
)
ptr
-
sizeof
(
size_t
));
size_t
tsize
=
size
+
sizeof
(
size_t
);
void
*
tptr1
=
taosMemoryRealloc
(
tptr
,
tsize
);
if
(
tptr1
==
NULL
)
return
NULL
;
tptr
=
tptr1
;
*
(
size_t
*
)
tptr
=
size
;
return
(
void
*
)((
char
*
)
tptr
+
sizeof
(
size_t
));
}
static
FORCE_INLINE
void
*
taosTZfree
(
void
*
ptr
)
{
if
(
ptr
)
{
taosMemoryFree
((
void
*
)((
char
*
)
ptr
-
sizeof
(
size_t
)));
}
return
NULL
;
}
#ifdef __cplusplus
}
#endif
#endif
/* _TD_TSDB_MEMORY_H_ */
\ No newline at end of file
source/dnode/vnode/src/inc/tsdbOptions.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_OPTIONS_H_
#define _TD_TSDB_OPTIONS_H_
#ifdef __cplusplus
extern
"C"
{
#endif
extern
const
STsdbCfg
defautlTsdbOptions
;
int
tsdbValidateOptions
(
const
STsdbCfg
*
);
void
tsdbOptionsCopy
(
STsdbCfg
*
pDest
,
const
STsdbCfg
*
pSrc
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_OPTIONS_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/tsdbReadImpl.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_READ_IMPL_H_
#define _TD_TSDB_READ_IMPL_H_
#include "os.h"
#include "tcommon.h"
#include "tfs.h"
#include "tsdb.h"
#include "tsdbFile.h"
#include "tsdbMemory.h"
#include "tskiplist.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SReadH
SReadH
;
typedef
struct
{
uint32_t
len
;
uint32_t
offset
;
uint32_t
hasLast
:
2
;
uint32_t
numOfBlocks
:
30
;
uint64_t
uid
;
TSKEY
maxKey
;
}
SBlockIdx
;
#ifdef TD_REFACTOR_3
typedef
struct
{
int64_t
last
:
1
;
int64_t
offset
:
63
;
int32_t
algorithm
:
8
;
int32_t
numOfRows
:
24
;
int32_t
len
;
int32_t
keyLen
;
// key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols
int16_t
numOfSubBlocks
;
int16_t
numOfCols
;
// not including timestamp column
TSKEY
keyFirst
;
TSKEY
keyLast
;
}
SBlock
;
#else
typedef
enum
{
TSDB_SBLK_VER_0
=
0
,
TSDB_SBLK_VER_MAX
,
}
ESBlockVer
;
#define SBlockVerLatest TSDB_SBLK_VER_0
typedef
struct
{
uint8_t
last
:
1
;
uint8_t
blkVer
:
7
;
uint8_t
numOfSubBlocks
;
col_id_t
numOfCols
;
// not including timestamp column
uint32_t
len
;
// data block length
uint32_t
keyLen
:
20
;
// key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols
uint32_t
algorithm
:
4
;
uint32_t
reserve
:
8
;
col_id_t
numOfBSma
;
uint16_t
numOfRows
;
int64_t
offset
;
uint64_t
aggrStat
:
1
;
uint64_t
aggrOffset
:
63
;
TSKEY
keyFirst
;
TSKEY
keyLast
;
}
SBlockV0
;
#define SBlock SBlockV0 // latest SBlock definition
#endif
typedef
struct
{
int32_t
delimiter
;
// For recovery usage
int32_t
tid
;
uint64_t
uid
;
SBlock
blocks
[];
}
SBlockInfo
;
#ifdef TD_REFACTOR_3
typedef
struct
{
int16_t
colId
;
uint16_t
bitmap
:
1
;
// 0: has bitmap if has NULL/NORM rows, 1: no bitmap if all rows are NORM
uint16_t
reserve
:
15
;
int32_t
len
;
uint32_t
type
:
8
;
uint32_t
offset
:
24
;
int64_t
sum
;
int64_t
max
;
int64_t
min
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
uint8_t
offsetH
;
char
padding
[
1
];
}
SBlockCol
;
#else
typedef
struct
{
int16_t
colId
;
uint16_t
type
:
6
;
uint16_t
blen
:
10
;
// bitmap length(TODO: full UT for the bitmap compress of various data input)
uint32_t
bitmap
:
1
;
// 0: has bitmap if has NULL/NORM rows, 1: no bitmap if all rows are NORM
uint32_t
len
:
31
;
// data length + bitmap length
uint32_t
offset
;
}
SBlockColV0
;
#define SBlockCol SBlockColV0 // latest SBlockCol definition
typedef
struct
{
int16_t
colId
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
int64_t
sum
;
int64_t
max
;
int64_t
min
;
}
SAggrBlkColV0
;
#define SAggrBlkCol SAggrBlkColV0 // latest SAggrBlkCol definition
#endif
// Code here just for back-ward compatibility
static
FORCE_INLINE
void
tsdbSetBlockColOffset
(
SBlockCol
*
pBlockCol
,
uint32_t
offset
)
{
#ifdef TD_REFACTOR_3
pBlockCol
->
offset
=
offset
&
((((
uint32_t
)
1
)
<<
24
)
-
1
);
pBlockCol
->
offsetH
=
(
uint8_t
)(
offset
>>
24
);
#else
pBlockCol
->
offset
=
offset
;
#endif
}
static
FORCE_INLINE
uint32_t
tsdbGetBlockColOffset
(
SBlockCol
*
pBlockCol
)
{
#ifdef TD_REFACTOR_3
uint32_t
offset1
=
pBlockCol
->
offset
;
uint32_t
offset2
=
pBlockCol
->
offsetH
;
return
(
offset1
|
(
offset2
<<
24
));
#else
return
pBlockCol
->
offset
;
#endif
}
typedef
struct
{
int32_t
delimiter
;
// For recovery usage
int32_t
numOfCols
;
// For recovery usage
uint64_t
uid
;
// For recovery usage
SBlockCol
cols
[];
}
SBlockData
;
typedef
void
SAggrBlkData
;
// SBlockCol cols[];
struct
SReadH
{
STsdb
*
pRepo
;
SDFileSet
rSet
;
// FSET to read
SArray
*
aBlkIdx
;
// SBlockIdx array
STable
*
pTable
;
// table to read
SBlockIdx
*
pBlkIdx
;
// current reading table SBlockIdx
int
cidx
;
SBlockInfo
*
pBlkInfo
;
SBlockData
*
pBlkData
;
// Block info
SAggrBlkData
*
pAggrBlkData
;
// Aggregate Block info
SDataCols
*
pDCols
[
2
];
void
*
pBuf
;
// buffer
void
*
pCBuf
;
// compression buffer
void
*
pExBuf
;
// extra buffer
};
#define TSDB_READ_REPO(rh) ((rh)->pRepo)
#define TSDB_READ_REPO_ID(rh) REPO_ID(TSDB_READ_REPO(rh))
#define TSDB_READ_FSET(rh) (&((rh)->rSet))
#define TSDB_READ_TABLE(rh) ((rh)->pTable)
#define TSDB_READ_HEAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_HEAD)
#define TSDB_READ_DATA_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_DATA)
#define TSDB_READ_LAST_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_LAST)
#define TSDB_READ_SMAD_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_SMAD)
#define TSDB_READ_SMAL_FILE(rh) TSDB_DFILE_IN_SET(TSDB_READ_FSET(rh), TSDB_FILE_SMAL)
#define TSDB_READ_BUF(rh) ((rh)->pBuf)
#define TSDB_READ_COMP_BUF(rh) ((rh)->pCBuf)
#define TSDB_READ_EXBUF(rh) ((rh)->pExBuf)
#define TSDB_BLOCK_STATIS_SIZE(ncols, blkVer) \
(sizeof(SBlockData) + sizeof(SBlockColV##blkVer) * (ncols) + sizeof(TSCKSUM))
static
FORCE_INLINE
size_t
tsdbBlockStatisSize
(
int
nCols
,
uint32_t
blkVer
)
{
switch
(
blkVer
)
{
case
TSDB_SBLK_VER_0
:
default:
return
TSDB_BLOCK_STATIS_SIZE
(
nCols
,
0
);
}
}
#define TSDB_BLOCK_AGGR_SIZE(ncols, blkVer) (sizeof(SAggrBlkColV##blkVer) * (ncols) + sizeof(TSCKSUM))
static
FORCE_INLINE
size_t
tsdbBlockAggrSize
(
int
nCols
,
uint32_t
blkVer
)
{
switch
(
blkVer
)
{
case
TSDB_SBLK_VER_0
:
default:
return
TSDB_BLOCK_AGGR_SIZE
(
nCols
,
0
);
}
}
int
tsdbInitReadH
(
SReadH
*
pReadh
,
STsdb
*
pRepo
);
void
tsdbDestroyReadH
(
SReadH
*
pReadh
);
int
tsdbSetAndOpenReadFSet
(
SReadH
*
pReadh
,
SDFileSet
*
pSet
);
void
tsdbCloseAndUnsetFSet
(
SReadH
*
pReadh
);
int
tsdbLoadBlockIdx
(
SReadH
*
pReadh
);
int
tsdbSetReadTable
(
SReadH
*
pReadh
,
STable
*
pTable
);
int
tsdbLoadBlockInfo
(
SReadH
*
pReadh
,
void
*
pTarget
);
int
tsdbLoadBlockData
(
SReadH
*
pReadh
,
SBlock
*
pBlock
,
SBlockInfo
*
pBlockInfo
);
int
tsdbLoadBlockDataCols
(
SReadH
*
pReadh
,
SBlock
*
pBlock
,
SBlockInfo
*
pBlkInfo
,
const
int16_t
*
colIds
,
int
numOfColsIds
);
int
tsdbLoadBlockStatis
(
SReadH
*
pReadh
,
SBlock
*
pBlock
);
int
tsdbEncodeSBlockIdx
(
void
**
buf
,
SBlockIdx
*
pIdx
);
void
*
tsdbDecodeSBlockIdx
(
void
*
buf
,
SBlockIdx
*
pIdx
);
void
tsdbGetBlockStatis
(
SReadH
*
pReadh
,
SDataStatis
*
pStatis
,
int
numOfCols
,
SBlock
*
pBlock
);
static
FORCE_INLINE
int
tsdbMakeRoom
(
void
**
ppBuf
,
size_t
size
)
{
void
*
pBuf
=
*
ppBuf
;
size_t
tsize
=
taosTSizeof
(
pBuf
);
if
(
tsize
<
size
)
{
if
(
tsize
==
0
)
tsize
=
1024
;
while
(
tsize
<
size
)
{
tsize
*=
2
;
}
*
ppBuf
=
taosTRealloc
(
pBuf
,
tsize
);
if
(
*
ppBuf
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
return
-
1
;
}
}
return
0
;
}
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_READ_IMPL_H_*/
source/dnode/vnode/src/inc/tsdbSma.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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_TSDB_SMA_H_
#define _TD_TSDB_SMA_H_
#define TSDB_SMA_TEST // remove after test finished
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaEnv
SSmaEnv
;
typedef
struct
SSmaEnvs
SSmaEnvs
;
struct
SSmaEnv
{
TdThreadRwlock
lock
;
SDiskID
did
;
TDBEnv
dbEnv
;
// TODO: If it's better to put it in smaIndex level?
char
*
path
;
// relative path
SSmaStat
*
pStat
;
};
#define SMA_ENV_LOCK(env) ((env)->lock)
#define SMA_ENV_DID(env) ((env)->did)
#define SMA_ENV_ENV(env) ((env)->dbEnv)
#define SMA_ENV_PATH(env) ((env)->path)
#define SMA_ENV_STAT(env) ((env)->pStat)
#define SMA_ENV_STAT_ITEMS(env) ((env)->pStat->smaStatItems)
struct
SSmaEnvs
{
int16_t
nTSma
;
int16_t
nRSma
;
SSmaEnv
*
pTSmaEnv
;
SSmaEnv
*
pRSmaEnv
;
};
void
tsdbDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tsdbFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
#if 0
int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result);
int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
#endif
// internal func
static
FORCE_INLINE
int32_t
tsdbEncodeTSmaKey
(
int64_t
groupId
,
TSKEY
tsKey
,
void
**
pData
)
{
int32_t
len
=
0
;
len
+=
taosEncodeFixedI64
(
pData
,
tsKey
);
len
+=
taosEncodeFixedI64
(
pData
,
groupId
);
return
len
;
}
static
FORCE_INLINE
int32_t
tsdbRLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockRdlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int32_t
tsdbWLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockWrlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int32_t
tsdbUnLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
taosThreadRwlockUnlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
#endif
/* _TD_TSDB_SMA_H_ */
\ No newline at end of file
source/dnode/vnode/src/inc/vn
d
.h
→
source/dnode/vnode/src/inc/vn
odeInt
.h
浏览文件 @
a8f740bc
...
@@ -16,17 +16,23 @@
...
@@ -16,17 +16,23 @@
#ifndef _TD_VNODE_DEF_H_
#ifndef _TD_VNODE_DEF_H_
#define _TD_VNODE_DEF_H_
#define _TD_VNODE_DEF_H_
#include "
tmalloca
tor.h"
#include "
execu
tor.h"
// #include "sync
.h"
#include "tchecksum
.h"
#include "tcoding.h"
#include "tcoding.h"
#include "tcompression.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tfs.h"
#include "tfs.h"
#include "tglobal.h"
#include "tlist.h"
#include "tlist.h"
#include "tlockfree.h"
#include "tlockfree.h"
#include "tmacro.h"
#include "tmacro.h"
#include "tmallocator.h"
#include "tskiplist.h"
#include "ttime.h"
#include "ttimer.h"
#include "vnode.h"
#include "vnode.h"
#include "vnodeQuery.h"
#include "wal.h"
#include "wal.h"
#include "qworker.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -34,8 +40,9 @@ extern "C" {
...
@@ -34,8 +40,9 @@ extern "C" {
typedef
struct
STQ
STQ
;
typedef
struct
STQ
STQ
;
typedef
struct
SVState
SVState
;
typedef
struct
SVState
SVState
;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SQWorkerMgmt
SQHandle
;
typedef
struct
SVnodeTask
{
typedef
struct
SVnodeTask
{
TD_DLIST_NODE
(
SVnodeTask
);
TD_DLIST_NODE
(
SVnodeTask
);
...
@@ -95,7 +102,9 @@ struct SVnode {
...
@@ -95,7 +102,9 @@ struct SVnode {
STfs
*
pTfs
;
STfs
*
pTfs
;
};
};
int
vnodeScheduleTask
(
SVnodeTask
*
task
);
int
vnodeScheduleTask
(
SVnodeTask
*
task
);
int
vnodeQueryOpen
(
SVnode
*
pVnode
);
void
vnodeQueryClose
(
SVnode
*
pVnode
);
#define vFatal(...) \
#define vFatal(...) \
do { \
do { \
...
@@ -205,6 +214,12 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen, int32_t wo
...
@@ -205,6 +214,12 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen, int32_t wo
// sma
// sma
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
#include "meta.h"
#include "tsdb.h"
#include "tq.h"
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/inc/vnodeQuery.h
已删除
100644 → 0
浏览文件 @
e9f7bf86
/*
* 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 "qworker.h"
#include "vnode.h"
typedef
struct
SQWorkerMgmt
SQHandle
;
int
vnodeQueryOpen
(
SVnode
*
pVnode
);
void
vnodeQueryClose
(
SVnode
*
pVnode
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_READ_H_*/
source/dnode/vnode/src/meta/metaCache.c
浏览文件 @
a8f740bc
...
@@ -13,8 +13,7 @@
...
@@ -13,8 +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 "meta.h"
#include "vnodeInt.h"
#include "metaDef.h"
struct
SMetaCache
{
struct
SMetaCache
{
// TODO
// TODO
...
...
source/dnode/vnode/src/meta/metaCfg.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
metaDef
.h"
#include "
vnodeInt
.h"
const
SMetaCfg
defaultMetaOptions
=
{.
lruSize
=
0
};
const
SMetaCfg
defaultMetaOptions
=
{.
lruSize
=
0
};
...
...
source/dnode/vnode/src/meta/metaIdx.c
浏览文件 @
a8f740bc
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#ifdef USE_INVERTED_INDEX
#ifdef USE_INVERTED_INDEX
#include "index.h"
#include "index.h"
#endif
#endif
#include "
metaDef
.h"
#include "
vnodeInt
.h"
struct
SMetaIdx
{
struct
SMetaIdx
{
#ifdef USE_INVERTED_INDEX
#ifdef USE_INVERTED_INDEX
...
...
source/dnode/vnode/src/meta/metaMain.c
浏览文件 @
a8f740bc
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#include "tcoding.h"
#include "tcoding.h"
#include "
metaDef
.h"
#include "
vnodeInt
.h"
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
static
SMeta
*
metaNew
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
static
void
metaFree
(
SMeta
*
pMeta
);
static
void
metaFree
(
SMeta
*
pMeta
);
...
...
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
metaDef
.h"
#include "
vnodeInt
.h"
#include "tdbInt.h"
#include "tdbInt.h"
typedef
struct
SPoolMem
{
typedef
struct
SPoolMem
{
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
metaDef
.h"
#include "
vnodeInt
.h"
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
)
{
// Validate the tbOptions
// Validate the tbOptions
...
...
source/dnode/vnode/src/meta/metaTbCfg.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
metaDef
.h"
#include "
vnodeInt
.h"
#include "tcoding.h"
#include "tcoding.h"
int
metaValidateTbCfg
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
)
{
int
metaValidateTbCfg
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
)
{
...
...
source/dnode/vnode/src/meta/metaTbUid.c
浏览文件 @
a8f740bc
...
@@ -13,8 +13,7 @@
...
@@ -13,8 +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 "meta.h"
#include "vnodeInt.h"
#include "metaDef.h"
int
metaOpenUidGnrt
(
SMeta
*
pMeta
)
{
int
metaOpenUidGnrt
(
SMeta
*
pMeta
)
{
// Init a generator
// Init a generator
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
a8f740bc
...
@@ -15,9 +15,8 @@
...
@@ -15,9 +15,8 @@
#include "tcompare.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tqInt.h"
#include "tqMetaStore.h"
#include "tstream.h"
#include "tstream.h"
#include "vnodeInt.h"
int32_t
tqInit
()
{
return
tqPushMgrInit
();
}
int32_t
tqInit
()
{
return
tqPushMgrInit
();
}
...
@@ -83,9 +82,9 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
...
@@ -83,9 +82,9 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
memcpy
(
data
,
msg
,
msgLen
);
memcpy
(
data
,
msg
,
msgLen
);
if
(
msgType
==
TDMT_VND_SUBMIT
)
{
if
(
msgType
==
TDMT_VND_SUBMIT
)
{
if
(
tsdbUpdateSmaWindow
(
pTq
->
pVnode
->
pTsdb
,
msg
)
!=
0
)
{
//
if (tsdbUpdateSmaWindow(pTq->pVnode->pTsdb, msg) != 0) {
return
-
1
;
//
return -1;
}
//
}
}
}
SRpcMsg
req
=
{
SRpcMsg
req
=
{
...
@@ -272,7 +271,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -272,7 +271,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
fetchOffset
=
pReq
->
currentOffset
+
1
;
fetchOffset
=
pReq
->
currentOffset
+
1
;
}
}
vDebug
(
"tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld"
,
consumerId
,
pReq
->
epoch
,
pTq
->
pVnode
->
vgId
,
pReq
->
currentOffset
,
fetchOffset
);
vDebug
(
"tmq poll: consumer %ld (epoch %d) recv poll req in vg %d, req %ld %ld"
,
consumerId
,
pReq
->
epoch
,
pTq
->
pVnode
->
vgId
,
pReq
->
currentOffset
,
fetchOffset
);
SMqPollRsp
rsp
=
{
SMqPollRsp
rsp
=
{
/*.consumerId = consumerId,*/
/*.consumerId = consumerId,*/
...
@@ -296,10 +296,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -296,10 +296,10 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
}
}
STqTopic
*
pTopic
=
NULL
;
STqTopic
*
pTopic
=
NULL
;
int
sz
=
taosArrayGetSize
(
pConsumer
->
topics
);
int
sz
=
taosArrayGetSize
(
pConsumer
->
topics
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
STqTopic
*
topic
=
taosArrayGet
(
pConsumer
->
topics
,
i
);
STqTopic
*
topic
=
taosArrayGet
(
pConsumer
->
topics
,
i
);
//TODO race condition
//
TODO race condition
ASSERT
(
pConsumer
->
consumerId
==
consumerId
);
ASSERT
(
pConsumer
->
consumerId
==
consumerId
);
if
(
strcmp
(
topic
->
topicName
,
pReq
->
topic
)
==
0
)
{
if
(
strcmp
(
topic
->
topicName
,
pReq
->
topic
)
==
0
)
{
pTopic
=
topic
;
pTopic
=
topic
;
...
@@ -307,7 +307,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -307,7 +307,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
}
}
}
}
if
(
pTopic
==
NULL
)
{
if
(
pTopic
==
NULL
)
{
vWarn
(
"tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d"
,
consumerId
,
pReq
->
epoch
,
pReq
->
topic
,
pTq
->
pVnode
->
vgId
);
vWarn
(
"tmq poll: consumer %ld (epoch %d) topic %s not found in vg %d"
,
consumerId
,
pReq
->
epoch
,
pReq
->
topic
,
pTq
->
pVnode
->
vgId
);
pMsg
->
pCont
=
NULL
;
pMsg
->
pCont
=
NULL
;
pMsg
->
contLen
=
0
;
pMsg
->
contLen
=
0
;
pMsg
->
code
=
-
1
;
pMsg
->
code
=
-
1
;
...
@@ -315,17 +316,17 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -315,17 +316,17 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
return
0
;
return
0
;
}
}
vDebug
(
"poll topic %s from consumer %ld (epoch %d)
"
,
pTopic
->
topicName
,
consumerId
,
pReq
->
epoch
);
vDebug
(
"poll topic %s from consumer %ld (epoch %d)
%s"
,
pTopic
->
topicName
,
consumerId
,
pReq
->
epoch
,
pTopic
->
topicName
);
rsp
.
reqOffset
=
pReq
->
currentOffset
;
rsp
.
reqOffset
=
pReq
->
currentOffset
;
rsp
.
skipLogNum
=
0
;
rsp
.
skipLogNum
=
0
;
while
(
1
)
{
while
(
1
)
{
/*if (fetchOffset > walGetLastVer(pTq->pWal) || walReadWithHandle(pTopic->pReadhandle, fetchOffset) < 0) {*/
/*if (fetchOffset > walGetLastVer(pTq->pWal) || walReadWithHandle(pTopic->pReadhandle, fetchOffset) < 0) {*/
//TODO
//
TODO
consumerEpoch
=
atomic_load_32
(
&
pConsumer
->
epoch
);
consumerEpoch
=
atomic_load_32
(
&
pConsumer
->
epoch
);
if
(
consumerEpoch
>
pReq
->
epoch
)
{
if
(
consumerEpoch
>
pReq
->
epoch
)
{
//TODO: return
//
TODO: return
break
;
break
;
}
}
SWalReadHead
*
pHead
;
SWalReadHead
*
pHead
;
...
...
source/dnode/vnode/src/tq/tqMetaStore.c
浏览文件 @
a8f740bc
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "
tqMetaStore
.h"
#include "
vnodeInt
.h"
// TODO:replace by an abstract file layer
// TODO:replace by an abstract file layer
#include <fcntl.h>
#include <fcntl.h>
#include <string.h>
#include <string.h>
...
...
source/dnode/vnode/src/tq/tqOffset.c
浏览文件 @
a8f740bc
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "
tqOffse
t.h"
#include "
vnodeIn
t.h"
enum
ETqOffsetPersist
{
enum
ETqOffsetPersist
{
TQ_OFFSET_PERSIST__LAZY
=
1
,
TQ_OFFSET_PERSIST__LAZY
=
1
,
...
@@ -39,4 +39,3 @@ STqOffsetStore* STqOffsetOpen(STqOffsetCfg* pCfg) {
...
@@ -39,4 +39,3 @@ STqOffsetStore* STqOffsetOpen(STqOffsetCfg* pCfg) {
pStore
->
pHash
=
taosHashInit
(
64
,
MurmurHash3_32
,
true
,
HASH_NO_LOCK
);
pStore
->
pHash
=
taosHashInit
(
64
,
MurmurHash3_32
,
true
,
HASH_NO_LOCK
);
return
pStore
;
return
pStore
;
}
}
source/dnode/vnode/src/tq/tqPush.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tqPush
.h"
#include "
vnodeInt
.h"
int32_t
tqPushMgrInit
()
{
int32_t
tqPushMgrInit
()
{
//
//
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
a8f740bc
...
@@ -167,8 +167,8 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -167,8 +167,8 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
if
(
!
tdSTSRowIterNext
(
&
iter
,
pColData
->
info
.
colId
,
pColData
->
info
.
type
,
&
sVal
))
{
break
;
break
;
}
}
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
false
)
<
0
)
{
/*if (colDataAppend(pColData, curRow, sVal.val, false) < 0) {*/
/*if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) {*/
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
sVal
.
valType
==
TD_VTYPE_NULL
)
<
0
)
{
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
return
NULL
;
return
NULL
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
浏览文件 @
a8f740bc
...
@@ -19,8 +19,6 @@
...
@@ -19,8 +19,6 @@
#include "taoserror.h"
#include "taoserror.h"
#include "tcoding.h"
#include "tcoding.h"
#include "thash.h"
#include "thash.h"
#include "tsdbDBDef.h"
#include "tsdbLog.h"
#define IMPL_WITH_LOCK 1
#define IMPL_WITH_LOCK 1
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
#define TSDB_MAX_SUBBLOCKS 8
#define TSDB_MAX_SUBBLOCKS 8
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
a8f740bc
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
#include <regex.h>
#include <regex.h>
#include "
tsdbDef
.h"
#include "
vnodeInt
.h"
#include "os.h"
#include "os.h"
typedef
enum
{
TSDB_TXN_TEMP_FILE
=
0
,
TSDB_TXN_CURR_FILE
}
TSDB_TXN_FILE_T
;
typedef
enum
{
TSDB_TXN_TEMP_FILE
=
0
,
TSDB_TXN_CURR_FILE
}
TSDB_TXN_FILE_T
;
...
@@ -1111,7 +1111,7 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
...
@@ -1111,7 +1111,7 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
char
bname
[
TSDB_FILENAME_LEN
];
char
bname
[
TSDB_FILENAME_LEN
];
STfsDir
*
tdir
=
NULL
;
STfsDir
*
tdir
=
NULL
;
const
STfsFile
*
pf
=
NULL
;
const
STfsFile
*
pf
=
NULL
;
const
char
*
pattern
=
"^v[0-9]+f[0-9]+
\\
.(head|data|last)(-ver[0-9]+)?$"
;
const
char
*
pattern
=
"^v[0-9]+f[0-9]+
\\
.(head|data|last
|smad|smal
)(-ver[0-9]+)?$"
;
SArray
*
fArray
=
NULL
;
SArray
*
fArray
=
NULL
;
regex_t
regex
;
regex_t
regex
;
STsdbFS
*
pfs
=
REPO_FS
(
pRepo
);
STsdbFS
*
pfs
=
REPO_FS
(
pRepo
);
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
static
const
char
*
TSDB_FNAME_SUFFIX
[]
=
{
static
const
char
*
TSDB_FNAME_SUFFIX
[]
=
{
"head"
,
// TSDB_FILE_HEAD
"head"
,
// TSDB_FILE_HEAD
...
...
source/dnode/vnode/src/tsdb/tsdbMain.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
static
STsdb
*
tsdbNew
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
static
STsdb
*
tsdbNew
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STfs
*
pTfs
);
SMeta
*
pMeta
,
STfs
*
pTfs
);
...
@@ -87,8 +87,8 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
...
@@ -87,8 +87,8 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
static
void
tsdbFree
(
STsdb
*
pTsdb
)
{
static
void
tsdbFree
(
STsdb
*
pTsdb
)
{
if
(
pTsdb
)
{
if
(
pTsdb
)
{
tsdbFreeSmaEnv
(
REPO_TSMA_ENV
(
pTsdb
));
//
tsdbFreeSmaEnv(REPO_TSMA_ENV(pTsdb));
tsdbFreeSmaEnv
(
REPO_RSMA_ENV
(
pTsdb
));
//
tsdbFreeSmaEnv(REPO_RSMA_ENV(pTsdb));
tsdbFreeFS
(
pTsdb
->
fs
);
tsdbFreeFS
(
pTsdb
->
fs
);
taosMemoryFreeClear
(
pTsdb
->
path
);
taosMemoryFreeClear
(
pTsdb
->
path
);
taosMemoryFree
(
pTsdb
);
taosMemoryFree
(
pTsdb
);
...
@@ -98,7 +98,7 @@ static void tsdbFree(STsdb *pTsdb) {
...
@@ -98,7 +98,7 @@ static void tsdbFree(STsdb *pTsdb) {
static
int
tsdbOpenImpl
(
STsdb
*
pTsdb
)
{
static
int
tsdbOpenImpl
(
STsdb
*
pTsdb
)
{
tsdbOpenFS
(
pTsdb
);
tsdbOpenFS
(
pTsdb
);
tsdbInitSma
(
pTsdb
);
//
tsdbInitSma(pTsdb);
// TODO
// TODO
return
0
;
return
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
static
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
static
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
static
int
tsdbMemTableInsertTbData
(
STsdb
*
pRepo
,
SSubmitBlk
*
pBlock
,
int32_t
*
pAffectedRows
);
static
int
tsdbMemTableInsertTbData
(
STsdb
*
pRepo
,
SSubmitBlk
*
pBlock
,
int32_t
*
pAffectedRows
);
...
...
source/dnode/vnode/src/tsdb/tsdbOptions.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
const
STsdbCfg
defautlTsdbOptions
=
{.
precision
=
0
,
const
STsdbCfg
defautlTsdbOptions
=
{.
precision
=
0
,
.
lruCacheSize
=
0
,
.
lruCacheSize
=
0
,
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
a8f740bc
...
@@ -13,25 +13,18 @@
...
@@ -13,25 +13,18 @@
* 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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "os.h"
#include "os.h"
#include "talgo.h"
#include "talgo.h"
#include "tcompare.h"
#include "tcompare.h"
#include "tdataformat.h"
#include "tdataformat.h"
#include "texception.h"
#include "texception.h"
#include "tsdb.h"
#include "tsdbFS.h"
#include "tsdbLog.h"
#include "tsdbReadImpl.h"
#include "tskiplist.h"
#include "ttime.h"
#include "taosdef.h"
#include "taosdef.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "
tsdbDef
.h"
#include "
vnodeInt
.h"
#include "tmsg.h"
#include "tmsg.h"
#include "tsdbCommit.h"
#define EXTRA_BYTES 2
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
...
source/dnode/vnode/src/tsdb/tsdbReadImpl.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
#define TSDB_KEY_COL_OFFSET 0
#define TSDB_KEY_COL_OFFSET 0
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
static
const
char
*
TSDB_SMA_DNAME
[]
=
{
static
const
char
*
TSDB_SMA_DNAME
[]
=
{
""
,
// TSDB_SMA_TYPE_BLOCK
""
,
// TSDB_SMA_TYPE_BLOCK
...
...
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "
tsdbDef
.h"
#include "
vnodeInt
.h"
/**
/**
* @brief insert TS data
* @brief insert TS data
...
...
source/dnode/vnode/src/vnd/vnodeArenaMAImpl.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "vn
d
.h"
#include "vn
odeInt
.h"
static
SVArenaNode
*
vArenaNodeNew
(
uint64_t
capacity
);
static
SVArenaNode
*
vArenaNodeNew
(
uint64_t
capacity
);
static
void
vArenaNodeFree
(
SVArenaNode
*
pNode
);
static
void
vArenaNodeFree
(
SVArenaNode
*
pNode
);
...
...
source/dnode/vnode/src/vnd/vnodeBufferPool.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "vn
d
.h"
#include "vn
odeInt
.h"
/* ------------------------ STRUCTURES ------------------------ */
/* ------------------------ STRUCTURES ------------------------ */
#define VNODE_BUF_POOL_SHARDS 3
#define VNODE_BUF_POOL_SHARDS 3
...
...
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "vn
d
.h"
#include "vn
odeInt
.h"
const
SVnodeCfg
defaultVnodeOptions
=
{
const
SVnodeCfg
defaultVnodeOptions
=
{
.
wsize
=
96
*
1024
*
1024
,
.
ssize
=
1
*
1024
*
1024
,
.
lsize
=
1024
,
.
walCfg
=
{.
level
=
TAOS_WAL_WRITE
}};
/* TODO */
.
wsize
=
96
*
1024
*
1024
,
.
ssize
=
1
*
1024
*
1024
,
.
lsize
=
1024
,
.
walCfg
=
{.
level
=
TAOS_WAL_WRITE
}};
/* TODO */
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "vn
d
.h"
#include "vn
odeInt
.h"
static
int
vnodeStartCommit
(
SVnode
*
pVnode
);
static
int
vnodeStartCommit
(
SVnode
*
pVnode
);
static
int
vnodeEndCommit
(
SVnode
*
pVnode
);
static
int
vnodeEndCommit
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/vnd/vnodeInt.c
浏览文件 @
a8f740bc
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "sync.h"
#include "sync.h"
#include "vn
d
.h"
#include "vn
odeInt
.h"
// #include "vnodeInt.h"
// #include "vnodeInt.h"
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
)
{
return
0
;
}
int32_t
vnodeAlter
(
SVnode
*
pVnode
,
const
SVnodeCfg
*
pCfg
)
{
return
0
;
}
...
...
source/dnode/vnode/src/vnd/vnodeMain.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "vn
d
.h"
#include "vn
odeInt
.h"
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
static
SVnode
*
vnodeNew
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
static
void
vnodeFree
(
SVnode
*
pVnode
);
static
void
vnodeFree
(
SVnode
*
pVnode
);
...
...
source/dnode/vnode/src/vnd/vnodeMgr.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 "vn
d
.h"
#include "vn
odeInt
.h"
#include "tglobal.h"
#include "tglobal.h"
SVnodeMgr
vnodeMgr
=
{.
vnodeInitFlag
=
TD_MOD_UNINITIALIZED
};
SVnodeMgr
vnodeMgr
=
{.
vnodeInitFlag
=
TD_MOD_UNINITIALIZED
};
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
a8f740bc
...
@@ -13,9 +13,8 @@
...
@@ -13,9 +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/>.
*/
*/
#include "vnodeQuery.h"
#include "executor.h"
#include "executor.h"
#include "vn
d
.h"
#include "vn
odeInt
.h"
static
int32_t
vnodeGetTableList
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
static
int32_t
vnodeGetTableList
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
a8f740bc
...
@@ -13,13 +13,13 @@
...
@@ -13,13 +13,13 @@
* 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 "vn
d
.h"
#include "vn
odeInt
.h"
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
)
{
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
)
{
// TODO
// TODO
blockDebugShowData
(
data
);
//
blockDebugShowData(data);
tsdbInsertTSmaData
(((
SVnode
*
)
pVnode
)
->
pTsdb
,
smaId
,
(
const
char
*
)
data
);
//
tsdbInsertTSmaData(((SVnode *)pVnode)->pTsdb, smaId, (const char *)data);
}
}
void
vnodeProcessWMsgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
void
vnodeProcessWMsgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
...
@@ -232,16 +232,16 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -232,16 +232,16 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
tdDestroyTSma(&vCreateSmaReq.tSma);
tdDestroyTSma(&vCreateSmaReq.tSma);
// TODO: return directly or go on follow steps?
// TODO: return directly or go on follow steps?
#endif
#endif
if
(
tsdbCreateTSma
(
pVnode
->
pTsdb
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
//
if (tsdbCreateTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) {
// TODO
//
// TODO
}
//
}
}
break
;
//
} break;
case
TDMT_VND_CANCEL_SMA
:
{
// timeRangeSMA
//
case TDMT_VND_CANCEL_SMA: { // timeRangeSMA
}
break
;
//
} break;
case
TDMT_VND_DROP_SMA
:
{
// timeRangeSMA
//
case TDMT_VND_DROP_SMA: { // timeRangeSMA
if
(
tsdbDropTSma
(
pVnode
->
pTsdb
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
//
if (tsdbDropTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) {
// TODO
//
// TODO
}
//
}
#if 0
#if 0
tsdbTSmaSub(pVnode->pTsdb, 1);
tsdbTSmaSub(pVnode->pTsdb, 1);
SVDropTSmaReq vDropSmaReq = {0};
SVDropTSmaReq vDropSmaReq = {0};
...
...
source/dnode/vnode/test/CMakeLists.txt
浏览文件 @
a8f740bc
...
@@ -25,15 +25,15 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
...
@@ -25,15 +25,15 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
# COMMAND tqTest
# COMMAND tqTest
# )
# )
ADD_EXECUTABLE
(
tsdbSmaTest tsdbSmaTest.cpp
)
#
ADD_EXECUTABLE(tsdbSmaTest tsdbSmaTest.cpp)
TARGET_LINK_LIBRARIES
(
#
TARGET_LINK_LIBRARIES(
tsdbSmaTest
#
tsdbSmaTest
PUBLIC os util common vnode gtest_main
#
PUBLIC os util common vnode gtest_main
)
#
)
TARGET_INCLUDE_DIRECTORIES
(
# TARGET_INCLUDE_DIRECTORIES(
tsdbSmaTest
# tsdbSmaTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/common"
# PUBLIC "${CMAKE_SOURCE_DIR}/include/common"
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../src/inc"
# PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../src/inc"
PUBLIC
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
# PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
# )
\ No newline at end of file
\ No newline at end of file
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
a8f740bc
...
@@ -14,13 +14,13 @@
...
@@ -14,13 +14,13 @@
*/
*/
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <
tsdbDef
.h>
#include <
vnodeInt
.h>
#include <taoserror.h>
#include <taoserror.h>
#include <tglobal.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#include <
metaDef
.h>
#include <
vnodeInt
.h>
#include <tmsg.h>
#include <tmsg.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic push
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
a8f740bc
...
@@ -511,6 +511,12 @@ typedef struct SProjectOperatorInfo {
...
@@ -511,6 +511,12 @@ typedef struct SProjectOperatorInfo {
SSDataBlock
*
existDataBlock
;
SSDataBlock
*
existDataBlock
;
SArray
*
pPseudoColInfo
;
SArray
*
pPseudoColInfo
;
SLimit
limit
;
SLimit
limit
;
SLimit
slimit
;
uint64_t
groupId
;
int64_t
curSOffset
;
int64_t
curGroupOutput
;
int64_t
curOffset
;
int64_t
curOffset
;
int64_t
curOutput
;
int64_t
curOutput
;
}
SProjectOperatorInfo
;
}
SProjectOperatorInfo
;
...
@@ -563,6 +569,29 @@ typedef struct SGroupbyOperatorInfo {
...
@@ -563,6 +569,29 @@ typedef struct SGroupbyOperatorInfo {
SAggSupporter
aggSup
;
SAggSupporter
aggSup
;
}
SGroupbyOperatorInfo
;
}
SGroupbyOperatorInfo
;
typedef
struct
SDataGroupInfo
{
uint64_t
groupId
;
int64_t
numOfRows
;
SArray
*
pPageList
;
}
SDataGroupInfo
;
// The sort in partition may be needed later.
typedef
struct
SPartitionOperatorInfo
{
SOptrBasicInfo
binfo
;
SArray
*
pGroupCols
;
SArray
*
pGroupColVals
;
// current group column values, SArray<SGroupKeys>
char
*
keyBuf
;
// group by keys for hash
int32_t
groupKeyLen
;
// total group by column width
SHashObj
*
pGroupSet
;
// quick locate the window object for each result
SDiskbasedBuf
*
pBuf
;
// query result buffer based on blocked-wised disk file
int32_t
rowCapacity
;
// maximum number of rows for each buffer page
int32_t
*
columnOffset
;
// start position for each column data
void
*
pGroupIter
;
// group iterator
int32_t
pageIndex
;
// page index of current group
}
SPartitionOperatorInfo
;
typedef
struct
SSessionAggOperatorInfo
{
typedef
struct
SSessionAggOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
SAggSupporter
aggSup
;
...
@@ -650,7 +679,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
...
@@ -650,7 +679,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
S
Limit
*
pSlimit
,
S
ExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SArray
*
pSortInfo
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SArray
*
pSortInfo
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
...
@@ -667,8 +696,8 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
...
@@ -667,8 +696,8 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
int32_t
fillType
,
char
*
fillVal
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
fillType
,
char
*
fillVal
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStatewindowOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStatewindowOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
S
SDataBlock
*
pResultBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
#if 0
#if 0
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
a8f740bc
...
@@ -13,7 +13,7 @@
...
@@ -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 <
tsdb
.h>
#include <
vnode
.h>
#include "dataSinkMgt.h"
#include "dataSinkMgt.h"
#include "texception.h"
#include "texception.h"
#include "os.h"
#include "os.h"
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
a8f740bc
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
#include "tcompare.h"
#include "tcompare.h"
#include "tcompression.h"
#include "tcompression.h"
#include "thash.h"
#include "thash.h"
#include "
tsdb
.h"
#include "
vnode
.h"
#include "ttypes.h"
#include "ttypes.h"
#include "vnode.h"
#include "vnode.h"
...
@@ -302,6 +302,10 @@ SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) {
...
@@ -302,6 +302,10 @@ SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) {
}
}
taosArrayPush
(
pBlock
->
pDataBlock
,
&
idata
);
taosArrayPush
(
pBlock
->
pDataBlock
,
&
idata
);
if
(
IS_VAR_DATA_TYPE
(
idata
.
info
.
type
))
{
pBlock
->
info
.
hasVarCol
=
true
;
}
}
}
return
pBlock
;
return
pBlock
;
...
@@ -1259,6 +1263,7 @@ static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, S
...
@@ -1259,6 +1263,7 @@ static void setPseudoOutputColInfo(SSDataBlock* pResult, SqlFunctionCtx* pCtx, S
static
void
projectApplyFunctions
(
SExprInfo
*
pExpr
,
SSDataBlock
*
pResult
,
SSDataBlock
*
pSrcBlock
,
SqlFunctionCtx
*
pCtx
,
static
void
projectApplyFunctions
(
SExprInfo
*
pExpr
,
SSDataBlock
*
pResult
,
SSDataBlock
*
pSrcBlock
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SArray
*
pPseudoList
)
{
int32_t
numOfOutput
,
SArray
*
pPseudoList
)
{
setPseudoOutputColInfo
(
pResult
,
pCtx
,
pPseudoList
);
setPseudoOutputColInfo
(
pResult
,
pCtx
,
pPseudoList
);
pResult
->
info
.
groupId
=
pSrcBlock
->
info
.
groupId
;
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
)
{
// it is a project query
if
(
pExpr
[
k
].
pExpr
->
nodeType
==
QUERY_NODE_COLUMN
)
{
// it is a project query
...
@@ -5422,7 +5427,6 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup)
...
@@ -5422,7 +5427,6 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup)
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
if
(
pBlock
==
NULL
)
{
if
(
pBlock
==
NULL
)
{
assert
(
*
newgroup
==
false
);
*
newgroup
=
prevVal
;
*
newgroup
=
prevVal
;
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
break
;
break
;
...
@@ -5450,6 +5454,38 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup)
...
@@ -5450,6 +5454,38 @@ static SSDataBlock* doProjectOperation(SOperatorInfo* pOperator, bool* newgroup)
projectApplyFunctions
(
pOperator
->
pExpr
,
pInfo
->
pRes
,
pBlock
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
,
pProjectInfo
->
pPseudoColInfo
);
projectApplyFunctions
(
pOperator
->
pExpr
,
pInfo
->
pRes
,
pBlock
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
,
pProjectInfo
->
pPseudoColInfo
);
if
(
pProjectInfo
->
curSOffset
>
0
)
{
if
(
pProjectInfo
->
groupId
==
0
)
{
// it is the first group
pProjectInfo
->
groupId
=
pBlock
->
info
.
groupId
;
blockDataCleanup
(
pInfo
->
pRes
);
continue
;
}
else
if
(
pProjectInfo
->
groupId
!=
pBlock
->
info
.
groupId
)
{
pProjectInfo
->
curSOffset
-=
1
;
// ignore data block in current group
if
(
pProjectInfo
->
curSOffset
>
0
)
{
blockDataCleanup
(
pInfo
->
pRes
);
continue
;
}
}
pProjectInfo
->
groupId
=
pBlock
->
info
.
groupId
;
}
if
(
pProjectInfo
->
groupId
!=
0
&&
pProjectInfo
->
groupId
!=
pBlock
->
info
.
groupId
)
{
pProjectInfo
->
curGroupOutput
+=
1
;
if
((
pProjectInfo
->
slimit
.
limit
>
0
)
&&
(
pProjectInfo
->
slimit
.
limit
<=
pProjectInfo
->
curGroupOutput
))
{
pOperator
->
status
=
OP_EXEC_DONE
;
return
NULL
;
}
// reset the value for a new group data
pProjectInfo
->
curOffset
=
0
;
pProjectInfo
->
curOutput
=
0
;
}
pProjectInfo
->
groupId
=
pBlock
->
info
.
groupId
;
// todo extract method
// todo extract method
if
(
pProjectInfo
->
curOffset
<
pInfo
->
pRes
->
info
.
rows
&&
pProjectInfo
->
curOffset
>
0
)
{
if
(
pProjectInfo
->
curOffset
<
pInfo
->
pRes
->
info
.
rows
&&
pProjectInfo
->
curOffset
>
0
)
{
blockDataTrimFirstNRows
(
pInfo
->
pRes
,
pProjectInfo
->
curOffset
);
blockDataTrimFirstNRows
(
pInfo
->
pRes
,
pProjectInfo
->
curOffset
);
...
@@ -6317,7 +6353,7 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
...
@@ -6317,7 +6353,7 @@ static SArray* setRowTsColumnOutputInfo(SqlFunctionCtx* pCtx, int32_t numOfCols)
}
}
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
)
{
SSDataBlock
*
pResBlock
,
SLimit
*
pLimit
,
S
Limit
*
pSlimit
,
S
ExecTaskInfo
*
pTaskInfo
)
{
SProjectOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SProjectOperatorInfo
));
SProjectOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SProjectOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
@@ -6325,7 +6361,10 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
...
@@ -6325,7 +6361,10 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p
}
}
pInfo
->
limit
=
*
pLimit
;
pInfo
->
limit
=
*
pLimit
;
pInfo
->
slimit
=
*
pSlimit
;
pInfo
->
curOffset
=
pLimit
->
offset
;
pInfo
->
curOffset
=
pLimit
->
offset
;
pInfo
->
curSOffset
=
pSlimit
->
offset
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
int32_t
numOfCols
=
num
;
int32_t
numOfCols
=
num
;
...
@@ -7052,11 +7091,13 @@ static SArray* extractScanColumnId(SNodeList* pNodeList);
...
@@ -7052,11 +7091,13 @@ static SArray* extractScanColumnId(SNodeList* pNodeList);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
);
static
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
);
static
SArray
*
createSortInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
createSortInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
);
SOperatorInfo
*
createOperatorTree
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
SOperatorInfo
*
createOperatorTree
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
int32_t
type
=
nodeType
(
pPhyNode
);
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
type
)
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
...
@@ -7064,11 +7105,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -7064,11 +7105,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SArray
*
pColList
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
,
pScanPhyNode
->
node
.
pOutputDataBlockDesc
,
&
numOfCols
);
SArray
*
pColList
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
,
pScanPhyNode
->
node
.
pOutputDataBlockDesc
,
&
numOfCols
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pColList
,
pScanPhyNode
->
node
.
pConditions
,
pTaskInfo
);
pScanPhyNode
->
reverse
,
pColList
,
pScanPhyNode
->
node
.
pConditions
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
nodeType
(
pPhyNode
)
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
type
)
{
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pExchange
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pExchange
->
node
.
pOutputDataBlockDesc
);
return
createExchangeOperatorInfo
(
pExchange
->
pSrcEndPoints
,
pResBlock
,
pTaskInfo
);
return
createExchangeOperatorInfo
(
pExchange
->
pSrcEndPoints
,
pResBlock
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
nodeType
(
pPhyNode
)
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
...
@@ -7081,7 +7122,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -7081,7 +7122,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pHandle
->
reader
,
pResBlock
,
pColList
,
tableIdList
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pHandle
->
reader
,
pResBlock
,
pColList
,
tableIdList
,
pTaskInfo
);
taosArrayDestroy
(
tableIdList
);
taosArrayDestroy
(
tableIdList
);
return
pOperator
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
==
nodeType
(
pPhyNode
)
)
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
==
type
)
{
SSystemTableScanPhysiNode
*
pSysScanPhyNode
=
(
SSystemTableScanPhysiNode
*
)
pPhyNode
;
SSystemTableScanPhysiNode
*
pSysScanPhyNode
=
(
SSystemTableScanPhysiNode
*
)
pPhyNode
;
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pSysScanPhyNode
->
scan
.
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pSysScanPhyNode
->
scan
.
node
.
pOutputDataBlockDesc
);
...
@@ -7097,93 +7138,76 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
...
@@ -7097,93 +7138,76 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
}
}
}
i
f
(
QUERY_NODE_PHYSICAL_PLAN_PROJECT
==
nodeType
(
pPhyNode
))
{
i
nt32_t
type
=
nodeType
(
pPhyNode
);
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
ASSERT
(
size
==
1
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
SOperatorInfo
*
op
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
SOperatorInfo
*
op
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
if
(
QUERY_NODE_PHYSICAL_PLAN_PROJECT
==
type
)
{
int32_t
num
=
0
;
int32_t
num
=
0
;
SProjectPhysiNode
*
pProjPhyNode
=
(
SProjectPhysiNode
*
)
pPhyNode
;
SProjectPhysiNode
*
pProjPhyNode
=
(
SProjectPhysiNode
*
)
pPhyNode
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pProjPhyNode
->
pProjections
,
NULL
,
&
num
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pProjPhyNode
->
pProjections
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SLimit
limit
=
{.
limit
=
pProjPhyNode
->
limit
,
.
offset
=
pProjPhyNode
->
offset
};
SLimit
limit
=
{.
limit
=
pProjPhyNode
->
limit
,
.
offset
=
pProjPhyNode
->
offset
};
SLimit
slimit
=
{.
limit
=
pProjPhyNode
->
slimit
,
.
offset
=
pProjPhyNode
->
soffset
};
return
createProjectOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
&
limit
,
pTaskInfo
);
return
createProjectOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
&
limit
,
&
slimit
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_AGG
==
nodeType
(
pPhyNode
))
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_AGG
==
type
)
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
int32_t
num
=
0
;
assert
(
size
==
1
);
SAggPhysiNode
*
pAggNode
=
(
SAggPhysiNode
*
)
pPhyNode
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SExprInfo
*
pExprInfo
=
createExprInfo
(
pAggNode
->
pAggFuncs
,
pAggNode
->
pGroupKeys
,
&
num
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
i
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SOperatorInfo
*
op
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
if
(
pAggNode
->
pGroupKeys
!=
NULL
)
{
int32_t
num
=
0
;
SArray
*
pColList
=
extractColumnInfo
(
pAggNode
->
pGroupKeys
);
return
createGroupOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pColList
,
pAggNode
->
node
.
pConditions
,
pTaskInfo
,
NULL
);
SAggPhysiNode
*
pAggNode
=
(
SAggPhysiNode
*
)
pPhyNode
;
}
else
{
SExprInfo
*
pExprInfo
=
createExprInfo
(
pAggNode
->
pAggFuncs
,
pAggNode
->
pGroupKeys
,
&
num
);
return
createAggregateOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pTaskInfo
,
pTableGroupInfo
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
if
(
pAggNode
->
pGroupKeys
!=
NULL
)
{
SArray
*
pColList
=
extractColumnInfo
(
pAggNode
->
pGroupKeys
);
return
createGroupOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pColList
,
pAggNode
->
node
.
pConditions
,
pTaskInfo
,
NULL
);
}
else
{
return
createAggregateOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pTaskInfo
,
pTableGroupInfo
);
}
}
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
==
nodeType
(
pPhyNode
))
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
i
);
SOperatorInfo
*
op
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
SIntervalPhysiNode
*
pIntervalPhyNode
=
(
SIntervalPhysiNode
*
)
pPhyNode
;
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
window
.
pFuncs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SInterval
interval
=
{
.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
.
intervalUnit
=
pIntervalPhyNode
->
intervalUnit
,
.
slidingUnit
=
pIntervalPhyNode
->
slidingUnit
,
.
offset
=
pIntervalPhyNode
->
offset
,
.
precision
=
pIntervalPhyNode
->
precision
};
int32_t
primaryTsSlotId
=
((
SColumnNode
*
)
pIntervalPhyNode
->
pTspk
)
->
slotId
;
return
createIntervalOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
&
interval
,
primaryTsSlotId
,
pTableGroupInfo
,
pTaskInfo
);
}
}
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SORT
==
nodeType
(
pPhyNode
))
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
==
type
)
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
SIntervalPhysiNode
*
pIntervalPhyNode
=
(
SIntervalPhysiNode
*
)
pPhyNode
;
assert
(
size
==
1
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
int32_t
num
=
0
;
SOperatorInfo
*
op
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
window
.
pFuncs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SInterval
interval
=
{
.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
.
intervalUnit
=
pIntervalPhyNode
->
intervalUnit
,
.
slidingUnit
=
pIntervalPhyNode
->
slidingUnit
,
.
offset
=
pIntervalPhyNode
->
offset
,
.
precision
=
pIntervalPhyNode
->
precision
};
int32_t
primaryTsSlotId
=
((
SColumnNode
*
)
pIntervalPhyNode
->
pTspk
)
->
slotId
;
return
createIntervalOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
&
interval
,
primaryTsSlotId
,
pTableGroupInfo
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SORT
==
type
)
{
SSortPhysiNode
*
pSortPhyNode
=
(
SSortPhysiNode
*
)
pPhyNode
;
SSortPhysiNode
*
pSortPhyNode
=
(
SSortPhysiNode
*
)
pPhyNode
;
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SArray
*
info
=
createSortInfo
(
pSortPhyNode
->
pSortKeys
);
return
createSortOperatorInfo
(
op
,
pResBlock
,
info
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
==
nodeType
(
pPhyNode
))
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
SOperatorInfo
*
op
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
SArray
*
info
=
createSortInfo
(
pSortPhyNode
->
pSortKeys
);
return
createSortOperatorInfo
(
op
,
pResBlock
,
info
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
==
type
)
{
SSessionWinodwPhysiNode
*
pSessionNode
=
(
SSessionWinodwPhysiNode
*
)
pPhyNode
;
SSessionWinodwPhysiNode
*
pSessionNode
=
(
SSessionWinodwPhysiNode
*
)
pPhyNode
;
int32_t
num
=
0
;
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSessionNode
->
window
.
pFuncs
,
NULL
,
&
num
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSessionNode
->
window
.
pFuncs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
return
createSessionAggOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pSessionNode
->
gap
,
pTaskInfo
);
return
createSessionAggOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pSessionNode
->
gap
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_PARTITION
==
type
)
{
SPartitionPhysiNode
*
pPartNode
=
(
SPartitionPhysiNode
*
)
pPhyNode
;
SArray
*
pColList
=
extractPartitionColInfo
(
pPartNode
->
pPartitionKeys
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pPartNode
->
pTargets
,
NULL
,
&
num
);
return
createPartitionOperatorInfo
(
op
,
pExprInfo
,
num
,
pResBlock
,
pColList
,
pTaskInfo
,
NULL
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
/*else if (pPhyNode->info.type == OP_MultiTableAggregate) {
}
/*else if (pPhyNode->info.type == OP_MultiTableAggregate) {
...
@@ -7266,11 +7290,38 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
...
@@ -7266,11 +7290,38 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
STargetNode
*
pNode
=
(
STargetNode
*
)
nodesListGetNode
(
pNodeList
,
i
);
STargetNode
*
pNode
=
(
STargetNode
*
)
nodesListGetNode
(
pNodeList
,
i
);
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pNode
->
pExpr
;
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pNode
->
pExpr
;
// todo extract method
SColumn
c
=
{
0
};
SColumn
c
=
{
0
};
c
.
slotId
=
pColNode
->
slotId
;
c
.
slotId
=
pColNode
->
slotId
;
c
.
colId
=
pColNode
->
colId
;
c
.
colId
=
pColNode
->
colId
;
c
.
type
=
pColNode
->
node
.
resType
.
type
;
c
.
type
=
pColNode
->
node
.
resType
.
type
;
c
.
bytes
=
pColNode
->
node
.
resType
.
bytes
;
c
.
bytes
=
pColNode
->
node
.
resType
.
bytes
;
c
.
precision
=
pColNode
->
node
.
resType
.
precision
;
c
.
scale
=
pColNode
->
node
.
resType
.
scale
;
taosArrayPush
(
pList
,
&
c
);
}
return
pList
;
}
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
)
{
size_t
numOfCols
=
LIST_LENGTH
(
pNodeList
);
SArray
*
pList
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumn
));
if
(
pList
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
nodesListGetNode
(
pNodeList
,
i
);
// todo extract method
SColumn
c
=
{
0
};
c
.
slotId
=
pColNode
->
slotId
;
c
.
colId
=
pColNode
->
colId
;
c
.
type
=
pColNode
->
node
.
resType
.
type
;
c
.
bytes
=
pColNode
->
node
.
resType
.
bytes
;
c
.
precision
=
pColNode
->
node
.
resType
.
precision
;
c
.
precision
=
pColNode
->
node
.
resType
.
precision
;
c
.
scale
=
pColNode
->
node
.
resType
.
scale
;
c
.
scale
=
pColNode
->
node
.
resType
.
scale
;
...
@@ -7296,15 +7347,6 @@ SArray* createSortInfo(SNodeList* pNodeList) {
...
@@ -7296,15 +7347,6 @@ SArray* createSortInfo(SNodeList* pNodeList) {
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pSortKey
->
pExpr
;
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pSortKey
->
pExpr
;
bi
.
slotId
=
pColNode
->
slotId
;
bi
.
slotId
=
pColNode
->
slotId
;
// pColNode->order;
// SColumn c = {0};
// c.slotId = pColNode->slotId;
// c.colId = pColNode->colId;
// c.type = pColNode->node.resType.type;
// c.bytes = pColNode->node.resType.bytes;
// c.precision = pColNode->node.resType.precision;
// c.scale = pColNode->node.resType.scale;
taosArrayPush
(
pList
,
&
bi
);
taosArrayPush
(
pList
,
&
bi
);
}
}
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
a8f740bc
...
@@ -25,7 +25,11 @@
...
@@ -25,7 +25,11 @@
#include "thash.h"
#include "thash.h"
#include "ttypes.h"
#include "ttypes.h"
static
void
destroyGroupbyOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
static
int32_t
*
setupColumnOffset
(
const
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
);
static
void
*
getCurrentDataGroupInfo
(
const
SPartitionOperatorInfo
*
pInfo
,
SDataGroupInfo
**
pGroupInfo
,
int32_t
len
);
static
uint64_t
calcGroupId
(
char
*
pData
,
int32_t
len
);
static
void
destroyGroupOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SGroupbyOperatorInfo
*
pInfo
=
(
SGroupbyOperatorInfo
*
)
param
;
SGroupbyOperatorInfo
*
pInfo
=
(
SGroupbyOperatorInfo
*
)
param
;
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
taosMemoryFreeClear
(
pInfo
->
keyBuf
);
taosMemoryFreeClear
(
pInfo
->
keyBuf
);
...
@@ -33,44 +37,43 @@ static void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput) {
...
@@ -33,44 +37,43 @@ static void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput) {
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
}
}
static
int32_t
initGroupOptrInfo
(
S
GroupbyOperatorInfo
*
pInfo
,
SArray
*
pGroupColList
)
{
static
int32_t
initGroupOptrInfo
(
S
Array
**
pGroupColVals
,
int32_t
*
keyLen
,
char
**
keyBuf
,
const
SArray
*
pGroupColList
)
{
pInfo
->
pGroupColVals
=
taosArrayInit
(
4
,
sizeof
(
SGroupKeys
));
*
pGroupColVals
=
taosArrayInit
(
4
,
sizeof
(
SGroupKeys
));
if
(
pInfo
->
pGroupColVals
==
NULL
)
{
if
(
(
*
pGroupColVals
)
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
int32_t
numOfGroupCols
=
taosArrayGetSize
(
pGroupColList
);
int32_t
numOfGroupCols
=
taosArrayGetSize
(
pGroupColList
);
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGet
(
pGroupColList
,
i
);
SColumn
*
pCol
=
taosArrayGet
(
pGroupColList
,
i
);
pInfo
->
groupKeyLen
+=
pCol
->
bytes
;
(
*
keyLen
)
+=
pCol
->
bytes
;
struct
SGroupKeys
key
=
{
0
};
struct
SGroupKeys
key
=
{
0
};
key
.
bytes
=
pCol
->
bytes
;
key
.
bytes
=
pCol
->
bytes
;
key
.
type
=
pCol
->
type
;
key
.
type
=
pCol
->
type
;
key
.
isNull
=
false
;
key
.
isNull
=
false
;
key
.
pData
=
taosMemoryCalloc
(
1
,
pCol
->
bytes
);
key
.
pData
=
taosMemoryCalloc
(
1
,
pCol
->
bytes
);
if
(
key
.
pData
==
NULL
)
{
if
(
key
.
pData
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
taosArrayPush
(
pInfo
->
pGroupColVals
,
&
key
);
taosArrayPush
(
(
*
pGroupColVals
)
,
&
key
);
}
}
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
numOfGroupCols
;
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
numOfGroupCols
;
pInfo
->
keyBuf
=
taosMemoryCalloc
(
1
,
pInfo
->
groupKeyLen
+
nullFlagSize
);
if
(
pInfo
->
keyBuf
==
NULL
)
{
(
*
keyBuf
)
=
taosMemoryCalloc
(
1
,
(
*
keyLen
)
+
nullFlagSize
);
if
((
*
keyBuf
)
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
bool
groupKeyCompare
(
SGroupbyOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
static
bool
groupKeyCompare
(
SArray
*
pGroupCols
,
SArray
*
pGroupColVals
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
int32_t
numOfGroupCols
)
{
int32_t
numOfGroupCols
)
{
SColumnDataAgg
*
pColAgg
=
NULL
;
SColumnDataAgg
*
pColAgg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGet
(
p
Info
->
p
GroupCols
,
i
);
SColumn
*
pCol
=
taosArrayGet
(
pGroupCols
,
i
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pCol
->
slotId
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pCol
->
slotId
);
if
(
pBlock
->
pBlockAgg
!=
NULL
)
{
if
(
pBlock
->
pBlockAgg
!=
NULL
)
{
pColAgg
=
&
pBlock
->
pBlockAgg
[
pCol
->
slotId
];
// TODO is agg data matched?
pColAgg
=
&
pBlock
->
pBlockAgg
[
pCol
->
slotId
];
// TODO is agg data matched?
...
@@ -78,7 +81,7 @@ static bool groupKeyCompare(SGroupbyOperatorInfo* pInfo, SSDataBlock* pBlock, in
...
@@ -78,7 +81,7 @@ static bool groupKeyCompare(SGroupbyOperatorInfo* pInfo, SSDataBlock* pBlock, in
bool
isNull
=
colDataIsNull
(
pColInfoData
,
pBlock
->
info
.
rows
,
rowIndex
,
pColAgg
);
bool
isNull
=
colDataIsNull
(
pColInfoData
,
pBlock
->
info
.
rows
,
rowIndex
,
pColAgg
);
SGroupKeys
*
pkey
=
taosArrayGet
(
p
Info
->
p
GroupColVals
,
i
);
SGroupKeys
*
pkey
=
taosArrayGet
(
pGroupColVals
,
i
);
if
(
pkey
->
isNull
&&
isNull
)
{
if
(
pkey
->
isNull
&&
isNull
)
{
continue
;
continue
;
}
}
...
@@ -106,18 +109,18 @@ static bool groupKeyCompare(SGroupbyOperatorInfo* pInfo, SSDataBlock* pBlock, in
...
@@ -106,18 +109,18 @@ static bool groupKeyCompare(SGroupbyOperatorInfo* pInfo, SSDataBlock* pBlock, in
return
true
;
return
true
;
}
}
static
void
recordNewGroupKeys
(
S
GroupbyOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
int32_t
numOfGroupCols
)
{
static
void
recordNewGroupKeys
(
S
Array
*
pGroupCols
,
SArray
*
pGroupColVals
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
int32_t
numOfGroupCols
)
{
SColumnDataAgg
*
pColAgg
=
NULL
;
SColumnDataAgg
*
pColAgg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfGroupCols
;
++
i
)
{
SColumn
*
pCol
=
taosArrayGet
(
p
Info
->
p
GroupCols
,
i
);
SColumn
*
pCol
=
taosArrayGet
(
pGroupCols
,
i
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pCol
->
slotId
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pCol
->
slotId
);
if
(
pBlock
->
pBlockAgg
!=
NULL
)
{
if
(
pBlock
->
pBlockAgg
!=
NULL
)
{
pColAgg
=
&
pBlock
->
pBlockAgg
[
pCol
->
slotId
];
// TODO is agg data matched?
pColAgg
=
&
pBlock
->
pBlockAgg
[
pCol
->
slotId
];
// TODO is agg data matched?
}
}
SGroupKeys
*
pkey
=
taosArrayGet
(
p
Info
->
p
GroupColVals
,
i
);
SGroupKeys
*
pkey
=
taosArrayGet
(
pGroupColVals
,
i
);
if
(
colDataIsNull
(
pColInfoData
,
pBlock
->
info
.
rows
,
rowIndex
,
pColAgg
))
{
if
(
colDataIsNull
(
pColInfoData
,
pBlock
->
info
.
rows
,
rowIndex
,
pColAgg
))
{
pkey
->
isNull
=
true
;
pkey
->
isNull
=
true
;
}
else
{
}
else
{
...
@@ -197,13 +200,13 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
...
@@ -197,13 +200,13 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
// Compare with the previous row of this column, and do not set the output buffer again if they are identical.
if
(
!
pInfo
->
isInit
)
{
if
(
!
pInfo
->
isInit
)
{
recordNewGroupKeys
(
pInfo
,
pBlock
,
j
,
numOfGroupCols
);
recordNewGroupKeys
(
pInfo
->
pGroupCols
,
pInfo
->
pGroupColVals
,
pBlock
,
j
,
numOfGroupCols
);
pInfo
->
isInit
=
true
;
pInfo
->
isInit
=
true
;
num
++
;
num
++
;
continue
;
continue
;
}
}
bool
equal
=
groupKeyCompare
(
pInfo
,
pBlock
,
j
,
numOfGroupCols
);
bool
equal
=
groupKeyCompare
(
pInfo
->
pGroupCols
,
pInfo
->
pGroupColVals
,
pBlock
,
j
,
numOfGroupCols
);
if
(
equal
)
{
if
(
equal
)
{
num
++
;
num
++
;
continue
;
continue
;
...
@@ -212,7 +215,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
...
@@ -212,7 +215,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
// The first row of a new block does not belongs to the previous existed group
// The first row of a new block does not belongs to the previous existed group
if
(
!
equal
&&
j
==
0
)
{
if
(
!
equal
&&
j
==
0
)
{
num
++
;
num
++
;
recordNewGroupKeys
(
pInfo
,
pBlock
,
j
,
numOfGroupCols
);
recordNewGroupKeys
(
pInfo
->
pGroupCols
,
pInfo
->
pGroupColVals
,
pBlock
,
j
,
numOfGroupCols
);
continue
;
continue
;
}
}
...
@@ -227,7 +230,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
...
@@ -227,7 +230,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
// assign the group keys or user input constant values if required
// assign the group keys or user input constant values if required
doAssignGroupKeys
(
pCtx
,
pOperator
->
numOfOutput
,
pBlock
->
info
.
rows
,
rowIndex
);
doAssignGroupKeys
(
pCtx
,
pOperator
->
numOfOutput
,
pBlock
->
info
.
rows
,
rowIndex
);
recordNewGroupKeys
(
pInfo
,
pBlock
,
j
,
numOfGroupCols
);
recordNewGroupKeys
(
pInfo
->
pGroupCols
,
pInfo
->
pGroupColVals
,
pBlock
,
j
,
numOfGroupCols
);
num
=
1
;
num
=
1
;
}
}
...
@@ -259,7 +262,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
...
@@ -259,7 +262,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
if
(
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pInfo
->
groupResInfo
))
{
if
(
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pInfo
->
groupResInfo
))
{
pOperator
->
status
=
OP_EXEC_DONE
;
pOperator
->
status
=
OP_EXEC_DONE
;
}
}
return
pRes
;
return
(
pRes
->
info
.
rows
==
0
)
?
NULL
:
pRes
;
}
}
int32_t
order
=
TSDB_ORDER_ASC
;
int32_t
order
=
TSDB_ORDER_ASC
;
...
@@ -309,7 +312,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
...
@@ -309,7 +312,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator, bool* newgrou
}
}
}
}
return
pInfo
->
binfo
.
pRes
;
return
(
pRes
->
info
.
rows
==
0
)
?
NULL
:
pRes
;
}
}
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SNode
*
pCondition
,
SExecTaskInfo
*
pTaskInfo
,
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SNode
*
pCondition
,
SExecTaskInfo
*
pTaskInfo
,
...
@@ -325,7 +328,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -325,7 +328,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
4096
,
pResultBlock
,
pTaskInfo
->
id
.
str
);
initAggInfo
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
4096
,
pResultBlock
,
pTaskInfo
->
id
.
str
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
int32_t
code
=
initGroupOptrInfo
(
pInfo
,
pGroupColList
);
int32_t
code
=
initGroupOptrInfo
(
&
pInfo
->
pGroupColVals
,
&
pInfo
->
groupKeyLen
,
&
pInfo
->
keyBuf
,
pGroupColList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
...
@@ -339,7 +342,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -339,7 +342,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
_openFn
=
operatorDummyOpenFn
;
pOperator
->
_openFn
=
operatorDummyOpenFn
;
pOperator
->
getNextFn
=
hashGroupbyAggregate
;
pOperator
->
getNextFn
=
hashGroupbyAggregate
;
pOperator
->
closeFn
=
destroyGroup
by
OperatorInfo
;
pOperator
->
closeFn
=
destroyGroupOperatorInfo
;
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
return
pOperator
;
...
@@ -351,67 +354,263 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -351,67 +354,263 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
return
NULL
;
return
NULL
;
}
}
static
SSDataBlock
*
doPartitionData
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
static
void
doHashPartition
(
SOperatorInfo
*
pOperator
,
SSDataBlock
*
pBlock
)
{
// SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SPartitionOperatorInfo
*
pInfo
=
pOperator
->
info
;
int32_t
numOfGroupCols
=
taosArrayGetSize
(
pInfo
->
pGroupCols
);
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
recordNewGroupKeys
(
pInfo
->
pGroupCols
,
pInfo
->
pGroupColVals
,
pBlock
,
j
,
numOfGroupCols
);
int32_t
len
=
buildGroupKeys
(
pInfo
->
keyBuf
,
pInfo
->
pGroupColVals
);
SDataGroupInfo
*
pGInfo
=
NULL
;
void
*
pPage
=
getCurrentDataGroupInfo
(
pInfo
,
&
pGInfo
,
len
);
pGInfo
->
numOfRows
+=
1
;
if
(
pGInfo
->
groupId
==
0
)
{
pGInfo
->
groupId
=
calcGroupId
(
pInfo
->
keyBuf
,
len
);
}
int32_t
*
rows
=
(
int32_t
*
)
pPage
;
size_t
numOfCols
=
pOperator
->
numOfOutput
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SExprInfo
*
pExpr
=
&
pOperator
->
pExpr
[
i
];
int32_t
slotId
=
pExpr
->
base
.
pParam
[
0
].
pCol
->
slotId
;
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
int32_t
bytes
=
pColInfoData
->
info
.
bytes
;
int32_t
startOffset
=
pInfo
->
columnOffset
[
i
];
char
*
columnLen
=
NULL
;
int32_t
contentLen
=
0
;
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
int32_t
*
offset
=
pPage
+
startOffset
;
columnLen
=
pPage
+
startOffset
+
sizeof
(
int32_t
)
*
pInfo
->
rowCapacity
;
char
*
data
=
(
char
*
)(
columnLen
+
sizeof
(
int32_t
));
if
(
colDataIsNull_s
(
pColInfoData
,
j
))
{
offset
[(
*
rows
)]
=
-
1
;
contentLen
=
0
;
}
else
{
offset
[
*
rows
]
=
(
*
columnLen
);
char
*
src
=
colDataGetData
(
pColInfoData
,
j
);
memcpy
(
data
+
(
*
columnLen
),
src
,
varDataTLen
(
src
));
contentLen
=
varDataTLen
(
src
);
}
}
else
{
char
*
bitmap
=
pPage
+
startOffset
;
columnLen
=
pPage
+
startOffset
+
BitmapLen
(
pInfo
->
rowCapacity
);
char
*
data
=
(
char
*
)
columnLen
+
sizeof
(
int32_t
);
bool
isNull
=
colDataIsNull_f
(
pColInfoData
->
nullbitmap
,
j
);
if
(
isNull
)
{
colDataSetNull_f
(
bitmap
,
(
*
rows
));
}
else
{
memcpy
(
data
+
(
*
columnLen
),
colDataGetData
(
pColInfoData
,
j
),
bytes
);
}
contentLen
=
bytes
;
}
(
*
columnLen
)
+=
contentLen
;
}
(
*
rows
)
+=
1
;
setBufPageDirty
(
pPage
,
true
);
releaseBufPage
(
pInfo
->
pBuf
,
pPage
);
}
}
void
*
getCurrentDataGroupInfo
(
const
SPartitionOperatorInfo
*
pInfo
,
SDataGroupInfo
**
pGroupInfo
,
int32_t
len
)
{
SDataGroupInfo
*
p
=
taosHashGet
(
pInfo
->
pGroupSet
,
pInfo
->
keyBuf
,
len
);
void
*
pPage
=
NULL
;
if
(
p
==
NULL
)
{
// it is a new group
SDataGroupInfo
gi
=
{
0
};
gi
.
pPageList
=
taosArrayInit
(
100
,
sizeof
(
int32_t
));
taosHashPut
(
pInfo
->
pGroupSet
,
pInfo
->
keyBuf
,
len
,
&
gi
,
sizeof
(
SDataGroupInfo
));
p
=
taosHashGet
(
pInfo
->
pGroupSet
,
pInfo
->
keyBuf
,
len
);
int32_t
pageId
=
0
;
pPage
=
getNewBufPage
(
pInfo
->
pBuf
,
0
,
&
pageId
);
taosArrayPush
(
p
->
pPageList
,
&
pageId
);
*
(
int32_t
*
)
pPage
=
0
;
}
else
{
int32_t
*
curId
=
taosArrayGetLast
(
p
->
pPageList
);
pPage
=
getBufPage
(
pInfo
->
pBuf
,
*
curId
);
int32_t
*
rows
=
(
int32_t
*
)
pPage
;
if
(
*
rows
>=
pInfo
->
rowCapacity
)
{
// add a new page for current group
int32_t
pageId
=
0
;
pPage
=
getNewBufPage
(
pInfo
->
pBuf
,
0
,
&
pageId
);
taosArrayPush
(
p
->
pPageList
,
&
pageId
);
*
(
int32_t
*
)
pPage
=
0
;
}
}
*
pGroupInfo
=
p
;
return
pPage
;
}
uint64_t
calcGroupId
(
char
*
pData
,
int32_t
len
)
{
T_MD5_CTX
context
;
tMD5Init
(
&
context
);
tMD5Update
(
&
context
,
(
uint8_t
*
)
pData
,
len
);
tMD5Final
(
&
context
);
// NOTE: only extract the initial 8 bytes of the final MD5 digest
uint64_t
id
=
0
;
memcpy
(
&
id
,
context
.
digest
,
sizeof
(
uint64_t
));
return
id
;
}
int32_t
*
setupColumnOffset
(
const
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
)
{
size_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
int32_t
*
offset
=
taosMemoryCalloc
(
pBlock
->
info
.
numOfCols
,
sizeof
(
int32_t
));
offset
[
0
]
=
sizeof
(
int32_t
);
// the number of rows in current page, ref to SSDataBlock paged serialization format
for
(
int32_t
i
=
0
;
i
<
numOfCols
-
1
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
int32_t
bytes
=
pColInfoData
->
info
.
bytes
;
int32_t
payloadLen
=
bytes
*
rowCapacity
;
if
(
IS_VAR_DATA_TYPE
(
pColInfoData
->
info
.
type
))
{
// offset segment + content length + payload
offset
[
i
+
1
]
=
rowCapacity
*
sizeof
(
int32_t
)
+
sizeof
(
int32_t
)
+
payloadLen
+
offset
[
i
];
}
else
{
// bitmap + content length + payload
offset
[
i
+
1
]
=
BitmapLen
(
rowCapacity
)
+
sizeof
(
int32_t
)
+
payloadLen
+
offset
[
i
];
}
}
return
offset
;
}
static
SSDataBlock
*
buildPartitionResult
(
SOperatorInfo
*
pOperator
)
{
SPartitionOperatorInfo
*
pInfo
=
pOperator
->
info
;
SDataGroupInfo
*
pGroupInfo
=
pInfo
->
pGroupIter
;
if
(
pInfo
->
pGroupIter
==
NULL
||
pInfo
->
pageIndex
>=
taosArrayGetSize
(
pGroupInfo
->
pPageList
))
{
// try next group data
pInfo
->
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
pInfo
->
pGroupIter
);
if
(
pInfo
->
pGroupIter
==
NULL
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
return
NULL
;
}
pGroupInfo
=
pInfo
->
pGroupIter
;
pInfo
->
pageIndex
=
0
;
}
int32_t
*
pageId
=
taosArrayGet
(
pGroupInfo
->
pPageList
,
pInfo
->
pageIndex
);
void
*
page
=
getBufPage
(
pInfo
->
pBuf
,
*
pageId
);
blockDataFromBuf1
(
pInfo
->
binfo
.
pRes
,
page
,
pInfo
->
rowCapacity
);
pInfo
->
pageIndex
+=
1
;
pInfo
->
binfo
.
pRes
->
info
.
groupId
=
pGroupInfo
->
groupId
;
return
pInfo
->
binfo
.
pRes
;
}
static
SSDataBlock
*
hashPartition
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
return
NULL
;
}
}
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SGroupbyOperatorInfo
*
pInfo
=
pOperator
->
info
;
SSortOperatorInfo
*
pInfo
=
pOperator
->
info
;
SSDataBlock
*
pRes
=
pInfo
->
binfo
.
pRes
;
bool
hasVarCol
=
pInfo
->
pDataBlock
->
info
.
hasVarCol
;
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
return
getSortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
pDataBlock
,
pInfo
->
numOfRowsInRes
);
blockDataCleanup
(
pRes
);
return
buildPartitionResult
(
pOperator
);
}
}
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
SORT_SINGLESOURCE_SORT
,
pInfo
->
bufPageSize
,
numOfBufPage
,
pInfo
->
pDataBlock
,
pTaskInfo
->
id
.
str
);
tsortSetFetchRawDataFp
(
pInfo
->
pSortHandle
,
loadNextDataBlock
);
SGenericSource
*
ps
=
taosMemoryCalloc
(
1
,
sizeof
(
SGenericSource
));
while
(
1
)
{
ps
->
param
=
pOperator
->
pDownstream
[
0
];
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
tsortAddSource
(
pInfo
->
pSortHandle
,
ps
);
SSDataBlock
*
pBlock
=
downstream
->
getNextFn
(
downstream
,
newgroup
);
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
if
(
pBlock
==
NULL
)
{
break
;
}
int32_t
code
=
tsortOpen
(
pInfo
->
pSortHandle
);
// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->binfo.pCtx, pOperator->numOfOutput);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
doHashPartition
(
pOperator
,
pBlock
);
longjmp
(
pTaskInfo
->
env
,
terrno
);
}
}
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
return
getSortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
pDataBlock
,
pInfo
->
numOfRowsInRes
);
blockDataEnsureCapacity
(
pRes
,
4096
);
return
buildPartitionResult
(
pOperator
);
}
}
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SSDataBlock
*
pResultBlock
,
SArray
*
pSortInfo
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
)
{
static
void
destroyPartitionOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SSortOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SSortOperatorInfo
));
SPartitionOperatorInfo
*
pInfo
=
(
SPartitionOperatorInfo
*
)
param
;
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
taosArrayDestroy
(
pInfo
->
pGroupCols
);
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
taosMemoryFree
(
pInfo
->
keyBuf
);
taosMemoryFree
(
pInfo
->
columnOffset
);
}
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
)
{
SPartitionOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SPartitionOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
goto
_error
;
}
}
pInfo
->
sortBufSize
=
1024
*
16
;
// TODO dynamic set the available sort buffer
pInfo
->
pGroupCols
=
pGroupColList
;
pInfo
->
bufPageSize
=
1024
;
pInfo
->
numOfRowsInRes
=
1024
;
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pInfo
->
pDataBlock
=
pResultBlock
;
pInfo
->
pGroupSet
=
taosHashInit
(
100
,
hashFn
,
false
,
HASH_NO_LOCK
);
pInfo
->
pSortInfo
=
pSortInfo
;
if
(
pInfo
->
pGroupSet
==
NULL
)
{
goto
_error
;
}
int32_t
code
=
createDiskbasedBuf
(
&
pInfo
->
pBuf
,
4096
,
4096
*
256
,
pTaskInfo
->
id
.
str
,
"/tmp/"
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pInfo
->
rowCapacity
=
blockDataGetCapacityInRow
(
pResultBlock
,
getBufPageSize
(
pInfo
->
pBuf
));
pInfo
->
columnOffset
=
setupColumnOffset
(
pResultBlock
,
pInfo
->
rowCapacity
);
code
=
initGroupOptrInfo
(
&
pInfo
->
pGroupColVals
,
&
pInfo
->
groupKeyLen
,
&
pInfo
->
keyBuf
,
pGroupColList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pOperator
->
name
=
"PartitionOperator"
;
pOperator
->
name
=
"PartitionOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PARTITION
;
pOperator
->
blockingOptr
=
true
;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PARTITION
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pInfo
->
binfo
.
pRes
=
pResultBlock
;
pOperator
->
getNextFn
=
doPartitionData
;
pOperator
->
numOfOutput
=
numOfCols
;
// pOperator->closeFn = destroyOrderOperatorInfo;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
_openFn
=
operatorDummyOpenFn
;
pOperator
->
getNextFn
=
hashPartition
;
pOperator
->
closeFn
=
destroyPartitionOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
return
pOperator
;
_error:
_error:
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
taosMemoryFree
(
pInfo
);
taosMemoryFree
Clear
(
pInfo
);
taosMemoryFree
(
pOperator
);
taosMemoryFree
Clear
(
pOperator
);
return
NULL
;
return
NULL
;
}
}
\ No newline at end of file
source/libs/executor/src/scanoperator.c
浏览文件 @
a8f740bc
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include "query.h"
#include "query.h"
#include "tcompare.h"
#include "tcompare.h"
#include "thash.h"
#include "thash.h"
#include "
tsdb
.h"
#include "
vnode
.h"
#include "ttypes.h"
#include "ttypes.h"
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
#define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN)
...
...
source/libs/executor/src/tsort.c
浏览文件 @
a8f740bc
...
@@ -425,9 +425,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -425,9 +425,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
qDebug
(
"%s %d rounds mergesort required to complete the sort, first-round sorted data size:%"
PRIzu
", sort:%"
PRId64
", total elapsed:%"
PRId64
,
qDebug
(
"%s %d rounds mergesort required to complete the sort, first-round sorted data size:%"
PRIzu
", sort:%"
PRId64
", total elapsed:%"
PRId64
,
pHandle
->
idStr
,
(
int32_t
)
(
sortPass
+
1
),
getTotalBufSize
(
pHandle
->
pBuf
),
pHandle
->
sortElapsed
,
pHandle
->
totalElapsed
);
pHandle
->
idStr
,
(
int32_t
)
(
sortPass
+
1
),
getTotalBufSize
(
pHandle
->
pBuf
),
pHandle
->
sortElapsed
,
pHandle
->
totalElapsed
);
size_t
pgSize
=
pHandle
->
pageSize
;
int32_t
numOfRows
=
blockDataGetCapacityInRow
(
pHandle
->
pDataBlock
,
pHandle
->
pageSize
);
int32_t
numOfRows
=
(
pgSize
-
blockDataGetSerialMetaSize
(
pHandle
->
pDataBlock
))
/
blockDataGetSerialRowSize
(
pHandle
->
pDataBlock
);
blockDataEnsureCapacity
(
pHandle
->
pDataBlock
,
numOfRows
);
blockDataEnsureCapacity
(
pHandle
->
pDataBlock
,
numOfRows
);
size_t
numOfSorted
=
taosArrayGetSize
(
pHandle
->
pOrderedSource
);
size_t
numOfSorted
=
taosArrayGetSize
(
pHandle
->
pOrderedSource
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
a8f740bc
...
@@ -1578,7 +1578,7 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) {
...
@@ -1578,7 +1578,7 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) {
case
TSDB_DATA_TYPE_NULL
:
case
TSDB_DATA_TYPE_NULL
:
break
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
code
=
tjsonAdd
Integer
ToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
b
);
code
=
tjsonAdd
Bool
ToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
b
);
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
a8f740bc
...
@@ -644,7 +644,7 @@ SNodeList* nodesMakeList() {
...
@@ -644,7 +644,7 @@ SNodeList* nodesMakeList() {
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
if
(
NULL
==
pList
||
NULL
==
pNode
)
{
if
(
NULL
==
pList
||
NULL
==
pNode
)
{
return
TSDB_CODE_
SUCCESS
;
return
TSDB_CODE_
FAILED
;
}
}
SListCell
*
p
=
taosMemoryCalloc
(
1
,
sizeof
(
SListCell
));
SListCell
*
p
=
taosMemoryCalloc
(
1
,
sizeof
(
SListCell
));
if
(
NULL
==
p
)
{
if
(
NULL
==
p
)
{
...
@@ -688,7 +688,7 @@ int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) {
...
@@ -688,7 +688,7 @@ int32_t nodesListMakeAppend(SNodeList** pList, SNodeptr pNode) {
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
return
TSDB_CODE_
SUCCESS
;
return
TSDB_CODE_
FAILED
;
}
}
if
(
NULL
==
pTarget
->
pHead
)
{
if
(
NULL
==
pTarget
->
pHead
)
{
...
@@ -717,11 +717,34 @@ int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc) {
...
@@ -717,11 +717,34 @@ int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc) {
return
code
;
return
code
;
}
}
int32_t
nodesListPushFront
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
if
(
NULL
==
pList
||
NULL
==
pNode
)
{
return
TSDB_CODE_FAILED
;
}
SListCell
*
p
=
taosMemoryCalloc
(
1
,
sizeof
(
SListCell
));
if
(
NULL
==
p
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
pNode
=
pNode
;
if
(
NULL
!=
pList
->
pHead
)
{
pList
->
pHead
->
pPrev
=
p
;
p
->
pNext
=
pList
->
pHead
;
}
pList
->
pHead
=
p
;
++
(
pList
->
length
);
return
TSDB_CODE_SUCCESS
;
}
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
)
{
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
)
{
if
(
NULL
==
pCell
->
pPrev
)
{
if
(
NULL
==
pCell
->
pPrev
)
{
pList
->
pHead
=
pCell
->
pNext
;
pList
->
pHead
=
pCell
->
pNext
;
}
else
{
}
else
{
pCell
->
pPrev
->
pNext
=
pCell
->
pNext
;
pCell
->
pPrev
->
pNext
=
pCell
->
pNext
;
}
if
(
NULL
==
pCell
->
pNext
)
{
pList
->
pTail
=
pCell
->
pPrev
;
}
else
{
pCell
->
pNext
->
pPrev
=
pCell
->
pPrev
;
pCell
->
pNext
->
pPrev
=
pCell
->
pPrev
;
}
}
SListCell
*
pNext
=
pCell
->
pNext
;
SListCell
*
pNext
=
pCell
->
pNext
;
...
@@ -731,6 +754,24 @@ SListCell* nodesListErase(SNodeList* pList, SListCell* pCell) {
...
@@ -731,6 +754,24 @@ SListCell* nodesListErase(SNodeList* pList, SListCell* pCell) {
return
pNext
;
return
pNext
;
}
}
void
nodesListInsertList
(
SNodeList
*
pTarget
,
SListCell
*
pPos
,
SNodeList
*
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pPos
||
NULL
==
pSrc
)
{
return
;
}
if
(
NULL
==
pPos
->
pPrev
)
{
pTarget
->
pHead
=
pSrc
->
pHead
;
}
else
{
pPos
->
pPrev
->
pNext
=
pSrc
->
pHead
;
}
pSrc
->
pHead
->
pPrev
=
pPos
->
pPrev
;
pSrc
->
pTail
->
pNext
=
pPos
;
pPos
->
pPrev
=
pSrc
->
pTail
;
pTarget
->
length
+=
pSrc
->
length
;
taosMemoryFreeClear
(
pSrc
);
}
SNodeptr
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
)
{
SNodeptr
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
)
{
SNode
*
node
;
SNode
*
node
;
FOREACH
(
node
,
pList
)
{
FOREACH
(
node
,
pList
)
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
a8f740bc
...
@@ -376,8 +376,9 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
...
@@ -376,8 +376,9 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
}
}
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
uint8_t
precision
=
(
NULL
!=
pCxt
->
pCurrStmt
?
pCxt
->
pCurrStmt
->
precision
:
pVal
->
node
.
resType
.
precision
);
if
(
pVal
->
isDuration
)
{
if
(
pVal
->
isDuration
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
p
Val
->
node
.
resType
.
p
recision
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
}
}
else
{
}
else
{
...
@@ -421,7 +422,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
...
@@ -421,7 +422,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
break
;
break
;
}
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
if
(
taosParseTime
(
pVal
->
literal
,
&
pVal
->
datum
.
i
,
pVal
->
node
.
resType
.
bytes
,
p
Val
->
node
.
resType
.
p
recision
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
pVal
->
literal
,
&
pVal
->
datum
.
i
,
pVal
->
node
.
resType
.
bytes
,
precision
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
}
break
;
break
;
...
@@ -683,6 +684,19 @@ static int32_t setTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTa
...
@@ -683,6 +684,19 @@ static int32_t setTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTa
return
code
;
return
code
;
}
}
static
uint8_t
getStmtPrecision
(
SNode
*
pStmt
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
return
((
SSelectStmt
*
)
pStmt
)
->
precision
;
}
return
0
;
}
static
uint8_t
getJoinTablePrecision
(
SJoinTableNode
*
pJoinTable
)
{
uint8_t
lp
=
((
STableNode
*
)
pJoinTable
->
pLeft
)
->
precision
;
uint8_t
rp
=
((
STableNode
*
)
pJoinTable
->
pRight
)
->
precision
;
return
(
lp
>
rp
?
rp
:
lp
);
}
static
int32_t
translateTable
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
static
int32_t
translateTable
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pTable
))
{
switch
(
nodeType
(
pTable
))
{
...
@@ -695,6 +709,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -695,6 +709,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pRealTable
->
table
.
tableName
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pRealTable
->
table
.
tableName
);
}
}
pRealTable
->
table
.
precision
=
pRealTable
->
pMeta
->
tableInfo
.
precision
;
code
=
setTableVgroupList
(
pCxt
,
&
name
,
pRealTable
);
code
=
setTableVgroupList
(
pCxt
,
&
name
,
pRealTable
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addNamespace
(
pCxt
,
pRealTable
);
code
=
addNamespace
(
pCxt
,
pRealTable
);
...
@@ -705,6 +720,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -705,6 +720,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
STempTableNode
*
pTempTable
=
(
STempTableNode
*
)
pTable
;
STempTableNode
*
pTempTable
=
(
STempTableNode
*
)
pTable
;
code
=
translateSubquery
(
pCxt
,
pTempTable
->
pSubquery
);
code
=
translateSubquery
(
pCxt
,
pTempTable
->
pSubquery
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pTempTable
->
table
.
precision
=
getStmtPrecision
(
pTempTable
->
pSubquery
);
code
=
addNamespace
(
pCxt
,
pTempTable
);
code
=
addNamespace
(
pCxt
,
pTempTable
);
}
}
break
;
break
;
...
@@ -716,6 +732,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -716,6 +732,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
code
=
translateTable
(
pCxt
,
pJoinTable
->
pRight
);
code
=
translateTable
(
pCxt
,
pJoinTable
->
pRight
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pJoinTable
->
table
.
precision
=
getJoinTablePrecision
(
pJoinTable
);
code
=
translateExpr
(
pCxt
,
pJoinTable
->
pOnCond
);
code
=
translateExpr
(
pCxt
,
pJoinTable
->
pOnCond
);
}
}
break
;
break
;
...
@@ -726,24 +743,99 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -726,24 +743,99 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
return
code
;
return
code
;
}
}
static
int32_t
translateStar
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
,
bool
*
pIsSelectStar
)
{
static
int32_t
createAllColumns
(
STranslateContext
*
pCxt
,
SNodeList
**
pCols
)
{
if
(
NULL
==
pSelect
->
pProjectionList
)
{
// select * ...
*
pCols
=
nodesMakeList
();
SArray
*
pTables
=
taosArrayGetP
(
pCxt
->
pNsLevel
,
pCxt
->
currLevel
);
if
(
NULL
==
*
pCols
)
{
size_t
nums
=
taosArrayGetSize
(
pTables
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
pSelect
->
pProjectionList
=
nodesMakeList
();
}
if
(
NULL
==
pSelect
->
pProjectionList
)
{
SArray
*
pTables
=
taosArrayGetP
(
pCxt
->
pNsLevel
,
pCxt
->
currLevel
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
);
size_t
nums
=
taosArrayGetSize
(
pTables
);
}
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
int32_t
code
=
createColumnNodeByTable
(
pCxt
,
pTable
,
*
pCols
);
int32_t
code
=
createColumnNodeByTable
(
pCxt
,
pTable
,
pSelect
->
pProjectionList
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
}
}
}
return
TSDB_CODE_SUCCESS
;
}
static
bool
isFirstLastFunc
(
SFunctionNode
*
pFunc
)
{
return
(
FUNCTION_TYPE_FIRST
==
pFunc
->
funcType
||
FUNCTION_TYPE_LAST
==
pFunc
->
funcType
);
}
static
bool
isFirstLastStar
(
SNode
*
pNode
)
{
if
(
QUERY_NODE_FUNCTION
!=
nodeType
(
pNode
)
||
!
isFirstLastFunc
((
SFunctionNode
*
)
pNode
))
{
return
false
;
}
SNodeList
*
pParameterList
=
((
SFunctionNode
*
)
pNode
)
->
pParameterList
;
if
(
LIST_LENGTH
(
pParameterList
)
!=
1
)
{
return
false
;
}
SNode
*
pParam
=
nodesListGetNode
(
pParameterList
,
0
);
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pParam
)
?
0
==
strcmp
(((
SColumnNode
*
)
pParam
)
->
colName
,
"*"
)
:
false
);
}
static
SNode
*
createFirstLastFunc
(
SFunctionNode
*
pSrcFunc
,
SColumnNode
*
pCol
)
{
SFunctionNode
*
pFunc
=
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
return
NULL
;
}
pFunc
->
pParameterList
=
nodesMakeList
();
if
(
NULL
==
pFunc
->
pParameterList
||
TSDB_CODE_SUCCESS
!=
nodesListAppend
(
pFunc
->
pParameterList
,
pCol
))
{
nodesDestroyNode
(
pFunc
);
return
NULL
;
}
pFunc
->
node
.
resType
=
pCol
->
node
.
resType
;
pFunc
->
funcId
=
pSrcFunc
->
funcId
;
pFunc
->
funcType
=
pSrcFunc
->
funcType
;
strcpy
(
pFunc
->
functionName
,
pSrcFunc
->
functionName
);
snprintf
(
pFunc
->
node
.
aliasName
,
sizeof
(
pFunc
->
node
.
aliasName
),
(
FUNCTION_TYPE_FIRST
==
pSrcFunc
->
funcType
?
"first(%s)"
:
"last(%s)"
),
pCol
->
colName
);
return
(
SNode
*
)
pFunc
;
}
static
int32_t
createFirstLastAllCols
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pSrcFunc
,
SNodeList
**
pOutput
)
{
SNodeList
*
pCols
=
NULL
;
if
(
TSDB_CODE_SUCCESS
!=
createAllColumns
(
pCxt
,
&
pCols
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SNodeList
*
pFuncs
=
nodesMakeList
();
if
(
NULL
==
pFuncs
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SNode
*
pCol
=
NULL
;
FOREACH
(
pCol
,
pCols
)
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
pFuncs
,
createFirstLastFunc
(
pSrcFunc
,
(
SColumnNode
*
)
pCol
)))
{
nodesDestroyNode
(
pFuncs
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
*
pIsSelectStar
=
true
;
}
*
pOutput
=
pFuncs
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateStar
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
NULL
==
pSelect
->
pProjectionList
)
{
// select * ...
return
createAllColumns
(
pCxt
,
&
pSelect
->
pProjectionList
);
}
else
{
}
else
{
// todo : t.*
// todo : t.*
SNode
*
pNode
=
NULL
;
WHERE_EACH
(
pNode
,
pSelect
->
pProjectionList
)
{
if
(
isFirstLastStar
(
pNode
))
{
SNodeList
*
pFuncs
=
NULL
;
if
(
TSDB_CODE_SUCCESS
!=
createFirstLastAllCols
(
pCxt
,
(
SFunctionNode
*
)
pNode
,
&
pFuncs
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
INSERT_LIST
(
pSelect
->
pProjectionList
,
pFuncs
);
ERASE_NODE
(
pSelect
->
pProjectionList
);
continue
;
}
WHERE_NEXT
;
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -780,8 +872,8 @@ static int32_t getPositionValue(const SValueNode* pVal) {
...
@@ -780,8 +872,8 @@ static int32_t getPositionValue(const SValueNode* pVal) {
static
int32_t
translateOrderByPosition
(
STranslateContext
*
pCxt
,
SNodeList
*
pProjectionList
,
SNodeList
*
pOrderByList
,
bool
*
pOther
)
{
static
int32_t
translateOrderByPosition
(
STranslateContext
*
pCxt
,
SNodeList
*
pProjectionList
,
SNodeList
*
pOrderByList
,
bool
*
pOther
)
{
*
pOther
=
false
;
*
pOther
=
false
;
SNode
*
pNode
;
SNode
*
pNode
=
NULL
;
FOR
EACH
(
pNode
,
pOrderByList
)
{
WHERE_
EACH
(
pNode
,
pOrderByList
)
{
SNode
*
pExpr
=
((
SOrderByExprNode
*
)
pNode
)
->
pExpr
;
SNode
*
pExpr
=
((
SOrderByExprNode
*
)
pNode
)
->
pExpr
;
if
(
QUERY_NODE_VALUE
==
nodeType
(
pExpr
))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pExpr
))
{
SValueNode
*
pVal
=
(
SValueNode
*
)
pExpr
;
SValueNode
*
pVal
=
(
SValueNode
*
)
pExpr
;
...
@@ -806,6 +898,7 @@ static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pPro
...
@@ -806,6 +898,7 @@ static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pPro
}
else
{
}
else
{
*
pOther
=
true
;
*
pOther
=
true
;
}
}
WHERE_NEXT
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -828,11 +921,10 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -828,11 +921,10 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
}
}
static
int32_t
translateSelectList
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
static
int32_t
translateSelectList
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
bool
isSelectStar
=
false
;
pCxt
->
currClause
=
SQL_CLAUSE_SELECT
;
int32_t
code
=
translateStar
(
pCxt
,
pSelect
,
&
isSelectStar
);
int32_t
code
=
translateExprList
(
pCxt
,
pSelect
->
pProjectionList
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
isSelectStar
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pCxt
->
currClause
=
SQL_CLAUSE_SELECT
;
code
=
translateStar
(
pCxt
,
pSelect
);
code
=
translateExprList
(
pCxt
,
pSelect
->
pProjectionList
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkExprListForGroupBy
(
pCxt
,
pSelect
->
pProjectionList
);
code
=
checkExprListForGroupBy
(
pCxt
,
pSelect
->
pProjectionList
);
...
@@ -852,9 +944,12 @@ static int32_t translateHaving(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -852,9 +944,12 @@ static int32_t translateHaving(STranslateContext* pCxt, SSelectStmt* pSelect) {
return
code
;
return
code
;
}
}
static
int32_t
translateGroupBy
(
STranslateContext
*
pCxt
,
SNodeList
*
pGroupByList
)
{
static
int32_t
translateGroupBy
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
(
NULL
!=
pSelect
->
pGroupByList
&&
NULL
!=
pSelect
->
pWindow
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST
);
}
pCxt
->
currClause
=
SQL_CLAUSE_GROUP_BY
;
pCxt
->
currClause
=
SQL_CLAUSE_GROUP_BY
;
return
translateExprList
(
pCxt
,
pGroupByList
);
return
translateExprList
(
pCxt
,
p
Select
->
p
GroupByList
);
}
}
static
int32_t
translateIntervalWindow
(
STranslateContext
*
pCxt
,
SIntervalWindowNode
*
pInterval
)
{
static
int32_t
translateIntervalWindow
(
STranslateContext
*
pCxt
,
SIntervalWindowNode
*
pInterval
)
{
...
@@ -899,14 +994,18 @@ static int32_t translateWhere(STranslateContext* pCxt, SNode* pWhere) {
...
@@ -899,14 +994,18 @@ static int32_t translateWhere(STranslateContext* pCxt, SNode* pWhere) {
return
translateExpr
(
pCxt
,
pWhere
);
return
translateExpr
(
pCxt
,
pWhere
);
}
}
static
int32_t
translateFrom
(
STranslateContext
*
pCxt
,
S
Node
*
pTable
)
{
static
int32_t
translateFrom
(
STranslateContext
*
pCxt
,
S
SelectStmt
*
pSelect
)
{
pCxt
->
currClause
=
SQL_CLAUSE_FROM
;
pCxt
->
currClause
=
SQL_CLAUSE_FROM
;
return
translateTable
(
pCxt
,
pTable
);
int32_t
code
=
translateTable
(
pCxt
,
pSelect
->
pFromTable
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pSelect
->
precision
=
((
STableNode
*
)
pSelect
->
pFromTable
)
->
precision
;
}
return
code
;
}
}
static
int32_t
translateSelect
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
static
int32_t
translateSelect
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
pCxt
->
pCurrStmt
=
pSelect
;
pCxt
->
pCurrStmt
=
pSelect
;
int32_t
code
=
translateFrom
(
pCxt
,
pSelect
->
pFromTable
);
int32_t
code
=
translateFrom
(
pCxt
,
pSelect
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateWhere
(
pCxt
,
pSelect
->
pWhere
);
code
=
translateWhere
(
pCxt
,
pSelect
->
pWhere
);
}
}
...
@@ -917,7 +1016,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -917,7 +1016,7 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
code
=
translateWindow
(
pCxt
,
pSelect
->
pWindow
);
code
=
translateWindow
(
pCxt
,
pSelect
->
pWindow
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateGroupBy
(
pCxt
,
pSelect
->
pGroupByList
);
code
=
translateGroupBy
(
pCxt
,
pSelect
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateHaving
(
pCxt
,
pSelect
);
code
=
translateHaving
(
pCxt
,
pSelect
);
...
@@ -1807,10 +1906,13 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
...
@@ -1807,10 +1906,13 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
pSelect
->
pFromTable
=
(
SNode
*
)
pTable
;
pSelect
->
pFromTable
=
(
SNode
*
)
pTable
;
pSelect
->
pProjectionList
=
nodesCloneList
(
pStmt
->
pOptions
->
pFuncs
);
pSelect
->
pProjectionList
=
nodesCloneList
(
pStmt
->
pOptions
->
pFuncs
);
if
(
NULL
==
pTable
)
{
SFunctionNode
*
pFunc
=
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pSelect
->
pProjectionList
||
NULL
==
pFunc
)
{
nodesDestroyNode
(
pSelect
);
nodesDestroyNode
(
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
strcpy
(
pFunc
->
functionName
,
"_wstartts"
);
nodesListPushFront
(
pSelect
->
pProjectionList
,
pFunc
);
SNode
*
pProject
=
NULL
;
SNode
*
pProject
=
NULL
;
FOREACH
(
pProject
,
pSelect
->
pProjectionList
)
{
FOREACH
(
pProject
,
pSelect
->
pProjectionList
)
{
sprintf
(((
SExprNode
*
)
pProject
)
->
aliasName
,
"#sma_%p"
,
pProject
);
sprintf
(((
SExprNode
*
)
pProject
)
->
aliasName
,
"#sma_%p"
,
pProject
);
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
a8f740bc
...
@@ -89,6 +89,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -89,6 +89,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"invalid option rollup: only one function is allowed"
;
return
"invalid option rollup: only one function is allowed"
;
case
TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION
:
case
TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION
:
return
"invalid option retentions"
;
return
"invalid option retentions"
;
case
TSDB_CODE_PAR_GROUPBY_WINDOW_COEXIST
:
return
"GROUP BY and WINDOW-clause can't be used together"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
a8f740bc
...
@@ -267,7 +267,7 @@ static void trtrim(char *input, char *output, int32_t type, int32_t charLen) {
...
@@ -267,7 +267,7 @@ static void trtrim(char *input, char *output, int32_t type, int32_t charLen) {
numOfSpaces
++
;
numOfSpaces
++
;
}
}
}
else
{
//NCHAR
}
else
{
//NCHAR
for
(
int32_t
i
=
charLen
-
1
;
i
<
charLen
;
++
i
)
{
for
(
int32_t
i
=
charLen
-
1
;
i
>=
0
;
--
i
)
{
if
(
!
iswspace
(
*
((
uint32_t
*
)
varDataVal
(
input
)
+
i
)))
{
if
(
!
iswspace
(
*
((
uint32_t
*
)
varDataVal
(
input
)
+
i
)))
{
break
;
break
;
}
}
...
@@ -295,11 +295,11 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
...
@@ -295,11 +295,11 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
char
*
in
=
pInputData
->
pData
;
char
*
in
=
pInputData
->
pData
+
pInputData
->
varmeta
.
offset
[
0
]
;
int16_t
*
out
=
(
int16_t
*
)
pOutputData
->
pData
;
int16_t
*
out
=
(
int16_t
*
)
pOutputData
->
pData
;
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
if
(
colDataIsNull_
f
(
pInputData
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_
s
(
pInputData
,
i
))
{
colDataSetNull_f
(
pOutputData
->
nullbitmap
,
i
);
colDataSetNull_f
(
pOutputData
->
nullbitmap
,
i
);
continue
;
continue
;
}
}
...
@@ -357,7 +357,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -357,7 +357,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
}
}
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
input
[
i
]
=
pInputData
[
i
]
->
pData
;
input
[
i
]
=
pInputData
[
i
]
->
pData
+
pInputData
[
i
]
->
varmeta
.
offset
[
0
]
;
int32_t
factor
=
1
;
int32_t
factor
=
1
;
if
(
hasNcharCol
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
if
(
hasNcharCol
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
factor
=
TSDB_NCHAR_SIZE
;
factor
=
TSDB_NCHAR_SIZE
;
...
@@ -438,7 +438,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -438,7 +438,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
}
}
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
input
[
i
]
=
pInputData
[
i
]
->
pData
;
input
[
i
]
=
pInputData
[
i
]
->
pData
+
pInputData
[
i
]
->
varmeta
.
offset
[
0
]
;
int32_t
factor
=
1
;
int32_t
factor
=
1
;
if
(
hasNcharCol
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
if
(
hasNcharCol
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
factor
=
TSDB_NCHAR_SIZE
;
factor
=
TSDB_NCHAR_SIZE
;
...
@@ -509,7 +509,7 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala
...
@@ -509,7 +509,7 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
char
*
input
=
pInputData
->
pData
;
char
*
input
=
pInputData
->
pData
+
pInputData
->
varmeta
.
offset
[
0
]
;
char
*
output
=
NULL
;
char
*
output
=
NULL
;
int32_t
outputLen
=
pInputData
->
varmeta
.
length
;
int32_t
outputLen
=
pInputData
->
varmeta
.
length
;
...
@@ -554,7 +554,7 @@ static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarPar
...
@@ -554,7 +554,7 @@ static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarPar
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
char
*
input
=
pInputData
->
pData
;
char
*
input
=
pInputData
->
pData
+
pInputData
->
varmeta
.
offset
[
0
]
;
char
*
output
=
NULL
;
char
*
output
=
NULL
;
int32_t
outputLen
=
pInputData
->
varmeta
.
length
;
int32_t
outputLen
=
pInputData
->
varmeta
.
length
;
...
@@ -606,7 +606,7 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -606,7 +606,7 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
char
*
input
=
pInputData
->
pData
;
char
*
input
=
pInputData
->
pData
+
pInputData
->
varmeta
.
offset
[
0
]
;
char
*
output
=
NULL
;
char
*
output
=
NULL
;
int32_t
outputLen
=
pInputData
->
varmeta
.
length
*
pInput
->
numOfRows
;
int32_t
outputLen
=
pInputData
->
varmeta
.
length
*
pInput
->
numOfRows
;
...
...
source/libs/transport/src/transCli.c
浏览文件 @
a8f740bc
...
@@ -205,10 +205,10 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
...
@@ -205,10 +205,10 @@ static void destroyThrdObj(SCliThrdObj* pThrd);
transRefCliHandle(conn); \
transRefCliHandle(conn); \
} \
} \
} while (0)
} while (0)
#define CONN_NO_PERSIST_BY_APP(conn) \
(((conn)->status == ConnNormal || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
#define CONN_NO_PERSIST_BY_APP(conn)
(((conn)->status == ConnNormal || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
#define CONN_RELEASE_BY_SERVER(conn)
\
#define CONN_RELEASE_BY_SERVER(conn)
(((conn)->status == ConnRelease || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
(((conn)->status == ConnRelease || (conn)->status == ConnInPool) && T_REF_VAL_GET(conn) == 1)
#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1)
#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1)
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
#define REQUEST_PERSIS_HANDLE(msg) ((msg)->persistHandle == 1)
#define REQUEST_RELEASE_HANDLE(cmsg) ((cmsg)->type == Release)
#define REQUEST_RELEASE_HANDLE(cmsg) ((cmsg)->type == Release)
...
@@ -281,9 +281,8 @@ void cliHandleResp(SCliConn* conn) {
...
@@ -281,9 +281,8 @@ void cliHandleResp(SCliConn* conn) {
tDebug
(
"%s cli conn %p ref by app"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
tDebug
(
"%s cli conn %p ref by app"
,
CONN_GET_INST_LABEL
(
conn
),
conn
);
}
}
tDebug
(
"%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d"
,
pTransInst
->
label
,
conn
,
tDebug
(
"%s cli conn %p %s received from %s:%d, local info: %s:%d, msg size: %d"
,
pTransInst
->
label
,
conn
,
TMSG_INFO
(
pHead
->
msgType
),
TMSG_INFO
(
pHead
->
msgType
),
taosInetNtoa
(
conn
->
addr
.
sin_addr
),
ntohs
(
conn
->
addr
.
sin_port
),
taosInetNtoa
(
conn
->
addr
.
sin_addr
),
ntohs
(
conn
->
addr
.
sin_port
),
taosInetNtoa
(
conn
->
locaddr
.
sin_addr
),
ntohs
(
conn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
taosInetNtoa
(
conn
->
locaddr
.
sin_addr
),
ntohs
(
conn
->
locaddr
.
sin_port
),
transMsg
.
contLen
);
conn
->
secured
=
pHead
->
secured
;
conn
->
secured
=
pHead
->
secured
;
...
@@ -349,12 +348,10 @@ void cliHandleExcept(SCliConn* pConn) {
...
@@ -349,12 +348,10 @@ void cliHandleExcept(SCliConn* pConn) {
if
(
pMsg
==
NULL
&&
!
CONN_NO_PERSIST_BY_APP
(
pConn
))
{
if
(
pMsg
==
NULL
&&
!
CONN_NO_PERSIST_BY_APP
(
pConn
))
{
transMsg
.
ahandle
=
transCtxDumpVal
(
&
pConn
->
ctx
,
transMsg
.
msgType
);
transMsg
.
ahandle
=
transCtxDumpVal
(
&
pConn
->
ctx
,
transMsg
.
msgType
);
tDebug
(
"%s cli conn %p construct ahandle %p by %s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
transMsg
.
ahandle
,
tDebug
(
"%s cli conn %p construct ahandle %p by %s"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
transMsg
.
ahandle
,
TMSG_INFO
(
transMsg
.
msgType
));
TMSG_INFO
(
transMsg
.
msgType
));
if
(
transMsg
.
ahandle
==
NULL
)
{
if
(
transMsg
.
ahandle
==
NULL
)
{
transMsg
.
ahandle
=
transCtxDumpBrokenlinkVal
(
&
pConn
->
ctx
,
(
int32_t
*
)
&
(
transMsg
.
msgType
));
transMsg
.
ahandle
=
transCtxDumpBrokenlinkVal
(
&
pConn
->
ctx
,
(
int32_t
*
)
&
(
transMsg
.
msgType
));
tDebug
(
"%s cli conn %p construct ahandle %p due to brokenlink"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
tDebug
(
"%s cli conn %p construct ahandle %p due to brokenlink"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
transMsg
.
ahandle
);
transMsg
.
ahandle
);
}
}
}
else
{
}
else
{
transMsg
.
ahandle
=
pCtx
?
pCtx
->
ahandle
:
NULL
;
transMsg
.
ahandle
=
pCtx
?
pCtx
->
ahandle
:
NULL
;
...
@@ -628,9 +625,8 @@ void cliSend(SCliConn* pConn) {
...
@@ -628,9 +625,8 @@ void cliSend(SCliConn* pConn) {
pHead
->
release
=
REQUEST_RELEASE_HANDLE
(
pCliMsg
)
?
1
:
0
;
pHead
->
release
=
REQUEST_RELEASE_HANDLE
(
pCliMsg
)
?
1
:
0
;
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
uv_buf_t
wb
=
uv_buf_init
((
char
*
)
pHead
,
msgLen
);
tDebug
(
"%s cli conn %p %s is send to %s:%d, local info %s:%d"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
tDebug
(
"%s cli conn %p %s is send to %s:%d, local info %s:%d"
,
CONN_GET_INST_LABEL
(
pConn
),
pConn
,
TMSG_INFO
(
pHead
->
msgType
),
TMSG_INFO
(
pHead
->
msgType
),
taosInetNtoa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
taosInetNtoa
(
pConn
->
addr
.
sin_addr
),
ntohs
(
pConn
->
addr
.
sin_port
),
taosInetNtoa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
));
taosInetNtoa
(
pConn
->
locaddr
.
sin_addr
),
ntohs
(
pConn
->
locaddr
.
sin_port
));
if
(
pHead
->
persist
==
1
)
{
if
(
pHead
->
persist
==
1
)
{
CONN_SET_PERSIST_BY_APP
(
pConn
);
CONN_SET_PERSIST_BY_APP
(
pConn
);
...
@@ -741,8 +737,13 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
...
@@ -741,8 +737,13 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) {
if
(
ret
)
{
if
(
ret
)
{
tError
(
"%s cli conn %p failed to set conn option, errmsg %s"
,
pTransInst
->
label
,
conn
,
uv_err_name
(
ret
));
tError
(
"%s cli conn %p failed to set conn option, errmsg %s"
,
pTransInst
->
label
,
conn
,
uv_err_name
(
ret
));
}
}
struct
sockaddr_in
addr
;
struct
sockaddr_in
addr
;
uv_ip4_addr
(
pMsg
->
ctx
->
ip
,
pMsg
->
ctx
->
port
,
&
addr
);
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
.
s_addr
=
taosGetIpv4FromFqdn
(
conn
->
ip
);
addr
.
sin_port
=
(
uint16_t
)
htons
((
uint16_t
)
conn
->
port
);
// uv_ip4_addr(pMsg->ctx->ip, pMsg->ctx->port, &addr);
// handle error in callback if fail to connect
// handle error in callback if fail to connect
tTrace
(
"%s cli conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
pMsg
->
ctx
->
ip
,
pMsg
->
ctx
->
port
);
tTrace
(
"%s cli conn %p try to connect to %s:%d"
,
pTransInst
->
label
,
conn
,
pMsg
->
ctx
->
ip
,
pMsg
->
ctx
->
port
);
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
uv_tcp_connect
(
&
conn
->
connReq
,
(
uv_tcp_t
*
)(
conn
->
stream
),
(
const
struct
sockaddr
*
)
&
addr
,
cliConnCb
);
...
@@ -944,8 +945,8 @@ void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* p
...
@@ -944,8 +945,8 @@ void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* p
SCliThrdObj
*
thrd
=
((
SCliObj
*
)
pTransInst
->
tcphandle
)
->
pThreadObj
[
index
];
SCliThrdObj
*
thrd
=
((
SCliObj
*
)
pTransInst
->
tcphandle
)
->
pThreadObj
[
index
];
tDebug
(
"send request at thread:%d %p, dst: %s:%d
"
,
index
,
pMsg
,
ip
,
port
);
tDebug
(
"send request at thread:%d %p, dst: %s:%d
, app:%p"
,
index
,
pMsg
,
ip
,
port
,
pMsg
->
ahandle
);
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
)
);
ASSERT
(
transSendAsync
(
thrd
->
asyncPool
,
&
(
cliMsg
->
q
))
==
0
);
}
}
void
transSendRecv
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
port
,
STransMsg
*
pReq
,
STransMsg
*
pRsp
)
{
void
transSendRecv
(
void
*
shandle
,
const
char
*
ip
,
uint32_t
port
,
STransMsg
*
pReq
,
STransMsg
*
pRsp
)
{
...
...
source/util/src/tpagedbuf.c
浏览文件 @
a8f740bc
...
@@ -48,10 +48,8 @@ struct SDiskbasedBuf {
...
@@ -48,10 +48,8 @@ struct SDiskbasedBuf {
};
};
static
int32_t
createDiskFile
(
SDiskbasedBuf
*
pBuf
)
{
static
int32_t
createDiskFile
(
SDiskbasedBuf
*
pBuf
)
{
// pBuf->file = fopen(pBuf->path, "wb+");
pBuf
->
pFile
=
taosOpenFile
(
pBuf
->
path
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
|
TD_FILE_AUTO_DEL
);
pBuf
->
pFile
=
taosOpenFile
(
pBuf
->
path
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
);
if
(
pBuf
->
pFile
==
NULL
)
{
if
(
pBuf
->
pFile
==
NULL
)
{
// qError("failed to create tmp file: %s on disk. %s", pBuf->path, strerror(errno));
return
TAOS_SYSTEM_ERROR
(
errno
);
return
TAOS_SYSTEM_ERROR
(
errno
);
}
}
...
...
tests/script/tsim/query/charScalarFunction.sim
浏览文件 @
a8f740bc
...
@@ -286,25 +286,25 @@ endi
...
@@ -286,25 +286,25 @@ endi
#sql_error select c1, ltrim(t1), c2, ltrim(t2) from ctb3
#sql_error select c1, ltrim(t1), c2, ltrim(t2) from ctb3
#
print ====> rtrim
print ====> rtrim
#
sql select c1, rtrim(c1), c2, rtrim(c2), rtrim(" abcdEFGH =-*&% ") from ntb3
sql select c1, rtrim(c1), c2, rtrim(c2), rtrim(" abcdEFGH =-*&% ") from ntb3
#
print ====> select c1, rtrim(c1), c2, rtrim(c2), rtrim(" abcdEFGH =-*&% ") from ctb3
print ====> select c1, rtrim(c1), c2, rtrim(c2), rtrim(" abcdEFGH =-*&% ") from ctb3
#
sql select c1, rtrim(c1), c2, rtrim(c2), rtrim(" abcdEFGH =-*&% ") from ctb3
sql select c1, rtrim(c1), c2, rtrim(c2), rtrim(" abcdEFGH =-*&% ") from ctb3
#
print ====> rows: $rows
print ====> rows: $rows
#
print ====> [ $data00 ] [ $data01 ] [ $data02 ] [ $data03 ] [ $data04 ] [ $data05 ] [ $data06 ]
print ====> [ $data00 ] [ $data01 ] [ $data02 ] [ $data03 ] [ $data04 ] [ $data05 ] [ $data06 ]
#
print ====> $data10 $data11 $data12 $data13 $data14 $data15
print ====> $data10 $data11 $data12 $data13 $data14 $data15
#
if $rows != 1 then
if $rows != 1 then
#
return -1
return -1
#
endi
endi
#
if $data01 != @ abcd 1234@ then
if $data01 != @ abcd 1234@ then
#
return -1
return -1
#
endi
endi
#
if $data03 != @ abcd 1234@ then
if $data03 != @ abcd 1234@ then
#
return -1
return -1
#
endi
endi
#
if $data04 != @ abcdEFGH =-*&%@ then
if $data04 != @ abcdEFGH =-*&%@ then
#
return -1
return -1
#
endi
endi
#sql_error select c1, rtrim(t1), c2, rtrim(t2) from ctb3
#sql_error select c1, rtrim(t1), c2, rtrim(t2) from ctb3
...
...
tests/test/c/tmqSim.c
浏览文件 @
a8f740bc
...
@@ -274,17 +274,11 @@ int main(int32_t argc, char *argv[]) {
...
@@ -274,17 +274,11 @@ int main(int32_t argc, char *argv[]) {
loop_consume
(
tmq
);
loop_consume
(
tmq
);
err
=
tmq_unsubscribe
(
tmq
);
ASSERT
(
err
==
TMQ_RESP_ERR__SUCCESS
);
#if 0
err
=
tmq_unsubscribe
(
tmq
);
err
=
tmq_unsubscribe
(
tmq
);
if
(
err
)
{
if
(
err
)
{
printf
(
"tmq_unsubscribe() fail, reason: %s
\n
"
,
tmq_err2str
(
err
));
printf
(
"tmq_unsubscribe() fail, reason: %s
\n
"
,
tmq_err2str
(
err
));
exit
(
-
1
);
exit
(
-
1
);
}
}
#endif
return
0
;
return
0
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录