Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小楼昨夜-听风雨
TDengine
提交
2cd97574
T
TDengine
项目概览
小楼昨夜-听风雨
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2cd97574
编写于
11月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] refactor codes.
上级
64ab48d7
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
33 addition
and
33 deletion
+33
-33
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+4
-4
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+6
-6
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+12
-12
src/query/src/qUtil.c
src/query/src/qUtil.c
+11
-11
未找到文件。
src/query/inc/qExecutor.h
浏览文件 @
2cd97574
...
...
@@ -40,7 +40,7 @@ typedef struct SGroupResInfo {
int32_t
rowId
;
}
SGroupResInfo
;
typedef
struct
S
WindowResult
Pool
{
typedef
struct
S
ResultRow
Pool
{
int32_t
elemSize
;
int32_t
blockSize
;
int32_t
numOfElemPerBlock
;
...
...
@@ -51,7 +51,7 @@ typedef struct SWindowResultPool {
}
position
;
SArray
*
pData
;
// SArray<void*>
}
S
WindowResult
Pool
;
}
S
ResultRow
Pool
;
typedef
struct
SSqlGroupbyExpr
{
int16_t
tableIndex
;
...
...
@@ -188,9 +188,9 @@ typedef struct SQueryRuntimeEnv {
int32_t
interBufSize
;
// intermediate buffer sizse
int32_t
prevGroupId
;
// previous executed group id
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SHashObj
*
p
Wind
owHashTable
;
// quick locate the window object for each result
SHashObj
*
p
ResultR
owHashTable
;
// quick locate the window object for each result
char
*
keyBuf
;
// window key buffer
S
WindowResult
Pool
*
pool
;
// window result object pool
S
ResultRow
Pool
*
pool
;
// window result object pool
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
}
SQueryRuntimeEnv
;
...
...
src/query/inc/qUtil.h
浏览文件 @
2cd97574
...
...
@@ -73,12 +73,12 @@ __filter_func_t *getValueFilterFuncArray(int32_t type);
size_t
getWindowResultSize
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
S
WindowResultPool
*
initWindowResult
Pool
(
size_t
size
);
SResultRow
*
getNew
WindowResult
(
SWindowResult
Pool
*
p
);
int64_t
get
WindowResultPoolMemSize
(
SWindowResult
Pool
*
p
);
void
*
destroy
WindowResultPool
(
SWindowResult
Pool
*
p
);
int32_t
getNumOfAllocated
WindowResult
(
SWindowResult
Pool
*
p
);
int32_t
getNumOfUsed
WindowResult
(
SWindowResult
Pool
*
p
);
S
ResultRowPool
*
initResultRow
Pool
(
size_t
size
);
SResultRow
*
getNew
ResultRow
(
SResultRow
Pool
*
p
);
int64_t
get
ResultRowPoolMemSize
(
SResultRow
Pool
*
p
);
void
*
destroy
ResultRowPool
(
SResultRow
Pool
*
p
);
int32_t
getNumOfAllocated
ResultRows
(
SResultRow
Pool
*
p
);
int32_t
getNumOfUsed
ResultRows
(
SResultRow
Pool
*
p
);
#endif // TDENGINE_QUERYUTIL_H
src/query/src/qExecutor.c
浏览文件 @
2cd97574
...
...
@@ -452,7 +452,7 @@ static SResultRow *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWindow
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
pData
,
bytes
,
uid
);
int32_t
*
p1
=
(
int32_t
*
)
taosHashGet
(
pRuntimeEnv
->
p
Wind
owHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
int32_t
*
p1
=
(
int32_t
*
)
taosHashGet
(
pRuntimeEnv
->
p
ResultR
owHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
if
(
p1
!=
NULL
)
{
pWindowResInfo
->
curIndex
=
*
p1
;
}
else
{
...
...
@@ -485,7 +485,7 @@ static SResultRow *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWindow
pWindowResInfo
->
capacity
=
(
int32_t
)
newCapacity
;
}
// pRuntimeEnv->summary.winInfoSize += (pQuery->numOfOutput * sizeof(SResultRowCellInfo) + pRuntimeEnv->interBufSize) * inc;
SResultRow
*
pResult
=
getNew
WindowResult
(
pRuntimeEnv
->
pool
);
SResultRow
*
pResult
=
getNew
ResultRow
(
pRuntimeEnv
->
pool
);
pWindowResInfo
->
pResult
[
pWindowResInfo
->
size
]
=
pResult
;
int32_t
ret
=
createQueryResultInfo
(
pQuery
,
pResult
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -494,7 +494,7 @@ static SResultRow *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWindow
// add a new result set for a new group
pWindowResInfo
->
curIndex
=
pWindowResInfo
->
size
++
;
taosHashPut
(
pRuntimeEnv
->
p
Wind
owHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
(
char
*
)
&
pWindowResInfo
->
curIndex
,
sizeof
(
int32_t
));
taosHashPut
(
pRuntimeEnv
->
p
ResultR
owHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
(
char
*
)
&
pWindowResInfo
->
curIndex
,
sizeof
(
int32_t
));
}
// too many time window in query
...
...
@@ -1771,10 +1771,10 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
pRuntimeEnv
->
pTSBuf
=
tsBufDestroy
(
pRuntimeEnv
->
pTSBuf
);
taosTFree
(
pRuntimeEnv
->
keyBuf
);
taosHashCleanup
(
pRuntimeEnv
->
p
Wind
owHashTable
);
pRuntimeEnv
->
p
Wind
owHashTable
=
NULL
;
taosHashCleanup
(
pRuntimeEnv
->
p
ResultR
owHashTable
);
pRuntimeEnv
->
p
ResultR
owHashTable
=
NULL
;
pRuntimeEnv
->
pool
=
destroy
WindowResult
Pool
(
pRuntimeEnv
->
pool
);
pRuntimeEnv
->
pool
=
destroy
ResultRow
Pool
(
pRuntimeEnv
->
pool
);
}
#define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED)
...
...
@@ -4246,16 +4246,16 @@ static void queryCostStatis(SQInfo *pQInfo) {
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQueryCostInfo
*
pSummary
=
&
pRuntimeEnv
->
summary
;
uint64_t
hashSize
=
taosHashGetMemSize
(
pQInfo
->
runtimeEnv
.
p
Wind
owHashTable
);
uint64_t
hashSize
=
taosHashGetMemSize
(
pQInfo
->
runtimeEnv
.
p
ResultR
owHashTable
);
hashSize
+=
taosHashGetMemSize
(
pQInfo
->
tableqinfoGroupInfo
.
map
);
pSummary
->
hashSize
=
hashSize
;
// add the merge time
pSummary
->
elapsedTime
+=
pSummary
->
firstStageMergeTime
;
S
WindowResult
Pool
*
p
=
pQInfo
->
runtimeEnv
.
pool
;
pSummary
->
winInfoSize
=
get
WindowResult
PoolMemSize
(
p
);
pSummary
->
numOfTimeWindows
=
getNumOfAllocated
WindowResult
(
p
);
S
ResultRow
Pool
*
p
=
pQInfo
->
runtimeEnv
.
pool
;
pSummary
->
winInfoSize
=
get
ResultRow
PoolMemSize
(
p
);
pSummary
->
numOfTimeWindows
=
getNumOfAllocated
ResultRows
(
p
);
qDebug
(
"QInfo:%p :cost summary: elapsed time:%"
PRId64
" us, first merge:%"
PRId64
" us, total blocks:%d, "
"load block statis:%d, load data block:%d, total rows:%"
PRId64
", check rows:%"
PRId64
,
...
...
@@ -6322,9 +6322,9 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
pQInfo
->
runtimeEnv
.
interBufSize
=
getOutputInterResultBufSize
(
pQuery
);
pQInfo
->
runtimeEnv
.
summary
.
tableInfoSize
+=
(
pTableGroupInfo
->
numOfTables
*
sizeof
(
STableQueryInfo
));
pQInfo
->
runtimeEnv
.
p
Wind
owHashTable
=
taosHashInit
(
pTableGroupInfo
->
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pQInfo
->
runtimeEnv
.
p
ResultR
owHashTable
=
taosHashInit
(
pTableGroupInfo
->
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
pQInfo
->
runtimeEnv
.
keyBuf
=
malloc
(
TSDB_MAX_BYTES_PER_ROW
);
pQInfo
->
runtimeEnv
.
pool
=
init
WindowResult
Pool
(
getWindowResultSize
(
&
pQInfo
->
runtimeEnv
));
pQInfo
->
runtimeEnv
.
pool
=
init
ResultRow
Pool
(
getWindowResultSize
(
&
pQInfo
->
runtimeEnv
));
pQInfo
->
pBuf
=
calloc
(
pTableGroupInfo
->
numOfTables
,
sizeof
(
STableQueryInfo
));
if
(
pQInfo
->
pBuf
==
NULL
)
{
...
...
src/query/src/qUtil.c
浏览文件 @
2cd97574
...
...
@@ -105,7 +105,7 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
}
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
taosHashRemove
(
pRuntimeEnv
->
p
Wind
owHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
taosHashRemove
(
pRuntimeEnv
->
p
ResultR
owHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
}
else
{
break
;
}
...
...
@@ -138,14 +138,14 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
}
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pRuntimeEnv
->
p
Wind
owHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pRuntimeEnv
->
p
ResultR
owHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
assert
(
p
!=
NULL
);
int32_t
v
=
(
*
p
-
num
);
assert
(
v
>=
0
&&
v
<=
pWindowResInfo
->
size
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
taosHashPut
(
pRuntimeEnv
->
p
Wind
owHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
(
char
*
)
&
v
,
sizeof
(
int32_t
));
taosHashPut
(
pRuntimeEnv
->
p
ResultR
owHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
(
char
*
)
&
v
,
sizeof
(
int32_t
));
}
pWindowResInfo
->
curIndex
=
-
1
;
...
...
@@ -292,8 +292,8 @@ size_t getWindowResultSize(SQueryRuntimeEnv* pRuntimeEnv) {
return
(
pRuntimeEnv
->
pQuery
->
numOfOutput
*
sizeof
(
SResultRowCellInfo
))
+
pRuntimeEnv
->
interBufSize
+
sizeof
(
SResultRow
);
}
S
WindowResultPool
*
initWindowResult
Pool
(
size_t
size
)
{
S
WindowResultPool
*
p
=
calloc
(
1
,
sizeof
(
SWindowResult
Pool
));
S
ResultRowPool
*
initResultRow
Pool
(
size_t
size
)
{
S
ResultRowPool
*
p
=
calloc
(
1
,
sizeof
(
SResultRow
Pool
));
if
(
p
==
NULL
)
{
return
NULL
;
}
...
...
@@ -309,7 +309,7 @@ SWindowResultPool* initWindowResultPool(size_t size) {
return
p
;
}
SResultRow
*
getNew
WindowResult
(
SWindowResult
Pool
*
p
)
{
SResultRow
*
getNew
ResultRow
(
SResultRow
Pool
*
p
)
{
if
(
p
==
NULL
)
{
return
NULL
;
}
...
...
@@ -330,7 +330,7 @@ SResultRow* getNewWindowResult(SWindowResultPool* p) {
return
ptr
;
}
int64_t
get
WindowResultPoolMemSize
(
SWindowResult
Pool
*
p
)
{
int64_t
get
ResultRowPoolMemSize
(
SResultRow
Pool
*
p
)
{
if
(
p
==
NULL
)
{
return
0
;
}
...
...
@@ -338,15 +338,15 @@ int64_t getWindowResultPoolMemSize(SWindowResultPool* p) {
return
taosArrayGetSize
(
p
->
pData
)
*
p
->
blockSize
;
}
int32_t
getNumOfAllocated
WindowResult
(
SWindowResult
Pool
*
p
)
{
int32_t
getNumOfAllocated
ResultRows
(
SResultRow
Pool
*
p
)
{
return
taosArrayGetSize
(
p
->
pData
)
*
p
->
numOfElemPerBlock
;
}
int32_t
getNumOfUsed
WindowResult
(
SWindowResult
Pool
*
p
)
{
return
getNumOfAllocated
WindowResult
(
p
)
-
p
->
numOfElemPerBlock
+
p
->
position
.
pos
;
int32_t
getNumOfUsed
ResultRows
(
SResultRow
Pool
*
p
)
{
return
getNumOfAllocated
ResultRows
(
p
)
-
p
->
numOfElemPerBlock
+
p
->
position
.
pos
;
}
void
*
destroy
WindowResultPool
(
SWindowResult
Pool
*
p
)
{
void
*
destroy
ResultRowPool
(
SResultRow
Pool
*
p
)
{
if
(
p
==
NULL
)
{
return
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录