Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
1a3cf2e5
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1a3cf2e5
编写于
8月 06, 2021
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-5623]<feature>: add compression code on server side
上级
02f6f5e4
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
37 addition
and
9 deletion
+37
-9
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-0
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+4
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+23
-7
src/query/src/queryMain.c
src/query/src/queryMain.c
+9
-1
未找到文件。
src/inc/taosmsg.h
浏览文件 @
1a3cf2e5
...
...
@@ -536,6 +536,7 @@ typedef struct SRetrieveTableRsp {
int16_t
precision
;
int64_t
offset
;
// updated offset value for multi-vnode projection query
int64_t
useconds
;
int8_t
compressed
;
char
data
[];
}
SRetrieveTableRsp
;
...
...
src/query/inc/qExecutor.h
浏览文件 @
1a3cf2e5
...
...
@@ -43,6 +43,9 @@ typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int
#define GET_NUM_OF_RESULTS(_r) (((_r)->outputBuf) == NULL? 0:((_r)->outputBuf)->info.rows)
#define QUERY_COMP_THRESHOLD 60
#define NEEDTO_COMPRESS_QUERY(size) ((size) > QUERY_COMP_THRESHOLD ? 1 : 0)
enum
{
// when query starts to execute, this status will set
QUERY_NOT_COMPLETED
=
0x1u
,
...
...
@@ -647,7 +650,7 @@ void destroyUdfInfo(SUdfInfo* pUdfInfo);
bool
isValidQInfo
(
void
*
param
);
int32_t
doDumpQueryResult
(
SQInfo
*
pQInfo
,
char
*
data
);
int32_t
doDumpQueryResult
(
SQInfo
*
pQInfo
,
char
*
data
,
int8_t
compressed
,
int32_t
*
compLen
);
size_t
getResultSize
(
SQInfo
*
pQInfo
,
int64_t
*
numOfRows
);
void
setQueryKilled
(
SQInfo
*
pQInfo
);
...
...
src/query/src/qExecutor.c
浏览文件 @
1a3cf2e5
...
...
@@ -4193,7 +4193,15 @@ static void updateNumOfRowsInResultRows(SQueryRuntimeEnv* pRuntimeEnv, SQLFuncti
}
}
static
void
doCopyQueryResultToMsg
(
SQInfo
*
pQInfo
,
int32_t
numOfRows
,
char
*
data
)
{
static
int32_t
compressQueryColData
(
SColumnInfoData
*
pColRes
,
int32_t
numOfRows
,
char
*
data
,
int8_t
compressed
)
{
int32_t
colLen
=
pColRes
->
info
.
bytes
*
numOfRows
;
int32_t
colCompLen
=
(
*
(
tDataTypes
[
pColRes
->
info
.
type
].
compFunc
))(
pColRes
->
pData
,
colLen
,
numOfRows
,
data
,
colLen
+
COMP_OVERFLOW_BYTES
,
compressed
,
NULL
,
0
);
data
+=
colCompLen
;
return
colCompLen
;
}
static
void
doCopyQueryResultToMsg
(
SQInfo
*
pQInfo
,
int32_t
numOfRows
,
char
*
data
,
int8_t
compressed
,
int32_t
*
compLen
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQueryAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
...
...
@@ -4202,16 +4210,24 @@ static void doCopyQueryResultToMsg(SQInfo *pQInfo, int32_t numOfRows, char *data
if
(
pQueryAttr
->
pExpr2
==
NULL
)
{
for
(
int32_t
col
=
0
;
col
<
pQueryAttr
->
numOfOutput
;
++
col
)
{
SColumnInfoData
*
pColRes
=
taosArrayGet
(
pRes
->
pDataBlock
,
col
);
if
(
compressed
)
{
*
compLen
+=
compressQueryColData
(
pColRes
,
pRes
->
info
.
rows
,
data
,
compressed
);
}
else
{
memmove
(
data
,
pColRes
->
pData
,
pColRes
->
info
.
bytes
*
pRes
->
info
.
rows
);
data
+=
pColRes
->
info
.
bytes
*
pRes
->
info
.
rows
;
}
}
}
else
{
for
(
int32_t
col
=
0
;
col
<
pQueryAttr
->
numOfExpr2
;
++
col
)
{
SColumnInfoData
*
pColRes
=
taosArrayGet
(
pRes
->
pDataBlock
,
col
);
if
(
compressed
)
{
*
compLen
+=
compressQueryColData
(
pColRes
,
numOfRows
,
data
,
compressed
);
}
else
{
memmove
(
data
,
pColRes
->
pData
,
pColRes
->
info
.
bytes
*
numOfRows
);
data
+=
pColRes
->
info
.
bytes
*
numOfRows
;
}
}
}
int32_t
numOfTables
=
(
int32_t
)
taosHashGetSize
(
pRuntimeEnv
->
pTableRetrieveTsMap
);
*
(
int32_t
*
)
data
=
htonl
(
numOfTables
);
...
...
@@ -8695,7 +8711,7 @@ void freeQInfo(SQInfo *pQInfo) {
tfree
(
pQInfo
);
}
int32_t
doDumpQueryResult
(
SQInfo
*
pQInfo
,
char
*
data
)
{
int32_t
doDumpQueryResult
(
SQInfo
*
pQInfo
,
char
*
data
,
int8_t
compressed
,
int32_t
*
compLen
)
{
// the remained number of retrieved rows, not the interpolated result
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQueryAttr
*
pQueryAttr
=
pQInfo
->
runtimeEnv
.
pQueryAttr
;
...
...
@@ -8738,7 +8754,7 @@ int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
setQueryStatus
(
pRuntimeEnv
,
QUERY_OVER
);
}
}
else
{
doCopyQueryResultToMsg
(
pQInfo
,
(
int32_t
)
pRuntimeEnv
->
outputBuf
->
info
.
rows
,
data
);
doCopyQueryResultToMsg
(
pQInfo
,
(
int32_t
)
pRuntimeEnv
->
outputBuf
->
info
.
rows
,
data
,
compressed
,
compLen
);
}
qDebug
(
"QInfo:0x%"
PRIx64
" current numOfRes rows:%d, total:%"
PRId64
,
pQInfo
->
qId
,
...
...
src/query/src/queryMain.c
浏览文件 @
1a3cf2e5
...
...
@@ -324,6 +324,7 @@ int32_t qRetrieveQueryResultInfo(qinfo_t qinfo, bool* buildRes, void* pRspContex
int32_t
qDumpRetrieveResult
(
qinfo_t
qinfo
,
SRetrieveTableRsp
**
pRsp
,
int32_t
*
contLen
,
bool
*
continueExec
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
int32_t
compLen
=
0
;
if
(
pQInfo
==
NULL
||
!
isValidQInfo
(
pQInfo
))
{
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
...
...
@@ -356,12 +357,19 @@ int32_t qDumpRetrieveResult(qinfo_t qinfo, SRetrieveTableRsp **pRsp, int32_t *co
}
(
*
pRsp
)
->
precision
=
htons
(
pQueryAttr
->
precision
);
(
*
pRsp
)
->
compressed
=
NEEDTO_COMPRESS_QUERY
(
pQueryAttr
->
resultRowSize
*
s
);
if
(
GET_NUM_OF_RESULTS
(
&
(
pQInfo
->
runtimeEnv
))
>
0
&&
pQInfo
->
code
==
TSDB_CODE_SUCCESS
)
{
doDumpQueryResult
(
pQInfo
,
(
*
pRsp
)
->
data
);
doDumpQueryResult
(
pQInfo
,
(
*
pRsp
)
->
data
,
(
*
pRsp
)
->
compressed
,
&
compLen
);
}
else
{
setQueryStatus
(
pRuntimeEnv
,
QUERY_OVER
);
}
if
((
*
pRsp
)
->
compressed
&&
compLen
!=
0
)
{
*
contLen
=
*
contLen
-
pQueryAttr
->
resultRowSize
*
s
+
compLen
;
*
pRsp
=
(
SRetrieveTableRsp
*
)
rpcReallocCont
(
*
pRsp
,
*
contLen
);
}
pQInfo
->
rspContext
=
NULL
;
pQInfo
->
dataReady
=
QUERY_RESULT_NOT_READY
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录