Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
adminstrot
TDengine
提交
4c04ce09
TDengine
项目概览
adminstrot
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4c04ce09
编写于
12月 23, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2434]<enhance>: reduce the memory requirement during super table interval query.
上级
79ffafb3
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
351 addition
and
655 deletion
+351
-655
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-1
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+15
-3
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+6
-8
src/query/inc/qHistogram.h
src/query/inc/qHistogram.h
+1
-1
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+0
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+319
-618
src/query/src/qHistogram.c
src/query/src/qHistogram.c
+5
-4
src/query/src/qUtil.c
src/query/src/qUtil.c
+4
-19
未找到文件。
src/client/src/tscAsync.c
浏览文件 @
4c04ce09
...
...
@@ -388,10 +388,10 @@ void tscQueueAsyncRes(SSqlObj *pSql) {
return
;
}
assert
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
);
tscError
(
"%p add into queued async res, code:%s"
,
pSql
,
tstrerror
(
pSql
->
res
.
code
));
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pSql
->
fp
==
NULL
||
pSql
->
fetchFp
==
NULL
){
return
;
}
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
4c04ce09
...
...
@@ -2597,14 +2597,23 @@ static void percentile_next_step(SQLFunctionCtx *pCtx) {
}
//////////////////////////////////////////////////////////////////////////////////
static
void
buildHistogramInfo
(
SAPercentileInfo
*
pInfo
)
{
pInfo
->
pHisto
=
(
SHistogramInfo
*
)
((
char
*
)
pInfo
+
sizeof
(
SAPercentileInfo
));
pInfo
->
pHisto
->
elems
=
(
SHistBin
*
)
((
char
*
)
pInfo
->
pHisto
+
sizeof
(
SHistogramInfo
));
}
static
SAPercentileInfo
*
getAPerctInfo
(
SQLFunctionCtx
*
pCtx
)
{
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SAPercentileInfo
*
pInfo
=
NULL
;
if
(
pCtx
->
stableQuery
&&
pCtx
->
currentStage
!=
SECONDARY_STAGE_MERGE
)
{
return
(
SAPercentileInfo
*
)
pCtx
->
aOutputBuf
;
pInfo
=
(
SAPercentileInfo
*
)
pCtx
->
aOutputBuf
;
}
else
{
return
GET_ROWCELL_INTERBUF
(
pResInfo
);
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
}
buildHistogramInfo
(
pInfo
);
return
pInfo
;
}
static
bool
apercentile_function_setup
(
SQLFunctionCtx
*
pCtx
)
{
...
...
@@ -2616,6 +2625,7 @@ static bool apercentile_function_setup(SQLFunctionCtx *pCtx) {
char
*
tmp
=
(
char
*
)
pInfo
+
sizeof
(
SAPercentileInfo
);
pInfo
->
pHisto
=
tHistogramCreateFrom
(
tmp
,
MAX_HISTOGRAM_BIN
);
printf
(
"%p, %p
\n
"
,
pInfo
->
pHisto
,
pInfo
->
pHisto
->
elems
);
return
true
;
}
...
...
@@ -2624,6 +2634,8 @@ static void apercentile_function(SQLFunctionCtx *pCtx) {
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SAPercentileInfo
*
pInfo
=
getAPerctInfo
(
pCtx
);
assert
(
pInfo
->
pHisto
->
elems
!=
NULL
);
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
char
*
data
=
GET_INPUT_CHAR_INDEX
(
pCtx
,
i
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
4c04ce09
...
...
@@ -33,13 +33,6 @@ struct SColumnFilterElem;
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
char
*
val1
,
char
*
val2
);
typedef
int32_t
(
*
__block_search_fn_t
)(
char
*
data
,
int32_t
num
,
int64_t
key
,
int32_t
order
);
typedef
struct
SGroupResInfo
{
int32_t
groupId
;
int32_t
numOfDataPages
;
int32_t
pageId
;
int32_t
rowId
;
}
SGroupResInfo
;
typedef
struct
SResultRowPool
{
int32_t
elemSize
;
int32_t
blockSize
;
...
...
@@ -72,6 +65,12 @@ typedef struct SResultRow {
union
{
STimeWindow
win
;
char
*
key
;};
// start key of current time window
}
SResultRow
;
typedef
struct
SGroupResInfo
{
int32_t
rowId
;
int32_t
index
;
SArray
*
pRows
;
// SArray<SResultRow*>
}
SGroupResInfo
;
/**
* If the number of generated results is greater than this value,
* query query will be halt and return results to client immediate.
...
...
@@ -89,7 +88,6 @@ typedef struct SResultRowInfo {
int32_t
size
:
24
;
// number of result set
int32_t
capacity
;
// max capacity
int32_t
curIndex
;
// current start active index
int64_t
startTime
;
// start time of the first time window for sliding query
int64_t
prevSKey
;
// previous (not completed) sliding window start key
}
SResultRowInfo
;
...
...
src/query/inc/qHistogram.h
浏览文件 @
4c04ce09
...
...
@@ -67,7 +67,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto);
void
tHistogramPrint
(
SHistogramInfo
*
pHisto
);
int32_t
vnodeHistob
inarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
);
//int32_t histoB
inarySearch(SHistBin* pEntry, int32_t len, double val);
SHeapEntry
*
tHeapCreate
(
int32_t
numOfEntries
);
void
tHeapSort
(
SHeapEntry
*
pEntry
,
int32_t
len
);
...
...
src/query/inc/qUtil.h
浏览文件 @
4c04ce09
...
...
@@ -77,7 +77,6 @@ void* destroyResultRowPool(SResultRowPool* p);
int32_t
getNumOfAllocatedResultRows
(
SResultRowPool
*
p
);
int32_t
getNumOfUsedResultRows
(
SResultRowPool
*
p
);
uint64_t
getResultInfoUId
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
bool
isPointInterpoQuery
(
SQuery
*
pQuery
);
...
...
src/query/src/qExecutor.c
浏览文件 @
4c04ce09
此差异已折叠。
点击以展开。
src/query/src/qHistogram.c
浏览文件 @
4c04ce09
...
...
@@ -120,6 +120,7 @@
//}
static
int32_t
histogramCreateBin
(
SHistogramInfo
*
pHisto
,
int32_t
index
,
double
val
);
static
int32_t
histoBinarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
);
SHistogramInfo
*
tHistogramCreate
(
int32_t
numOfEntries
)
{
/* need one redundant slot */
...
...
@@ -158,8 +159,8 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
}
#if defined(USE_ARRAYLIST)
int32_t
idx
=
vnodeHistob
inarySearch
((
*
pHisto
)
->
elems
,
(
*
pHisto
)
->
numOfEntries
,
val
);
assert
(
idx
>=
0
&&
idx
<=
(
*
pHisto
)
->
maxEntries
);
int32_t
idx
=
histoB
inarySearch
((
*
pHisto
)
->
elems
,
(
*
pHisto
)
->
numOfEntries
,
val
);
assert
(
idx
>=
0
&&
idx
<=
(
*
pHisto
)
->
maxEntries
&&
(
*
pHisto
)
->
elems
!=
NULL
);
if
((
*
pHisto
)
->
elems
[
idx
].
val
==
val
&&
idx
>=
0
)
{
(
*
pHisto
)
->
elems
[
idx
].
num
+=
1
;
...
...
@@ -356,7 +357,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
return
0
;
}
int32_t
vnodeHistob
inarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
)
{
int32_t
histoB
inarySearch
(
SHistBin
*
pEntry
,
int32_t
len
,
double
val
)
{
int32_t
end
=
len
-
1
;
int32_t
start
=
0
;
...
...
@@ -466,7 +467,7 @@ void tHistogramPrint(SHistogramInfo* pHisto) {
*/
int64_t
tHistogramSum
(
SHistogramInfo
*
pHisto
,
double
v
)
{
#if defined(USE_ARRAYLIST)
int32_t
slotIdx
=
vnodeHistob
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
v
);
int32_t
slotIdx
=
histoB
inarySearch
(
pHisto
->
elems
,
pHisto
->
numOfEntries
,
v
);
if
(
pHisto
->
elems
[
slotIdx
].
val
!=
v
)
{
slotIdx
-=
1
;
...
...
src/query/src/qUtil.c
浏览文件 @
4c04ce09
...
...
@@ -96,8 +96,6 @@ void resetResultRowInfo(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRo
pResultRowInfo
->
curIndex
=
-
1
;
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
startTime
=
TSKEY_INITIAL_VAL
;
pResultRowInfo
->
prevSKey
=
TSKEY_INITIAL_VAL
;
}
...
...
@@ -110,7 +108,7 @@ void popFrontResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow
assert
(
num
>=
0
&&
num
<=
numOfClosed
);
int16_t
type
=
pResultRowInfo
->
type
;
int64_t
uid
=
getResultInfoUId
(
pRuntimeEnv
)
;
int64_t
uid
=
0
;
char
*
key
=
NULL
;
int16_t
bytes
=
-
1
;
...
...
@@ -181,11 +179,12 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) {
assert
(
pResultRowInfo
->
size
>=
0
&&
pResultRowInfo
->
capacity
>=
pResultRowInfo
->
size
);
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
if
(
pResultRowInfo
->
pResult
[
i
]
->
closed
)
{
SResultRow
*
pRow
=
pResultRowInfo
->
pResult
[
i
];
if
(
pRow
->
closed
)
{
continue
;
}
pR
esultRowInfo
->
pResult
[
i
]
->
closed
=
true
;
pR
ow
->
closed
=
true
;
}
}
...
...
@@ -383,18 +382,4 @@ void* destroyResultRowPool(SResultRowPool* p) {
tfree
(
p
);
return
NULL
;
}
uint64_t
getResultInfoUId
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
if
(
!
pRuntimeEnv
->
stableQuery
)
{
return
0
;
// for simple table query, the uid is always set to be 0;
}
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
(
pQuery
->
interval
.
interval
==
0
||
isPointInterpoQuery
(
pQuery
)
||
pRuntimeEnv
->
groupbyNormalCol
)
{
return
0
;
}
STableId
*
id
=
TSDB_TABLEID
(
pRuntimeEnv
->
pQuery
->
current
->
pTable
);
return
id
->
uid
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录