Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f967cff0
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
f967cff0
编写于
6月 22, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add table group info if need sort table by group
上级
9883d670
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
61 addition
and
40 deletion
+61
-40
include/common/tcommon.h
include/common/tcommon.h
+2
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+59
-40
未找到文件。
include/common/tcommon.h
浏览文件 @
f967cff0
...
...
@@ -47,8 +47,10 @@ typedef enum EStreamType {
}
EStreamType
;
typedef
struct
{
SArray
*
pGroupList
;
SArray
*
pTableList
;
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
bool
needSortTableByGroupId
;
}
STableListInfo
;
typedef
struct
SColumnDataAgg
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
f967cff0
...
...
@@ -3964,39 +3964,6 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
return
TDB_CODE_SUCCESS
;
}
// SSDataBlock data = {0};
// data.info.numOfCols = 3;
// data.info.rows = rowNum;
// data.pDataBlock = taosArrayInit(3, sizeof(SColumnInfoData));
// for (int32_t i = 0; i < 2; ++i) {
// SColumnInfoData idata = {{0}};
// idata.info.type = TSDB_DATA_TYPE_NULL;
// idata.info.bytes = 10;
// idata.info.colId = i + 1;
//
// int32_t size = idata.info.bytes * rowNum;
// idata.pData = (char *)taosMemoryCalloc(1, size);
// taosArrayPush(res->pDataBlock, &idata);
// }
//
// SArray* pBlockList = taosArrayInit(4, POINTER_BYTES);
// taosArrayPush(pBlockList, &src);
//
// SColumnInfoData* pResColData = taosArrayGet(pResult->pDataBlock, outputSlotId);
// SColumnInfoData idata = {.info = pResColData->info, .hasNull = true};
//
// SScalarParam dest = {.columnData = &idata};
// int32_t code = scalarCalculate(group, pBlockList, &dest);
// if (code != TSDB_CODE_SUCCESS) {
// taosArrayDestroy(pBlockList);
// return code;
// }
//
//
// numOfRows = dest.numOfRows;
// taosArrayDestroy(pBlockList);
pTableListInfo
->
map
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
pTableListInfo
->
map
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -4018,6 +3985,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
groupNum
=
0
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
i
++
)
{
STableKeyInfo
*
info
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
SMetaReader
mr
=
{
0
};
...
...
@@ -4038,6 +4006,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
if
(
TSDB_CODE_SUCCESS
==
code
)
{
REPLACE_NODE
(
pNew
);
}
else
{
taosMemoryFree
(
keyBuf
);
nodesClearList
(
groupNew
);
return
code
;
}
...
...
@@ -4066,17 +4035,67 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
}
int32_t
len
=
(
int32_t
)(
pStart
-
(
char
*
)
keyBuf
);
uint64_t
*
groupId
=
taosHashGet
(
pTableListInfo
->
map
,
keyBuf
,
len
);
if
(
groupId
)
{
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
groupId
,
sizeof
(
uint64_t
));
}
else
{
uint64_t
tmpId
=
calcGroupId
(
keyBuf
,
len
);
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
tmpId
,
sizeof
(
uint64_t
));
}
uint64_t
groupId
=
calcGroupId
(
keyBuf
,
len
);
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
groupId
,
sizeof
(
uint64_t
));
groupNum
++
;
nodesClearList
(
groupNew
);
metaReaderClear
(
&
mr
);
}
taosMemoryFree
(
keyBuf
);
if
(
pTableListInfo
->
needSortTableByGroupId
){
pTableListInfo
->
pGroupList
=
taosArrayInit
(
groupNum
,
POINTER_BYTES
);
SArray
*
sortSupport
=
taosArrayInit
(
groupNum
,
sizeof
(
uint64_t
));
if
(
pTableListInfo
->
pGroupList
==
NULL
||
sortSupport
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
i
++
)
{
STableKeyInfo
*
info
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
uint64_t
*
groupId
=
taosHashGet
(
pTableListInfo
->
map
,
&
info
->
uid
,
sizeof
(
uint64_t
));
int32_t
index
=
taosArraySearchIdx
(
sortSupport
,
groupId
,
compareUint64Val
,
TD_EQ
);
if
(
index
==
-
1
){
void
*
p
=
taosArraySearch
(
sortSupport
,
groupId
,
compareUint64Val
,
TD_GT
);
SArray
*
tGroup
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
if
(
tGroup
==
NULL
)
{
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
p
==
NULL
){
if
(
taosArrayPush
(
sortSupport
,
groupId
)
!=
NULL
){
qError
(
"taos push support array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
taosArrayPush
(
pTableListInfo
->
pGroupList
,
&
tGroup
)
!=
NULL
){
qError
(
"taos push group array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
else
{
int32_t
pos
=
TARRAY_ELEM_IDX
(
sortSupport
,
p
);
if
(
taosArrayInsert
(
sortSupport
,
pos
,
groupId
)
==
NULL
){
qError
(
"taos insert support array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
taosArrayInsert
(
pTableListInfo
->
pGroupList
,
pos
,
&
tGroup
)
==
NULL
){
qError
(
"taos insert group array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
}
else
{
SArray
*
tGroup
=
(
SArray
*
)
taosArrayGetP
(
pTableListInfo
->
pGroupList
,
index
);
if
(
taosArrayPush
(
tGroup
,
&
info
->
uid
)
==
NULL
){
qError
(
"taos push uid array error"
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
}
taosArrayDestroy
(
sortSupport
);
}
return
TDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录