Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
a9f0a30d
T
TDengine
项目概览
loser646
/
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,发现更多精彩内容 >>
提交
a9f0a30d
编写于
11月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-1870]<enhance>: optimize the memory consumption.
上级
2cd97574
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
107 addition
and
161 deletion
+107
-161
src/client/inc/tscLocalMerge.h
src/client/inc/tscLocalMerge.h
+2
-3
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+11
-11
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+4
-15
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-2
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+2
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+58
-109
src/query/src/qUtil.c
src/query/src/qUtil.c
+21
-16
src/util/src/hash.c
src/util/src/hash.c
+7
-3
未找到文件。
src/client/inc/tscLocalMerge.h
浏览文件 @
a9f0a30d
...
@@ -64,9 +64,8 @@ typedef struct SLocalReducer {
...
@@ -64,9 +64,8 @@ typedef struct SLocalReducer {
SColumnModel
*
resColModel
;
SColumnModel
*
resColModel
;
tExtMemBuffer
**
pExtMemBuffer
;
// disk-based buffer
tExtMemBuffer
**
pExtMemBuffer
;
// disk-based buffer
SFillInfo
*
pFillInfo
;
// interpolation support structure
SFillInfo
*
pFillInfo
;
// interpolation support structure
char
*
pFinalRes
;
// result data after interpo
char
*
pFinalRes
;
// result data after interpo
tFilePage
*
discardData
;
tFilePage
*
discardData
;
SResultRowCellInfo
*
pResInfo
;
bool
discard
;
bool
discard
;
int32_t
offset
;
// limit offset value
int32_t
offset
;
// limit offset value
bool
orderPrjOnSTable
;
// projection query on stable
bool
orderPrjOnSTable
;
// projection query on stable
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
a9f0a30d
...
@@ -99,7 +99,7 @@ typedef struct SSumInfo {
...
@@ -99,7 +99,7 @@ typedef struct SSumInfo {
// the attribute of hasResult is not needed since the num attribute would server as this purpose
// the attribute of hasResult is not needed since the num attribute would server as this purpose
typedef
struct
SAvgInfo
{
typedef
struct
SAvgInfo
{
double
sum
;
double
sum
;
int64_t
num
;
// num servers as the hasResult attribute in other struct
int64_t
num
;
}
SAvgInfo
;
}
SAvgInfo
;
typedef
struct
SStddevInfo
{
typedef
struct
SStddevInfo
{
...
@@ -167,7 +167,13 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
...
@@ -167,7 +167,13 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_INTERP
)
{
functionId
==
TSDB_FUNC_TAG
||
functionId
==
TSDB_FUNC_INTERP
)
{
*
type
=
(
int16_t
)
dataType
;
*
type
=
(
int16_t
)
dataType
;
*
bytes
=
(
int16_t
)
dataBytes
;
*
bytes
=
(
int16_t
)
dataBytes
;
*
interBytes
=
0
;
//*bytes;
if
(
functionId
==
TSDB_FUNC_INTERP
)
{
*
interBytes
=
sizeof
(
SInterpInfoDetail
);
}
else
{
*
interBytes
=
0
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -175,21 +181,21 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
...
@@ -175,21 +181,21 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
if
(
functionId
==
TSDB_FUNC_TID_TAG
)
{
// todo use struct
if
(
functionId
==
TSDB_FUNC_TID_TAG
)
{
// todo use struct
*
type
=
TSDB_DATA_TYPE_BINARY
;
*
type
=
TSDB_DATA_TYPE_BINARY
;
*
bytes
=
(
int16_t
)(
dataBytes
+
sizeof
(
int16_t
)
+
sizeof
(
int64_t
)
+
sizeof
(
int32_t
)
+
sizeof
(
int32_t
)
+
VARSTR_HEADER_SIZE
);
*
bytes
=
(
int16_t
)(
dataBytes
+
sizeof
(
int16_t
)
+
sizeof
(
int64_t
)
+
sizeof
(
int32_t
)
+
sizeof
(
int32_t
)
+
VARSTR_HEADER_SIZE
);
*
interBytes
=
0
;
//*bytes;
*
interBytes
=
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
functionId
==
TSDB_FUNC_COUNT
)
{
if
(
functionId
==
TSDB_FUNC_COUNT
)
{
*
type
=
TSDB_DATA_TYPE_BIGINT
;
*
type
=
TSDB_DATA_TYPE_BIGINT
;
*
bytes
=
sizeof
(
int64_t
);
*
bytes
=
sizeof
(
int64_t
);
*
interBytes
=
0
;
//*bytes;
*
interBytes
=
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
functionId
==
TSDB_FUNC_ARITHM
)
{
if
(
functionId
==
TSDB_FUNC_ARITHM
)
{
*
type
=
TSDB_DATA_TYPE_DOUBLE
;
*
type
=
TSDB_DATA_TYPE_DOUBLE
;
*
bytes
=
sizeof
(
double
);
*
bytes
=
sizeof
(
double
);
*
interBytes
=
0
;
//*bytes;
*
interBytes
=
0
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -334,11 +340,6 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
...
@@ -334,11 +340,6 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
//void setResultInfoBuf(SResultRowCellInfo *pResInfo, char* buf) {
// assert(GET_ROWCELL_INTERBUF(pResInfo) == NULL);
// GET_ROWCELL_INTERBUF(pResInfo) = buf;
//}
// set the query flag to denote that query is completed
// set the query flag to denote that query is completed
static
void
no_next_step
(
SQLFunctionCtx
*
pCtx
)
{
static
void
no_next_step
(
SQLFunctionCtx
*
pCtx
)
{
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
...
@@ -3998,7 +3999,6 @@ static void interp_function(SQLFunctionCtx *pCtx) {
...
@@ -3998,7 +3999,6 @@ static void interp_function(SQLFunctionCtx *pCtx) {
}
}
}
}
}
}
}
}
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
a9f0a30d
...
@@ -99,11 +99,8 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
...
@@ -99,11 +99,8 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
pCtx
->
param
[
1
].
i64Key
=
pQueryInfo
->
order
.
orderColId
;
pCtx
->
param
[
1
].
i64Key
=
pQueryInfo
->
order
.
orderColId
;
}
}
// SResultRowCellInfo *pResInfo = &pReducer->pResInfo[i];
pCtx
->
interBufBytes
=
pExpr
->
interBytes
;
pCtx
->
interBufBytes
=
pExpr
->
interBytes
;
pCtx
->
resultInfo
=
calloc
(
1
,
pCtx
->
interBufBytes
+
sizeof
(
SResultRowCellInfo
));
// pResInfo->interResultBuf = calloc(1, (size_t) pCtx->interBufBytes);
pCtx
->
resultInfo
=
&
pReducer
->
pResInfo
[
i
];
pCtx
->
stableQuery
=
true
;
pCtx
->
stableQuery
=
true
;
}
}
...
@@ -345,7 +342,6 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -345,7 +342,6 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
size_t
numOfCols
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
size_t
numOfCols
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
pReducer
->
pTempBuffer
->
num
=
0
;
pReducer
->
pTempBuffer
->
num
=
0
;
pReducer
->
pResInfo
=
calloc
(
numOfCols
,
sizeof
(
SResultRowCellInfo
));
tscCreateResPointerInfo
(
pRes
,
pQueryInfo
);
tscCreateResPointerInfo
(
pRes
,
pQueryInfo
);
tscInitSqlContext
(
pCmd
,
pReducer
,
pDesc
);
tscInitSqlContext
(
pCmd
,
pReducer
,
pDesc
);
...
@@ -496,6 +492,8 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
...
@@ -496,6 +492,8 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
i
];
SQLFunctionCtx
*
pCtx
=
&
pLocalReducer
->
pCtx
[
i
];
tVariantDestroy
(
&
pCtx
->
tag
);
tVariantDestroy
(
&
pCtx
->
tag
);
taosTFree
(
pCtx
->
resultInfo
);
if
(
pCtx
->
tagInfo
.
pTagCtxList
!=
NULL
)
{
if
(
pCtx
->
tagInfo
.
pTagCtxList
!=
NULL
)
{
taosTFree
(
pCtx
->
tagInfo
.
pTagCtxList
);
taosTFree
(
pCtx
->
tagInfo
.
pTagCtxList
);
}
}
...
@@ -509,15 +507,6 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
...
@@ -509,15 +507,6 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
taosTFree
(
pLocalReducer
->
pTempBuffer
);
taosTFree
(
pLocalReducer
->
pTempBuffer
);
taosTFree
(
pLocalReducer
->
pResultBuf
);
taosTFree
(
pLocalReducer
->
pResultBuf
);
if
(
pLocalReducer
->
pResInfo
!=
NULL
)
{
size_t
num
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
// taosTFree(pLocalReducer->pResInfo[i].interResultBuf);
}
taosTFree
(
pLocalReducer
->
pResInfo
);
}
if
(
pLocalReducer
->
pLoserTree
)
{
if
(
pLocalReducer
->
pLoserTree
)
{
taosTFree
(
pLocalReducer
->
pLoserTree
->
param
);
taosTFree
(
pLocalReducer
->
pLoserTree
->
param
);
taosTFree
(
pLocalReducer
->
pLoserTree
);
taosTFree
(
pLocalReducer
->
pLoserTree
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
a9f0a30d
...
@@ -168,7 +168,7 @@ typedef struct SQuery {
...
@@ -168,7 +168,7 @@ typedef struct SQuery {
typedef
struct
SQueryRuntimeEnv
{
typedef
struct
SQueryRuntimeEnv
{
jmp_buf
env
;
jmp_buf
env
;
SResultRow
CellInfo
*
resultInfo
;
// todo refactor to merge with SWindowResInfo
SResultRow
*
pResultRow
;
// todo refactor to merge with SWindowResInfo
SQuery
*
pQuery
;
SQuery
*
pQuery
;
SQLFunctionCtx
*
pCtx
;
SQLFunctionCtx
*
pCtx
;
int32_t
numOfRowsPerPage
;
int32_t
numOfRowsPerPage
;
...
@@ -190,7 +190,7 @@ typedef struct SQueryRuntimeEnv {
...
@@ -190,7 +190,7 @@ typedef struct SQueryRuntimeEnv {
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
char
*
keyBuf
;
// window key buffer
char
*
keyBuf
;
// window key buffer
SResultRowPool
*
pool
;
// window result object pool
SResultRowPool
*
pool
;
// window result object pool
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
}
SQueryRuntimeEnv
;
}
SQueryRuntimeEnv
;
...
...
src/query/inc/qUtil.h
浏览文件 @
a9f0a30d
...
@@ -42,7 +42,7 @@ void closeTimeWindow(SWindowResInfo* pWindowResInfo, int32_t slot);
...
@@ -42,7 +42,7 @@ void closeTimeWindow(SWindowResInfo* pWindowResInfo, int32_t slot);
void
closeAllTimeWindow
(
SWindowResInfo
*
pWindowResInfo
);
void
closeAllTimeWindow
(
SWindowResInfo
*
pWindowResInfo
);
void
removeRedundantWindow
(
SWindowResInfo
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
);
void
removeRedundantWindow
(
SWindowResInfo
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
);
static
FORCE_INLINE
SResultRow
*
get
WindowResult
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
static
FORCE_INLINE
SResultRow
*
get
ResultRow
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
assert
(
pWindowResInfo
!=
NULL
&&
slot
>=
0
&&
slot
<
pWindowResInfo
->
size
);
assert
(
pWindowResInfo
!=
NULL
&&
slot
>=
0
&&
slot
<
pWindowResInfo
->
size
);
return
pWindowResInfo
->
pResult
[
slot
];
return
pWindowResInfo
->
pResult
[
slot
];
}
}
...
@@ -52,7 +52,7 @@ static FORCE_INLINE SResultRow *getWindowResult(SWindowResInfo *pWindowResInfo,
...
@@ -52,7 +52,7 @@ static FORCE_INLINE SResultRow *getWindowResult(SWindowResInfo *pWindowResInfo,
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
);
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
);
int32_t
createQueryResultInfo
(
SQuery
*
pQuery
,
SResultRow
*
pResultRow
);
int32_t
initResultRow
(
SResultRow
*
pResultRow
);
static
FORCE_INLINE
char
*
getPosInResultPage
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
columnIndex
,
SResultRow
*
pResult
,
static
FORCE_INLINE
char
*
getPosInResultPage
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
columnIndex
,
SResultRow
*
pResult
,
tFilePage
*
page
)
{
tFilePage
*
page
)
{
...
...
src/query/src/qExecutor.c
浏览文件 @
a9f0a30d
此差异已折叠。
点击以展开。
src/query/src/qUtil.c
浏览文件 @
a9f0a30d
...
@@ -87,7 +87,7 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
...
@@ -87,7 +87,7 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
assert
(
num
>=
0
&&
num
<=
numOfClosed
);
assert
(
num
>=
0
&&
num
<=
numOfClosed
);
int16_t
type
=
pWindowResInfo
->
type
;
int16_t
type
=
pWindowResInfo
->
type
;
uint64_t
uid
=
0
;
// uid is always set to be 0.
STableId
*
id
=
TSDB_TABLEID
(
pRuntimeEnv
->
pQuery
->
current
->
pTable
)
;
// uid is always set to be 0.
char
*
key
=
NULL
;
char
*
key
=
NULL
;
int16_t
bytes
=
-
1
;
int16_t
bytes
=
-
1
;
...
@@ -104,7 +104,7 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
...
@@ -104,7 +104,7 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
bytes
=
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
;
bytes
=
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
;
}
}
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
id
->
uid
);
taosHashRemove
(
pRuntimeEnv
->
pResultRowHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
taosHashRemove
(
pRuntimeEnv
->
pResultRowHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
}
else
{
}
else
{
break
;
break
;
...
@@ -137,14 +137,14 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
...
@@ -137,14 +137,14 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
bytes
=
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
;
bytes
=
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
;
}
}
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
id
->
uid
);
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pRuntimeEnv
->
pResultRowHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pRuntimeEnv
->
pResultRowHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
assert
(
p
!=
NULL
);
assert
(
p
!=
NULL
);
int32_t
v
=
(
*
p
-
num
);
int32_t
v
=
(
*
p
-
num
);
assert
(
v
>=
0
&&
v
<=
pWindowResInfo
->
size
);
assert
(
v
>=
0
&&
v
<=
pWindowResInfo
->
size
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
uid
);
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
key
,
bytes
,
id
->
uid
);
taosHashPut
(
pRuntimeEnv
->
pResultRowHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
(
char
*
)
&
v
,
sizeof
(
int32_t
));
taosHashPut
(
pRuntimeEnv
->
pResultRowHashTable
,
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
(
char
*
)
&
v
,
sizeof
(
int32_t
));
}
}
...
@@ -217,11 +217,11 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
...
@@ -217,11 +217,11 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
}
}
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
return
(
get
WindowResult
(
pWindowResInfo
,
slot
)
->
closed
==
true
);
return
(
get
ResultRow
(
pWindowResInfo
,
slot
)
->
closed
==
true
);
}
}
void
closeTimeWindow
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
void
closeTimeWindow
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
get
WindowResult
(
pWindowResInfo
,
slot
)
->
closed
=
true
;
get
ResultRow
(
pWindowResInfo
,
slot
)
->
closed
=
true
;
}
}
void
clearResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pWindowRes
)
{
void
clearResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pWindowRes
)
{
...
@@ -229,18 +229,21 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pWindowRes) {
...
@@ -229,18 +229,21 @@ void clearResultRow(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pWindowRes) {
return
;
return
;
}
}
tFilePage
*
page
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pWindowRes
->
pageId
);
// the result does not put into the SDiskbasedResultBuf, ignore it.
if
(
pWindowRes
->
pageId
>=
0
)
{
tFilePage
*
page
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pWindowRes
->
pageId
);
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQuery
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRuntimeEnv
->
pQuery
->
numOfOutput
;
++
i
)
{
SResultRowCellInfo
*
pResultInfo
=
&
pWindowRes
->
pCellInfo
[
i
];
SResultRowCellInfo
*
pResultInfo
=
&
pWindowRes
->
pCellInfo
[
i
];
char
*
s
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
pWindowRes
,
page
);
char
*
s
=
getPosInResultPage
(
pRuntimeEnv
,
i
,
pWindowRes
,
page
);
size_t
size
=
pRuntimeEnv
->
pQuery
->
pSelectExpr
[
i
].
bytes
;
size_t
size
=
pRuntimeEnv
->
pQuery
->
pSelectExpr
[
i
].
bytes
;
memset
(
s
,
0
,
size
);
memset
(
s
,
0
,
size
);
RESET_RESULT_INFO
(
pResultInfo
);
RESET_RESULT_INFO
(
pResultInfo
);
}
}
}
pWindowRes
->
numOfRows
=
0
;
pWindowRes
->
numOfRows
=
0
;
pWindowRes
->
pageId
=
-
1
;
pWindowRes
->
pageId
=
-
1
;
pWindowRes
->
rowId
=
-
1
;
pWindowRes
->
rowId
=
-
1
;
...
@@ -327,6 +330,8 @@ SResultRow* getNewResultRow(SResultRowPool* p) {
...
@@ -327,6 +330,8 @@ SResultRow* getNewResultRow(SResultRowPool* p) {
}
}
p
->
position
.
pos
=
(
p
->
position
.
pos
+
1
)
%
p
->
numOfElemPerBlock
;
p
->
position
.
pos
=
(
p
->
position
.
pos
+
1
)
%
p
->
numOfElemPerBlock
;
initResultRow
(
ptr
);
return
ptr
;
return
ptr
;
}
}
...
...
src/util/src/hash.c
浏览文件 @
a9f0a30d
...
@@ -114,10 +114,12 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p
...
@@ -114,10 +114,12 @@ static SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *p
* @param dsize size of actual data
* @param dsize size of actual data
* @return hash node
* @return hash node
*/
*/
static
FORCE_INLINE
SHashNode
*
doUpdateHashNode
(
SHashNode
*
prev
,
SHashNode
*
pNode
,
SHashNode
*
pNewNode
)
{
static
FORCE_INLINE
SHashNode
*
doUpdateHashNode
(
SHash
Entry
*
pe
,
SHash
Node
*
prev
,
SHashNode
*
pNode
,
SHashNode
*
pNewNode
)
{
assert
(
pNode
->
keyLen
==
pNewNode
->
keyLen
);
assert
(
pNode
->
keyLen
==
pNewNode
->
keyLen
);
if
(
prev
!=
NULL
)
{
if
(
prev
!=
NULL
)
{
prev
->
next
=
pNewNode
;
prev
->
next
=
pNewNode
;
}
else
{
pe
->
next
=
pNewNode
;
}
}
pNewNode
->
next
=
pNode
->
next
;
pNewNode
->
next
=
pNode
->
next
;
...
@@ -242,7 +244,10 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
...
@@ -242,7 +244,10 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
}
else
{
}
else
{
// not support the update operation, return error
// not support the update operation, return error
if
(
pHashObj
->
enableUpdate
)
{
if
(
pHashObj
->
enableUpdate
)
{
doUpdateHashNode
(
prev
,
pNode
,
pNewNode
);
doUpdateHashNode
(
pe
,
prev
,
pNode
,
pNewNode
);
DO_FREE_HASH_NODE
(
pNode
);
}
else
{
DO_FREE_HASH_NODE
(
pNewNode
);
}
}
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
if
(
pHashObj
->
type
==
HASH_ENTRY_LOCK
)
{
...
@@ -252,7 +257,6 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
...
@@ -252,7 +257,6 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, void *da
// enable resize
// enable resize
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
__rd_unlock
(
&
pHashObj
->
lock
,
pHashObj
->
type
);
DO_FREE_HASH_NODE
(
pNewNode
);
return
pHashObj
->
enableUpdate
?
0
:
-
1
;
return
pHashObj
->
enableUpdate
?
0
:
-
1
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录