Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
272d0ec7
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
272d0ec7
编写于
4月 14, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact vnode
上级
b932b5bc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
113 addition
and
120 deletion
+113
-120
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+74
-119
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+39
-1
未找到文件。
source/dnode/vnode/inc/vnode.h
浏览文件 @
272d0ec7
...
...
@@ -35,21 +35,13 @@
extern
"C"
{
#endif
// types
typedef
struct
SVnode
SVnode
;
typedef
struct
SMetaCfg
SMetaCfg
;
// todo: remove
typedef
struct
STsdbCfg
STsdbCfg
;
// todo: remove
typedef
struct
STqCfg
STqCfg
;
// todo: remove
typedef
struct
SVnodeCfg
SVnodeCfg
;
typedef
struct
STqReadHandle
STqReadHandle
;
typedef
struct
SMTbCursor
SMTbCursor
;
// todo: remove
typedef
struct
SMCtbCursor
SMCtbCursor
;
// todo: remove
typedef
struct
SMSmaCursor
SMSmaCursor
;
// todo: remove
typedef
void
*
tsdbReaderT
;
typedef
struct
STsdbQueryCond
STsdbQueryCond
;
typedef
struct
SDataStatis
SDataStatis
;
// vnode
typedef
struct
SVnode
SVnode
;
typedef
struct
SMetaCfg
SMetaCfg
;
// todo: remove
typedef
struct
STsdbCfg
STsdbCfg
;
// todo: remove
typedef
struct
STqCfg
STqCfg
;
// todo: remove
typedef
struct
SVnodeCfg
SVnodeCfg
;
int
vnodeInit
();
void
vnodeCleanup
();
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
...
...
@@ -65,12 +57,59 @@ int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg);
int32_t
vnodeCompact
(
SVnode
*
pVnode
);
int32_t
vnodeSync
(
SVnode
*
pVnode
);
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
);
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
);
// meta
typedef
struct
SMeta
SMeta
;
// todo: remove
typedef
struct
SMeta
SMeta
;
// todo: remove
typedef
struct
SMTbCursor
SMTbCursor
;
// todo: remove
typedef
struct
SMCtbCursor
SMCtbCursor
;
// todo: remove
typedef
struct
SMSmaCursor
SMSmaCursor
;
// todo: remove
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTSmaReq
SSmaCfg
;
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
);
void
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
,
bool
isDecode
);
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
metaCloseSmaCursor
(
SMSmaCursor
*
pSmaCur
);
int64_t
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
// tsdb
typedef
struct
STsdb
STsdb
;
typedef
struct
STsdb
STsdb
;
typedef
struct
SDataStatis
SDataStatis
;
typedef
struct
STsdbQueryCond
STsdbQueryCond
;
typedef
void
*
tsdbReaderT
;
#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
tsdbReaderT
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
);
...
...
@@ -92,6 +131,23 @@ int32_t tsdbGetTableGroupFromIdList(STsdb *tsdb, SArray *pTableIdList, STab
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
// tq
enum
{
TQ_STREAM_TOKEN__DATA
=
1
,
TQ_STREAM_TOKEN__WATERMARK
,
TQ_STREAM_TOKEN__CHECKPOINT
,
};
typedef
struct
STqReadHandle
STqReadHandle
;
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
);
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
);
int
tqReadHandleSetTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
);
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
// need to remove
int32_t
tdScanAndConvertSubmitMsg
(
SSubmitReq
*
pMsg
);
...
...
@@ -159,16 +215,9 @@ struct STqReadHandle {
// ---------------------------- OLD ----------------------------
typedef
struct
SMgmtWrapper
SMgmtWrapper
;
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
// Types exported
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTSmaReq
SSmaCfg
;
typedef
struct
SDataStatis
{
struct
SDataStatis
{
int16_t
colId
;
int16_t
maxIndex
;
int16_t
minIndex
;
...
...
@@ -176,7 +225,7 @@ typedef struct SDataStatis {
int64_t
sum
;
int64_t
max
;
int64_t
min
;
}
SDataStatis
;
};
struct
STsdbQueryCond
{
STimeWindow
twindow
;
...
...
@@ -198,24 +247,8 @@ typedef struct STable {
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
/* ------------------------ SVnode ------------------------ */
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
);
/* ------------------------ FOR COMPILE ------------------------ */
enum
{
TQ_STREAM_TOKEN__DATA
=
1
,
TQ_STREAM_TOKEN__WATERMARK
,
TQ_STREAM_TOKEN__CHECKPOINT
,
};
typedef
struct
{
int8_t
type
;
int8_t
reserved
[
7
];
...
...
@@ -226,85 +259,7 @@ typedef struct {
};
}
STqStreamToken
;
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
);
static
FORCE_INLINE
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
// static FORCE_INLINE void tqReadHandleSetTbUid(STqReadHandle* pHandle, int64_t tbUid) {
// pHandle->tbUid = tbUid;
//}
static
FORCE_INLINE
int
tqReadHandleSetTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
if
(
pHandle
->
tbIdHash
)
{
taosHashClear
(
pHandle
->
tbIdHash
);
}
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
*
pKey
=
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
taosHashPut
(
pHandle
->
tbIdHash
,
pKey
,
sizeof
(
int64_t
),
NULL
,
0
);
}
return
0
;
}
static
FORCE_INLINE
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
if
(
pHandle
->
tbIdHash
==
NULL
)
{
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
*
pKey
=
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
taosHashPut
(
pHandle
->
tbIdHash
,
pKey
,
sizeof
(
int64_t
),
NULL
,
0
);
}
return
0
;
}
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
// return SArray<SColumnInfoData>
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
);
void
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
,
bool
isDecode
);
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
metaCloseSmaCursor
(
SMSmaCursor
*
pSmaCur
);
int64_t
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
// Options
void
metaOptionsInit
(
SMetaCfg
*
pMetaCfg
);
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
272d0ec7
...
...
@@ -88,7 +88,7 @@ int tqRetrieveDataBlockInfo(STqReadHandle* pHandle, SDataBlockInfo* pBlockInfo)
pBlockInfo
->
numOfCols
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
pBlockInfo
->
rows
=
pHandle
->
pBlock
->
numOfRows
;
// pBlockInfo->uid = pHandle->pBlock->uid; // the uid can not be assigned to pBlockData.
// pBlockInfo->uid = pHandle->pBlock->uid; // the uid can not be assigned to pBlockData.
return
0
;
}
...
...
@@ -177,3 +177,41 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
}
return
pArray
;
}
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColIdList
)
{
pReadHandle
->
pColIdList
=
pColIdList
;
}
int
tqReadHandleSetTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
if
(
pHandle
->
tbIdHash
)
{
taosHashClear
(
pHandle
->
tbIdHash
);
}
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
*
pKey
=
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
taosHashPut
(
pHandle
->
tbIdHash
,
pKey
,
sizeof
(
int64_t
),
NULL
,
0
);
}
return
0
;
}
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
if
(
pHandle
->
tbIdHash
==
NULL
)
{
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
*
pKey
=
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
taosHashPut
(
pHandle
->
tbIdHash
,
pKey
,
sizeof
(
int64_t
),
NULL
,
0
);
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录