Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
502efb3d
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
502efb3d
编写于
5月 15, 2023
作者:
L
liuyao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
op stream selectivity buff
上级
4c64260a
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
73 addition
and
42 deletion
+73
-42
include/common/tcommon.h
include/common/tcommon.h
+1
-1
include/libs/stream/streamState.h
include/libs/stream/streamState.h
+2
-3
include/libs/stream/tstreamFileState.h
include/libs/stream/tstreamFileState.h
+3
-2
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+36
-12
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+2
-7
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+17
-13
source/libs/stream/src/tstreamFileState.c
source/libs/stream/src/tstreamFileState.c
+12
-4
未找到文件。
include/common/tcommon.h
浏览文件 @
502efb3d
...
...
@@ -82,7 +82,7 @@ typedef struct STuplePos {
int32_t
pageId
;
int32_t
offset
;
};
S
Tuple
Key
streamTupleKey
;
S
Win
Key
streamTupleKey
;
};
}
STuplePos
;
...
...
include/libs/stream/streamState.h
浏览文件 @
502efb3d
...
...
@@ -77,9 +77,8 @@ typedef struct {
int64_t
number
;
}
SStreamStateCur
;
int32_t
streamStateFuncPut
(
SStreamState
*
pState
,
const
STupleKey
*
key
,
const
void
*
value
,
int32_t
vLen
);
int32_t
streamStateFuncGet
(
SStreamState
*
pState
,
const
STupleKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
int32_t
streamStateFuncDel
(
SStreamState
*
pState
,
const
STupleKey
*
key
);
int32_t
streamStateFuncPut
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
const
void
*
value
,
int32_t
vLen
);
int32_t
streamStateFuncGet
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
void
**
ppVal
,
int32_t
*
pVLen
);
int32_t
streamStatePut
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
const
void
*
value
,
int32_t
vLen
);
int32_t
streamStateGet
(
SStreamState
*
pState
,
const
SWinKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
);
...
...
include/libs/stream/tstreamFileState.h
浏览文件 @
502efb3d
...
...
@@ -38,8 +38,8 @@ typedef SList SStreamSnapshot;
typedef
TSKEY
(
*
GetTsFun
)(
void
*
);
SStreamFileState
*
streamFileStateInit
(
int64_t
memSize
,
uint32_t
keySize
,
uint32_t
rowSize
,
GetTsFun
fp
,
void
*
pFil
e
,
TSKEY
delMark
);
SStreamFileState
*
streamFileStateInit
(
int64_t
memSize
,
uint32_t
keySize
,
uint32_t
rowSize
,
uint32_t
selectRowSiz
e
,
GetTsFun
fp
,
void
*
pFile
,
TSKEY
delMark
);
void
streamFileStateDestroy
(
SStreamFileState
*
pFileState
);
void
streamFileStateClear
(
SStreamFileState
*
pFileState
);
bool
needClearDiskBuff
(
SStreamFileState
*
pFileState
);
...
...
@@ -56,6 +56,7 @@ int32_t recoverSnapshot(SStreamFileState* pFileState);
int32_t
getSnapshotIdList
(
SStreamFileState
*
pFileState
,
SArray
*
list
);
int32_t
deleteExpiredCheckPoint
(
SStreamFileState
*
pFileState
,
TSKEY
mark
);
int32_t
streamFileStateGeSelectRowSize
(
SStreamFileState
*
pFileState
);
#ifdef __cplusplus
}
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
502efb3d
...
...
@@ -2675,6 +2675,29 @@ TSKEY compareTs(void* pKey) {
return
pWinKey
->
ts
;
}
int32_t
getSelectivityBufSize
(
SqlFunctionCtx
*
pCtx
)
{
if
(
pCtx
->
subsidiaries
.
rowLen
==
0
)
{
int32_t
rowLen
=
0
;
for
(
int32_t
j
=
0
;
j
<
pCtx
->
subsidiaries
.
num
;
++
j
)
{
SqlFunctionCtx
*
pc
=
pCtx
->
subsidiaries
.
pCtx
[
j
];
rowLen
+=
pc
->
pExpr
->
base
.
resSchema
.
bytes
;
}
return
rowLen
+
pCtx
->
subsidiaries
.
num
*
sizeof
(
bool
);
}
else
{
return
pCtx
->
subsidiaries
.
rowLen
;
}
}
int32_t
getMaxFunResSize
(
SExprSupp
*
pSup
,
int32_t
numOfCols
)
{
int32_t
size
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
int32_t
resSize
=
getSelectivityBufSize
(
pSup
->
pCtx
+
i
);
size
=
TMAX
(
size
,
resSize
);
}
return
size
;
}
SOperatorInfo
*
createStreamFinalIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
int32_t
numOfChild
)
{
SIntervalPhysiNode
*
pIntervalPhyNode
=
(
SIntervalPhysiNode
*
)
pPhyNode
;
...
...
@@ -2721,8 +2744,11 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
SSDataBlock
*
pResBlock
=
createDataBlockFromDescNode
(
pPhyNode
->
pOutputDataBlockDesc
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
pInfo
->
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
*
(
pInfo
->
pState
)
=
*
(
pTaskInfo
->
streamInfo
.
pState
);
streamStateSetNumber
(
pInfo
->
pState
,
-
1
);
int32_t
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
p
TaskInfo
->
streamInfo
.
pState
);
p
Info
->
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -2731,10 +2757,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
pInfo
->
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
*
(
pInfo
->
pState
)
=
*
(
pTaskInfo
->
streamInfo
.
pState
);
streamStateSetNumber
(
pInfo
->
pState
,
-
1
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pInfo
->
numOfChild
=
numOfChild
;
...
...
@@ -2767,7 +2789,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
pInfo
->
numOfDatapack
=
0
;
pInfo
->
pUpdated
=
NULL
;
pInfo
->
pUpdatedMap
=
NULL
;
pInfo
->
pState
->
pFileState
=
streamFileStateInit
(
tsStreamBufferSize
,
sizeof
(
SWinKey
),
pInfo
->
aggSup
.
resultRowSize
,
int32_t
funResSize
=
getMaxFunResSize
(
&
pOperator
->
exprSupp
,
numOfCols
);
pInfo
->
pState
->
pFileState
=
streamFileStateInit
(
tsStreamBufferSize
,
sizeof
(
SWinKey
),
pInfo
->
aggSup
.
resultRowSize
,
funResSize
,
compareTs
,
pInfo
->
pState
,
pInfo
->
twAggSup
.
deleteMark
);
pInfo
->
dataVersion
=
0
;
...
...
@@ -4886,9 +4909,13 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
pInfo
->
primaryTsIndex
=
((
SColumnNode
*
)
pIntervalPhyNode
->
window
.
pTspk
)
->
slotId
;
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
pInfo
->
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
*
(
pInfo
->
pState
)
=
*
(
pTaskInfo
->
streamInfo
.
pState
);
streamStateSetNumber
(
pInfo
->
pState
,
-
1
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
code
=
initAggSup
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
p
TaskInfo
->
streamInfo
.
pState
);
p
Info
->
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -4909,10 +4936,6 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
pInfo
->
pDelRes
=
createSpecialDataBlock
(
STREAM_DELETE_RESULT
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
pInfo
->
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
*
(
pInfo
->
pState
)
=
*
(
pTaskInfo
->
streamInfo
.
pState
);
streamStateSetNumber
(
pInfo
->
pState
,
-
1
);
pInfo
->
pPhyNode
=
NULL
;
// create new child
pInfo
->
pPullDataMap
=
NULL
;
pInfo
->
pPullWins
=
NULL
;
// SPullWindowInfo
...
...
@@ -4925,7 +4948,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
pInfo
->
numOfDatapack
=
0
;
pInfo
->
pUpdated
=
NULL
;
pInfo
->
pUpdatedMap
=
NULL
;
pInfo
->
pState
->
pFileState
=
streamFileStateInit
(
tsStreamBufferSize
,
sizeof
(
SWinKey
),
pInfo
->
aggSup
.
resultRowSize
,
int32_t
funResSize
=
getMaxFunResSize
(
pSup
,
numOfCols
);
pInfo
->
pState
->
pFileState
=
streamFileStateInit
(
tsStreamBufferSize
,
sizeof
(
SWinKey
),
pInfo
->
aggSup
.
resultRowSize
,
funResSize
,
compareTs
,
pInfo
->
pState
,
pInfo
->
twAggSup
.
deleteMark
);
setOperatorInfo
(
pOperator
,
"StreamIntervalOperator"
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL
,
true
,
OP_NOT_OPENED
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
502efb3d
...
...
@@ -881,10 +881,6 @@ int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STu
}
pStart
+=
pDstCol
->
info
.
bytes
;
}
if
(
pCtx
->
saveHandle
.
pState
)
{
streamFreeVal
((
void
*
)
p
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -3121,7 +3117,7 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid
return
buf
;
}
static
int32_t
doSaveTupleData
(
SSerializeDataHandle
*
pHandle
,
const
void
*
pBuf
,
size_t
length
,
S
Tuple
Key
*
key
,
static
int32_t
doSaveTupleData
(
SSerializeDataHandle
*
pHandle
,
const
void
*
pBuf
,
size_t
length
,
S
Win
Key
*
key
,
STuplePos
*
pPos
)
{
STuplePos
p
=
{
0
};
if
(
pHandle
->
pBuf
!=
NULL
)
{
...
...
@@ -3169,7 +3165,7 @@ static int32_t doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf,
int32_t
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STuplePos
*
pPos
)
{
prepareBuf
(
pCtx
);
S
Tuple
Key
key
;
S
Win
Key
key
;
if
(
pCtx
->
saveHandle
.
pBuf
==
NULL
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
0
);
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
...
...
@@ -3177,7 +3173,6 @@ int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock*
key
.
groupId
=
pSrcBlock
->
info
.
id
.
groupId
;
key
.
ts
=
skey
;
key
.
exprIdx
=
pCtx
->
exprIdx
;
}
}
...
...
source/libs/stream/src/streamState.c
浏览文件 @
502efb3d
...
...
@@ -262,26 +262,30 @@ int32_t streamStateCommit(SStreamState* pState) {
#endif
}
int32_t
streamStateFuncPut
(
SStreamState
*
pState
,
const
S
Tuple
Key
*
key
,
const
void
*
value
,
int32_t
vLen
)
{
int32_t
streamStateFuncPut
(
SStreamState
*
pState
,
const
S
Win
Key
*
key
,
const
void
*
value
,
int32_t
vLen
)
{
#ifdef USE_ROCKSDB
return
streamStateFuncPut_rocksdb
(
pState
,
key
,
value
,
vLen
);
void
*
pVal
=
NULL
;
int32_t
len
=
0
;
int32_t
code
=
getRowBuff
(
pState
->
pFileState
,
(
void
*
)
key
,
sizeof
(
SWinKey
),
&
pVal
,
&
len
);
char
*
buf
=
((
SRowBuffPos
*
)
pVal
)
->
pRowBuff
;
uint32_t
rowSize
=
streamFileStateGeSelectRowSize
(
pState
->
pFileState
);
memcpy
(
buf
+
len
-
rowSize
,
value
,
vLen
);
return
code
;
#else
return
tdbTbUpsert
(
pState
->
pTdbState
->
pFuncStateDb
,
key
,
sizeof
(
STupleKey
),
value
,
vLen
,
pState
->
pTdbState
->
txn
);
#endif
}
int32_t
streamStateFuncGet
(
SStreamState
*
pState
,
const
S
TupleKey
*
key
,
void
**
pVal
,
int32_t
*
pVLen
)
{
int32_t
streamStateFuncGet
(
SStreamState
*
pState
,
const
S
WinKey
*
key
,
void
**
p
pVal
,
int32_t
*
pVLen
)
{
#ifdef USE_ROCKSDB
return
streamStateFuncGet_rocksdb
(
pState
,
key
,
pVal
,
pVLen
);
#else
return
tdbTbGet
(
pState
->
pTdbState
->
pFuncStateDb
,
key
,
sizeof
(
STupleKey
),
pVal
,
pVLen
);
#endif
}
int32_t
streamStateFuncDel
(
SStreamState
*
pState
,
const
STupleKey
*
key
)
{
#ifdef USE_ROCKSDB
return
streamStateFuncDel_rocksdb
(
pState
,
key
);
void
*
pVal
=
NULL
;
int32_t
len
=
0
;
int32_t
code
=
getRowBuff
(
pState
->
pFileState
,
(
void
*
)
key
,
sizeof
(
SWinKey
),
(
void
**
)(
&
pVal
),
&
len
);
char
*
buf
=
((
SRowBuffPos
*
)
pVal
)
->
pRowBuff
;
uint32_t
rowSize
=
streamFileStateGeSelectRowSize
(
pState
->
pFileState
);
*
ppVal
=
buf
+
len
-
rowSize
;
return
code
;
#else
return
tdbTb
Delete
(
pState
->
pTdbState
->
pFuncStateDb
,
key
,
sizeof
(
STupleKey
),
pState
->
pTdbState
->
tx
n
);
return
tdbTb
Get
(
pState
->
pTdbState
->
pFuncStateDb
,
key
,
sizeof
(
STupleKey
),
ppVal
,
pVLe
n
);
#endif
}
...
...
source/libs/stream/src/tstreamFileState.c
浏览文件 @
502efb3d
...
...
@@ -31,6 +31,7 @@ struct SStreamFileState {
SSHashObj
*
rowBuffMap
;
void
*
pFileStore
;
int32_t
rowSize
;
int32_t
selectivityRowSize
;
int32_t
keyLen
;
uint64_t
preCheckPointVersion
;
uint64_t
checkPointVersion
;
...
...
@@ -44,7 +45,7 @@ struct SStreamFileState {
typedef
SRowBuffPos
SRowBuffInfo
;
SStreamFileState
*
streamFileStateInit
(
int64_t
memSize
,
uint32_t
keySize
,
uint32_t
rowSize
,
GetTsFun
fp
,
void
*
pFile
,
SStreamFileState
*
streamFileStateInit
(
int64_t
memSize
,
uint32_t
keySize
,
uint32_t
rowSize
,
uint32_t
selectRowSize
,
GetTsFun
fp
,
void
*
pFile
,
TSKEY
delMark
)
{
if
(
memSize
<=
0
)
{
memSize
=
DEFAULT_MAX_STREAM_BUFFER_SIZE
;
...
...
@@ -57,6 +58,7 @@ SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_
if
(
!
pFileState
)
{
goto
_error
;
}
rowSize
+=
selectRowSize
;
pFileState
->
maxRowCount
=
TMAX
((
uint64_t
)
memSize
/
rowSize
,
FLUSH_NUM
*
2
);
pFileState
->
usedBuffs
=
tdListNew
(
POINTER_BYTES
);
pFileState
->
freeBuffs
=
tdListNew
(
POINTER_BYTES
);
...
...
@@ -68,11 +70,11 @@ SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_
}
pFileState
->
keyLen
=
keySize
;
pFileState
->
rowSize
=
rowSize
;
pFileState
->
selectivityRowSize
=
selectRowSize
;
pFileState
->
preCheckPointVersion
=
0
;
pFileState
->
checkPointVersion
=
1
;
pFileState
->
pFileStore
=
pFile
;
pFileState
->
getTs
=
fp
;
pFileState
->
maxRowCount
=
TMAX
((
uint64_t
)
memSize
/
rowSize
,
FLUSH_NUM
*
2
);
pFileState
->
curRowCount
=
0
;
pFileState
->
deleteMark
=
delMark
;
pFileState
->
flushMark
=
INT64_MIN
;
...
...
@@ -440,7 +442,9 @@ int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark) {
int32_t
recoverSnapshot
(
SStreamFileState
*
pFileState
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
pFileState
->
maxTs
!=
INT64_MIN
)
{
deleteExpiredCheckPoint
(
pFileState
,
pFileState
->
maxTs
-
pFileState
->
deleteMark
);
}
void
*
pStVal
=
NULL
;
int32_t
len
=
0
;
...
...
@@ -476,3 +480,7 @@ int32_t recoverSnapshot(SStreamFileState* pFileState) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
streamFileStateGeSelectRowSize
(
SStreamFileState
*
pFileState
)
{
return
pFileState
->
selectivityRowSize
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录