Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
3cb595b6
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3cb595b6
编写于
7月 29, 2021
作者:
Y
yihaoDeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-4335]<feature> group by multi column
上级
a9d71e28
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
17 deletion
+24
-17
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+24
-17
未找到文件。
src/query/src/qExecutor.c
浏览文件 @
3cb595b6
...
@@ -48,6 +48,8 @@
...
@@ -48,6 +48,8 @@
(_dst).ekey = (_src).ekey;\
(_dst).ekey = (_src).ekey;\
} while (0)
} while (0)
#define GROUPBY_MULTI_COLUMN_DELIM "-"
enum
{
enum
{
TS_JOIN_TS_EQUAL
=
0
,
TS_JOIN_TS_EQUAL
=
0
,
TS_JOIN_TS_NOT_EQUALS
=
1
,
TS_JOIN_TS_NOT_EQUALS
=
1
,
...
@@ -1476,6 +1478,8 @@ static bool buildGroupbyInfo(const SSDataBlock *pSDataBlock, const SGroupbyExpr
...
@@ -1476,6 +1478,8 @@ static bool buildGroupbyInfo(const SSDataBlock *pSDataBlock, const SGroupbyExpr
}
}
}
}
}
}
pInfo
->
totalBytes
+=
strlen
(
GROUPBY_MULTI_COLUMN_DELIM
)
*
pGroupbyExpr
->
numOfGroupCols
;
return
true
;
return
true
;
}
}
static
void
buildGroupbyKeyBuf
(
const
SSDataBlock
*
pSDataBlock
,
SGroupbyOperatorInfo
*
pInfo
,
int32_t
rowId
,
char
**
buf
,
bool
*
isNullKey
)
{
static
void
buildGroupbyKeyBuf
(
const
SSDataBlock
*
pSDataBlock
,
SGroupbyOperatorInfo
*
pInfo
,
int32_t
rowId
,
char
**
buf
,
bool
*
isNullKey
)
{
...
@@ -1501,6 +1505,8 @@ static void buildGroupbyKeyBuf(const SSDataBlock *pSDataBlock, SGroupbyOperatorI
...
@@ -1501,6 +1505,8 @@ static void buildGroupbyKeyBuf(const SSDataBlock *pSDataBlock, SGroupbyOperatorI
memcpy
(
p
,
val
,
pDataInfo
->
bytes
);
memcpy
(
p
,
val
,
pDataInfo
->
bytes
);
p
+=
pDataInfo
->
bytes
;
p
+=
pDataInfo
->
bytes
;
}
}
memcpy
(
p
,
GROUPBY_MULTI_COLUMN_DELIM
,
strlen
(
GROUPBY_MULTI_COLUMN_DELIM
));
p
+=
strlen
(
GROUPBY_MULTI_COLUMN_DELIM
);
*
isNullKey
=
false
;
*
isNullKey
=
false
;
}
}
}
}
...
@@ -1516,6 +1522,7 @@ static bool isGroupbyKeyEqual(void *a, void *b, void *ext) {
...
@@ -1516,6 +1522,7 @@ static bool isGroupbyKeyEqual(void *a, void *b, void *ext) {
return
false
;
return
false
;
}
}
offset
+=
pDataInfo
->
bytes
;
offset
+=
pDataInfo
->
bytes
;
offset
+=
strlen
(
GROUPBY_MULTI_COLUMN_DELIM
);
}
}
return
true
;
return
true
;
}
}
...
@@ -1661,22 +1668,22 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
...
@@ -1661,22 +1668,22 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
pSDataBlock
->
info
.
rows
,
pOperator
->
numOfOutput
);
pSDataBlock
->
info
.
rows
,
pOperator
->
numOfOutput
);
}
}
static
void
setResultRowKey
(
SResultRow
*
pResultRow
,
char
*
pData
,
int16_t
type
)
{
//
static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) {
if
(
IS_VAR_DATA_TYPE
(
type
))
{
//
if (IS_VAR_DATA_TYPE(type)) {
if
(
pResultRow
->
key
==
NULL
)
{
//
if (pResultRow->key == NULL) {
pResultRow
->
key
=
malloc
(
varDataTLen
(
pData
));
//
pResultRow->key = malloc(varDataTLen(pData));
varDataCopy
(
pResultRow
->
key
,
pData
);
//
varDataCopy(pResultRow->key, pData);
}
else
{
//
} else {
assert
(
memcmp
(
pResultRow
->
key
,
pData
,
varDataTLen
(
pData
))
==
0
);
//
assert(memcmp(pResultRow->key, pData, varDataTLen(pData)) == 0);
}
//
}
}
else
{
//
} else {
int64_t
v
=
-
1
;
//
int64_t v = -1;
GET_TYPED_DATA
(
v
,
int64_t
,
type
,
pData
);
//
GET_TYPED_DATA(v, int64_t, type, pData);
//
pResultRow
->
win
.
skey
=
v
;
//
pResultRow->win.skey = v;
pResultRow
->
win
.
ekey
=
v
;
//
pResultRow->win.ekey = v;
}
//
}
}
//
}
static
int32_t
setGroupResultOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupIndex
)
{
static
int32_t
setGroupResultOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupIndex
)
{
SDiskbasedResultBuf
*
pResultBuf
=
pRuntimeEnv
->
pResultBuf
;
SDiskbasedResultBuf
*
pResultBuf
=
pRuntimeEnv
->
pResultBuf
;
...
@@ -1698,7 +1705,7 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic
...
@@ -1698,7 +1705,7 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
d
,
len
,
true
,
groupIndex
);
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
d
,
len
,
true
,
groupIndex
);
assert
(
pResultRow
!=
NULL
);
assert
(
pResultRow
!=
NULL
);
setResultRowKey
(
pResultRow
,
pData
,
type
);
//
setResultRowKey(pResultRow, pData, type);
if
(
pResultRow
->
pageId
==
-
1
)
{
if
(
pResultRow
->
pageId
==
-
1
)
{
int32_t
ret
=
addNewWindowResultBuf
(
pResultRow
,
pResultBuf
,
groupIndex
,
pRuntimeEnv
->
pQueryAttr
->
resultRowSize
);
int32_t
ret
=
addNewWindowResultBuf
(
pResultRow
,
pResultBuf
,
groupIndex
,
pRuntimeEnv
->
pQueryAttr
->
resultRowSize
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录