Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
501bec87
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
501bec87
编写于
6月 25, 2022
作者:
L
Liu Jicong
提交者:
GitHub
6月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14261 from taosdata/feature/stream
enh(stream): refine tqRetrieveDataBlock api
上级
5fd2f9a3
0c1a51ba
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
93 addition
and
101 deletion
+93
-101
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+13
-13
source/client/src/clientMain.c
source/client/src/clientMain.c
+13
-18
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+5
-4
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+13
-14
source/dnode/vnode/src/tq/tqExec.c
source/dnode/vnode/src/tq/tqExec.c
+2
-2
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+6
-10
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+41
-40
未找到文件。
source/client/src/clientImpl.c
浏览文件 @
501bec87
...
@@ -617,12 +617,12 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
...
@@ -617,12 +617,12 @@ int32_t scheduleAsyncQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNod
.
requestId
=
pRequest
->
requestId
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
.
requestObjRefId
=
pRequest
->
self
};
SSchedulerReq
req
=
{.
pConn
=
&
conn
,
SSchedulerReq
req
=
{.
pConn
=
&
conn
,
.
pNodeList
=
pNodeList
,
.
pNodeList
=
pNodeList
,
.
pDag
=
pDag
,
.
pDag
=
pDag
,
.
sql
=
pRequest
->
sqlstr
,
.
sql
=
pRequest
->
sqlstr
,
.
startTs
=
pRequest
->
metric
.
start
,
.
startTs
=
pRequest
->
metric
.
start
,
.
fp
=
schdExecCallback
,
.
fp
=
schdExecCallback
,
.
cbParam
=
&
res
};
.
cbParam
=
&
res
};
int32_t
code
=
schedulerAsyncExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
int32_t
code
=
schedulerAsyncExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
);
...
@@ -669,13 +669,13 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -669,13 +669,13 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
.
requestId
=
pRequest
->
requestId
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
.
requestObjRefId
=
pRequest
->
self
};
SSchedulerReq
req
=
{.
pConn
=
&
conn
,
SSchedulerReq
req
=
{.
pConn
=
&
conn
,
.
pNodeList
=
pNodeList
,
.
pNodeList
=
pNodeList
,
.
pDag
=
pDag
,
.
pDag
=
pDag
,
.
sql
=
pRequest
->
sqlstr
,
.
sql
=
pRequest
->
sqlstr
,
.
startTs
=
pRequest
->
metric
.
start
,
.
startTs
=
pRequest
->
metric
.
start
,
.
fp
=
NULL
,
.
fp
=
NULL
,
.
cbParam
=
NULL
,
.
cbParam
=
NULL
,
.
reqKilled
=
&
pRequest
->
killed
};
.
reqKilled
=
&
pRequest
->
killed
};
int32_t
code
=
schedulerExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
,
&
res
);
int32_t
code
=
schedulerExecJob
(
&
req
,
&
pRequest
->
body
.
queryJob
,
&
res
);
pRequest
->
body
.
resInfo
.
execRes
=
res
.
res
;
pRequest
->
body
.
resInfo
.
execRes
=
res
.
res
;
...
...
source/client/src/clientMain.c
浏览文件 @
501bec87
...
@@ -199,10 +199,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
...
@@ -199,10 +199,7 @@ TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) {
return
pResInfo
->
userFields
;
return
pResInfo
->
userFields
;
}
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
)
{
return
taosQueryImpl
(
taos
,
sql
,
false
);
}
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
)
{
return
taosQueryImpl
(
taos
,
sql
,
false
);
}
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
)
{
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
...
@@ -593,11 +590,11 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
...
@@ -593,11 +590,11 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) {
return
pResInfo
->
pCol
[
columnIndex
].
offset
;
return
pResInfo
->
pCol
[
columnIndex
].
offset
;
}
}
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
)
{
int
taos_validate_sql
(
TAOS
*
taos
,
const
char
*
sql
)
{
TAOS_RES
*
pObj
=
taosQueryImpl
(
taos
,
sql
,
true
);
TAOS_RES
*
pObj
=
taosQueryImpl
(
taos
,
sql
,
true
);
int
code
=
taos_errno
(
pObj
);
int
code
=
taos_errno
(
pObj
);
taos_free_result
(
pObj
);
taos_free_result
(
pObj
);
return
code
;
return
code
;
}
}
...
@@ -884,10 +881,10 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
...
@@ -884,10 +881,10 @@ void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress) {
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
)
{
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
)
{
const
int32_t
MAX_TABLE_NAME_LENGTH
=
12
*
1024
*
1024
;
// 12MB list
const
int32_t
MAX_TABLE_NAME_LENGTH
=
12
*
1024
*
1024
;
// 12MB list
int32_t
code
=
0
;
int32_t
code
=
0
;
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
SCatalogReq
catalogReq
=
{
0
};
SCatalogReq
catalogReq
=
{
0
};
if
(
NULL
==
tableNameList
)
{
if
(
NULL
==
tableNameList
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -911,26 +908,25 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
...
@@ -911,26 +908,25 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) {
goto
_return
;
goto
_return
;
}
}
SCatalog
*
pCtg
=
NULL
;
SCatalog
*
pCtg
=
NULL
;
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCtg
);
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCtg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_return
;
goto
_return
;
}
}
char
*
sql
=
"taos_load_table_info"
;
char
*
sql
=
"taos_load_table_info"
;
code
=
buildRequest
(
pTscObj
,
sql
,
strlen
(
sql
),
&
pRequest
);
code
=
buildRequest
(
pTscObj
,
sql
,
strlen
(
sql
),
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
terrno
=
code
;
goto
_return
;
goto
_return
;
}
}
SSyncQueryParam
param
=
{
0
};
SSyncQueryParam
param
=
{
0
};
tsem_init
(
&
param
.
sem
,
0
,
0
);
tsem_init
(
&
param
.
sem
,
0
,
0
);
param
.
pRequest
=
pRequest
;
param
.
pRequest
=
pRequest
;
SRequestConnInfo
conn
=
{.
pTrans
=
pTscObj
->
pAppInfo
->
pTransporter
,
SRequestConnInfo
conn
=
{
.
requestId
=
pRequest
->
requestId
,
.
pTrans
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
.
requestObjRefId
=
pRequest
->
self
};
conn
.
mgmtEps
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
conn
.
mgmtEps
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
...
@@ -951,7 +947,6 @@ _return:
...
@@ -951,7 +947,6 @@ _return:
return
code
;
return
code
;
}
}
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
TAOS_STMT
*
taos_stmt_init
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
STscObj
*
pObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
NULL
==
pObj
)
{
if
(
NULL
==
pObj
)
{
...
...
source/common/src/tdatablock.c
浏览文件 @
501bec87
...
@@ -1164,7 +1164,7 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
...
@@ -1164,7 +1164,7 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
)
{
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
//ASSERT(numOfRows > 0);
//
ASSERT(numOfRows > 0);
if
(
numOfRows
==
0
)
{
if
(
numOfRows
==
0
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1657,12 +1657,13 @@ void blockDebugShowData(const SArray* dataBlocks, const char* flag) {
...
@@ -1657,12 +1657,13 @@ void blockDebugShowData(const SArray* dataBlocks, const char* flag) {
char
*
dumpBlockData
(
SSDataBlock
*
pDataBlock
,
const
char
*
flag
,
char
**
pDataBuf
)
{
char
*
dumpBlockData
(
SSDataBlock
*
pDataBlock
,
const
char
*
flag
,
char
**
pDataBuf
)
{
int32_t
size
=
2048
;
int32_t
size
=
2048
;
*
pDataBuf
=
taosMemoryCalloc
(
size
,
1
);
*
pDataBuf
=
taosMemoryCalloc
(
size
,
1
);
char
*
dumpBuf
=
*
pDataBuf
;
char
*
dumpBuf
=
*
pDataBuf
;
char
pBuf
[
128
]
=
{
0
};
char
pBuf
[
128
]
=
{
0
};
int32_t
colNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
colNum
=
taosArrayGetSize
(
pDataBlock
->
pDataBlock
);
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
rows
=
pDataBlock
->
info
.
rows
;
int32_t
len
=
0
;
int32_t
len
=
0
;
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"
\n
%s |block type %d |child id %d|
\n
"
,
flag
,
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
);
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"
\n
%s |block type %d |child id %d|
\n
"
,
flag
,
(
int32_t
)
pDataBlock
->
info
.
type
,
pDataBlock
->
info
.
childId
);
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
for
(
int32_t
j
=
0
;
j
<
rows
;
j
++
)
{
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"%s |"
,
flag
);
len
+=
snprintf
(
dumpBuf
+
len
,
size
-
len
,
"%s |"
,
flag
);
for
(
int32_t
k
=
0
;
k
<
colNum
;
k
++
)
{
for
(
int32_t
k
=
0
;
k
<
colNum
;
k
++
)
{
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
501bec87
...
@@ -116,18 +116,18 @@ typedef void *tsdbReaderT;
...
@@ -116,18 +116,18 @@ typedef void *tsdbReaderT;
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_RR_ORDER 3
#define BLOCK_LOAD_TABLE_RR_ORDER 3
int32_t
tsdbSetTableList
(
tsdbReaderT
reader
,
SArray
*
tableList
);
int32_t
tsdbSetTableList
(
tsdbReaderT
reader
,
SArray
*
tableList
);
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
tableList
,
uint64_t
qId
,
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
);
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLast
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
groupList
,
uint64_t
qId
,
tsdbReaderT
tsdbQueryCacheLast
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
void
*
pMemRef
);
int32_t
tsdbGetFileBlocksDistInfo
(
tsdbReaderT
*
pReader
,
STableBlockDistInfo
*
pTableBlockInfo
);
int32_t
tsdbGetFileBlocksDistInfo
(
tsdbReaderT
*
pReader
,
STableBlockDistInfo
*
pTableBlockInfo
);
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
int32_t
tsdbGetAllTableList
(
SMeta
*
pMeta
,
uint64_t
uid
,
SArray
*
list
);
int32_t
tsdbGetAllTableList
(
SMeta
*
pMeta
,
uint64_t
uid
,
SArray
*
list
);
int32_t
tsdbGetCtbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
);
int32_t
tsdbGetCtbIdList
(
SMeta
*
pMeta
,
int64_t
suid
,
SArray
*
list
);
void
*
tsdbGetIdx
(
SMeta
*
pMeta
);
void
*
tsdbGetIdx
(
SMeta
*
pMeta
);
void
*
tsdbGetIvtIdx
(
SMeta
*
pMeta
);
void
*
tsdbGetIvtIdx
(
SMeta
*
pMeta
);
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
bool
tsdbNextDataBlock
(
tsdbReaderT
pTsdbReadHandle
);
bool
tsdbNextDataBlock
(
tsdbReaderT
pTsdbReadHandle
);
void
tsdbRetrieveDataBlockInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
void
tsdbRetrieveDataBlockInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
...
@@ -150,8 +150,7 @@ int32_t tqReadHandleRemoveTbUidList(STqReadHandle *pHandle, const SArray *tbUidL
...
@@ -150,8 +150,7 @@ int32_t tqReadHandleRemoveTbUidList(STqReadHandle *pHandle, const SArray *tbUidL
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
bool
tqNextDataBlockFilterOut
(
STqReadHandle
*
pHandle
,
SHashObj
*
filterOutUids
);
bool
tqNextDataBlockFilterOut
(
STqReadHandle
*
pHandle
,
SHashObj
*
filterOutUids
);
int32_t
tqRetrieveDataBlock
(
SSDataBlock
*
pBlock
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
uint64_t
*
pUid
,
int32_t
tqRetrieveDataBlock
(
SSDataBlock
*
pBlock
,
STqReadHandle
*
pHandle
);
int32_t
*
pNumOfRows
);
// sma
// sma
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
int32_t
smaGetTSmaDays
(
SVnodeCfg
*
pCfg
,
void
*
pCont
,
uint32_t
contLen
,
int32_t
*
days
);
...
...
source/dnode/vnode/src/tq/tqExec.c
浏览文件 @
501bec87
...
@@ -112,7 +112,7 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR
...
@@ -112,7 +112,7 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR
tqReadHandleSetMsg
(
pReader
,
pReq
,
0
);
tqReadHandleSetMsg
(
pReader
,
pReq
,
0
);
while
(
tqNextDataBlock
(
pReader
))
{
while
(
tqNextDataBlock
(
pReader
))
{
SSDataBlock
block
=
{
0
};
SSDataBlock
block
=
{
0
};
if
(
tqRetrieveDataBlock
(
&
block
,
pReader
,
&
block
.
info
.
groupId
,
&
block
.
info
.
uid
,
&
block
.
info
.
rows
)
<
0
)
{
if
(
tqRetrieveDataBlock
(
&
block
,
pReader
)
<
0
)
{
if
(
terrno
==
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
)
continue
;
if
(
terrno
==
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
)
continue
;
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -129,7 +129,7 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR
...
@@ -129,7 +129,7 @@ int32_t tqDataExec(STQ* pTq, STqExecHandle* pExec, SSubmitReq* pReq, SMqDataBlkR
tqReadHandleSetMsg
(
pReader
,
pReq
,
0
);
tqReadHandleSetMsg
(
pReader
,
pReq
,
0
);
while
(
tqNextDataBlockFilterOut
(
pReader
,
pExec
->
execDb
.
pFilterOutTbUid
))
{
while
(
tqNextDataBlockFilterOut
(
pReader
,
pExec
->
execDb
.
pFilterOutTbUid
))
{
SSDataBlock
block
=
{
0
};
SSDataBlock
block
=
{
0
};
if
(
tqRetrieveDataBlock
(
&
block
,
pReader
,
&
block
.
info
.
groupId
,
&
block
.
info
.
uid
,
&
block
.
info
.
rows
)
<
0
)
{
if
(
tqRetrieveDataBlock
(
&
block
,
pReader
)
<
0
)
{
if
(
terrno
==
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
)
continue
;
if
(
terrno
==
TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND
)
continue
;
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
501bec87
...
@@ -146,10 +146,7 @@ bool tqNextDataBlockFilterOut(STqReadHandle* pHandle, SHashObj* filterOutUids) {
...
@@ -146,10 +146,7 @@ bool tqNextDataBlockFilterOut(STqReadHandle* pHandle, SHashObj* filterOutUids) {
return
false
;
return
false
;
}
}
int32_t
tqRetrieveDataBlock
(
SSDataBlock
*
pBlock
,
STqReadHandle
*
pHandle
,
uint64_t
*
pGroupId
,
uint64_t
*
pUid
,
int32_t
tqRetrieveDataBlock
(
SSDataBlock
*
pBlock
,
STqReadHandle
*
pHandle
)
{
int32_t
*
pNumOfRows
)
{
*
pUid
=
0
;
// TODO: cache multiple schema
// TODO: cache multiple schema
int32_t
sversion
=
htonl
(
pHandle
->
pBlock
->
sversion
);
int32_t
sversion
=
htonl
(
pHandle
->
pBlock
->
sversion
);
if
(
pHandle
->
cachedSchemaSuid
==
0
||
pHandle
->
cachedSchemaVer
!=
sversion
||
if
(
pHandle
->
cachedSchemaSuid
==
0
||
pHandle
->
cachedSchemaVer
!=
sversion
||
...
@@ -180,7 +177,6 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
...
@@ -180,7 +177,6 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
STSchema
*
pTschema
=
pHandle
->
pSchema
;
STSchema
*
pTschema
=
pHandle
->
pSchema
;
SSchemaWrapper
*
pSchemaWrapper
=
pHandle
->
pSchemaWrapper
;
SSchemaWrapper
*
pSchemaWrapper
=
pHandle
->
pSchemaWrapper
;
*
pNumOfRows
=
pHandle
->
msgIter
.
numOfRows
;
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
int32_t
colNumNeed
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
if
(
colNumNeed
==
0
)
{
if
(
colNumNeed
==
0
)
{
...
@@ -221,22 +217,22 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
...
@@ -221,22 +217,22 @@ int32_t tqRetrieveDataBlock(SSDataBlock* pBlock, STqReadHandle* pHandle, uint64_
}
}
}
}
if
(
blockDataEnsureCapacity
(
pBlock
,
*
pN
umOfRows
)
<
0
)
{
if
(
blockDataEnsureCapacity
(
pBlock
,
pHandle
->
msgIter
.
n
umOfRows
)
<
0
)
{
goto
FAIL
;
goto
FAIL
;
}
}
int32_t
colActual
=
blockDataGetNumOfCols
(
pBlock
);
int32_t
colActual
=
blockDataGetNumOfCols
(
pBlock
);
// TODO in stream shuffle case, fetch groupId
*
pGroupId
=
0
;
STSRowIter
iter
=
{
0
};
STSRowIter
iter
=
{
0
};
tdSTSRowIterInit
(
&
iter
,
pTschema
);
tdSTSRowIterInit
(
&
iter
,
pTschema
);
STSRow
*
row
;
STSRow
*
row
;
int32_t
curRow
=
0
;
int32_t
curRow
=
0
;
tInitSubmitBlkIter
(
&
pHandle
->
msgIter
,
pHandle
->
pBlock
,
&
pHandle
->
blkIter
);
tInitSubmitBlkIter
(
&
pHandle
->
msgIter
,
pHandle
->
pBlock
,
&
pHandle
->
blkIter
);
*
pUid
=
pHandle
->
msgIter
.
uid
;
// set the uid of table for submit block
pBlock
->
info
.
groupId
=
0
;
pBlock
->
info
.
uid
=
pHandle
->
msgIter
.
uid
;
// set the uid of table for submit block
pBlock
->
info
.
rows
=
pHandle
->
msgIter
.
numOfRows
;
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
while
((
row
=
tGetSubmitBlkNext
(
&
pHandle
->
blkIter
))
!=
NULL
)
{
tdSTSRowIterReset
(
&
iter
,
row
);
tdSTSRowIterReset
(
&
iter
,
row
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
501bec87
...
@@ -507,20 +507,21 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
...
@@ -507,20 +507,21 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
STableScanInfo
*
pInfo
=
pOperator
->
info
;
STableScanInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
if
(
pInfo
->
currentGroupId
==
-
1
)
{
if
(
pInfo
->
currentGroupId
==
-
1
)
{
pInfo
->
currentGroupId
++
;
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroupList
))
{
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroupList
))
{
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
return
NULL
;
return
NULL
;
}
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
tsdbCleanupReadHandle
(
pInfo
->
dataReader
);
tsdbCleanupReadHandle
(
pInfo
->
dataReader
);
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pInfo
->
readHandle
.
vnode
,
&
pInfo
->
cond
,
tableList
,
pInfo
->
queryId
,
pInfo
->
taskId
);
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pInfo
->
readHandle
.
vnode
,
&
pInfo
->
cond
,
tableList
,
pInfo
->
queryId
,
pInfo
->
taskId
);
pInfo
->
dataReader
=
pReader
;
pInfo
->
dataReader
=
pReader
;
}
}
SSDataBlock
*
result
=
doTableScanGroup
(
pOperator
);
SSDataBlock
*
result
=
doTableScanGroup
(
pOperator
);
if
(
result
)
{
if
(
result
)
{
return
result
;
return
result
;
}
}
...
@@ -530,7 +531,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
...
@@ -530,7 +531,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
return
NULL
;
return
NULL
;
}
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
tsdbSetTableList
(
pInfo
->
dataReader
,
tableList
);
tsdbSetTableList
(
pInfo
->
dataReader
,
tableList
);
tsdbResetReadHandle
(
pInfo
->
dataReader
,
&
pInfo
->
cond
,
0
);
tsdbResetReadHandle
(
pInfo
->
dataReader
,
&
pInfo
->
cond
,
0
);
...
@@ -538,7 +539,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
...
@@ -538,7 +539,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
pInfo
->
scanTimes
=
0
;
pInfo
->
scanTimes
=
0
;
result
=
doTableScanGroup
(
pOperator
);
result
=
doTableScanGroup
(
pOperator
);
if
(
result
)
{
if
(
result
)
{
return
result
;
return
result
;
}
}
...
@@ -777,9 +778,9 @@ static bool isStateWindow(SStreamBlockScanInfo* pInfo) {
...
@@ -777,9 +778,9 @@ static bool isStateWindow(SStreamBlockScanInfo* pInfo) {
}
}
static
bool
prepareDataScan
(
SStreamBlockScanInfo
*
pInfo
,
SSDataBlock
*
pSDB
,
int32_t
tsColIndex
,
int32_t
*
pRowIndex
)
{
static
bool
prepareDataScan
(
SStreamBlockScanInfo
*
pInfo
,
SSDataBlock
*
pSDB
,
int32_t
tsColIndex
,
int32_t
*
pRowIndex
)
{
STimeWindow
win
=
{
STimeWindow
win
=
{
.
skey
=
INT64_MIN
,
.
skey
=
INT64_MIN
,
.
ekey
=
INT64_MAX
,
.
ekey
=
INT64_MAX
,
};
};
bool
needRead
=
false
;
bool
needRead
=
false
;
if
(
!
isStateWindow
(
pInfo
)
&&
(
*
pRowIndex
)
<
pSDB
->
info
.
rows
)
{
if
(
!
isStateWindow
(
pInfo
)
&&
(
*
pRowIndex
)
<
pSDB
->
info
.
rows
)
{
...
@@ -794,13 +795,12 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo, SSDataBlock* pSDB, int3
...
@@ -794,13 +795,12 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo, SSDataBlock* pSDB, int3
SResultWindowInfo
*
pCurWin
=
SResultWindowInfo
*
pCurWin
=
getSessionTimeWindow
(
pAggSup
,
tsCols
[(
*
pRowIndex
)],
INT64_MIN
,
pSDB
->
info
.
groupId
,
gap
,
&
winIndex
);
getSessionTimeWindow
(
pAggSup
,
tsCols
[(
*
pRowIndex
)],
INT64_MIN
,
pSDB
->
info
.
groupId
,
gap
,
&
winIndex
);
win
=
pCurWin
->
win
;
win
=
pCurWin
->
win
;
(
*
pRowIndex
)
+=
(
*
pRowIndex
)
+=
updateSessionWindowInfo
(
pCurWin
,
tsCols
,
NULL
,
pSDB
->
info
.
rows
,
(
*
pRowIndex
),
gap
,
NULL
);
updateSessionWindowInfo
(
pCurWin
,
tsCols
,
NULL
,
pSDB
->
info
.
rows
,
(
*
pRowIndex
),
gap
,
NULL
);
}
else
{
}
else
{
win
=
getActiveTimeWindow
(
NULL
,
&
dumyInfo
,
tsCols
[(
*
pRowIndex
)],
&
pInfo
->
interval
,
win
=
pInfo
->
interval
.
precision
,
NULL
);
getActiveTimeWindow
(
NULL
,
&
dumyInfo
,
tsCols
[(
*
pRowIndex
)],
&
pInfo
->
interval
,
pInfo
->
interval
.
precision
,
NULL
);
(
*
pRowIndex
)
+=
getNumOfRowsInTimeWindow
(
&
pSDB
->
info
,
tsCols
,
(
*
pRowIndex
),
win
.
ekey
,
(
*
pRowIndex
)
+=
getNumOfRowsInTimeWindow
(
&
pSDB
->
info
,
tsCols
,
(
*
pRowIndex
),
win
.
ekey
,
binarySearchForKey
,
NULL
,
binarySearchForKey
,
NULL
,
TSDB_ORDER_ASC
);
TSDB_ORDER_ASC
);
}
}
needRead
=
true
;
needRead
=
true
;
}
else
if
(
isStateWindow
(
pInfo
))
{
}
else
if
(
isStateWindow
(
pInfo
))
{
...
@@ -821,7 +821,7 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo, SSDataBlock* pSDB, int3
...
@@ -821,7 +821,7 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo, SSDataBlock* pSDB, int3
STableScanInfo
*
pTableScanInfo
=
pInfo
->
pSnapshotReadOp
->
info
;
STableScanInfo
*
pTableScanInfo
=
pInfo
->
pSnapshotReadOp
->
info
;
pTableScanInfo
->
cond
.
twindows
[
0
]
=
win
;
pTableScanInfo
->
cond
.
twindows
[
0
]
=
win
;
pTableScanInfo
->
curTWinIdx
=
0
;
pTableScanInfo
->
curTWinIdx
=
0
;
// tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
// tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
// if (!pTableScanInfo->dataReader) {
// if (!pTableScanInfo->dataReader) {
// return false;
// return false;
// }
// }
...
@@ -1033,12 +1033,13 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
...
@@ -1033,12 +1033,13 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) {
while
(
tqNextDataBlock
(
pInfo
->
streamBlockReader
))
{
while
(
tqNextDataBlock
(
pInfo
->
streamBlockReader
))
{
SSDataBlock
block
=
{
0
};
SSDataBlock
block
=
{
0
};
uint64_t
groupId
=
0
;
uint64_t
uid
=
0
;
int32_t
numOfRows
=
0
;
// todo refactor
// todo refactor
int32_t
code
=
tqRetrieveDataBlock
(
&
block
,
pInfo
->
streamBlockReader
,
&
groupId
,
&
uid
,
&
numOfRows
);
int32_t
code
=
tqRetrieveDataBlock
(
&
block
,
pInfo
->
streamBlockReader
);
uint64_t
groupId
=
block
.
info
.
groupId
;
uint64_t
uid
=
block
.
info
.
uid
;
int32_t
numOfRows
=
block
.
info
.
rows
;
if
(
code
!=
TSDB_CODE_SUCCESS
||
numOfRows
==
0
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
||
numOfRows
==
0
)
{
pTaskInfo
->
code
=
code
;
pTaskInfo
->
code
=
code
;
...
@@ -1154,9 +1155,9 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
...
@@ -1154,9 +1155,9 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
return
tableIdList
;
return
tableIdList
;
}
}
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
S
TableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
S
ExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
,
uint64_t
queryId
,
STimeWindowAggSupp
*
pTwSup
,
uint64_t
queryId
,
uint64_t
taskId
)
{
uint64_t
taskId
)
{
SStreamBlockScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamBlockScanInfo
));
SStreamBlockScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamBlockScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
...
@@ -1743,14 +1744,14 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
...
@@ -1743,14 +1744,14 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pDescNode
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pDescNode
);
int32_t
num
=
0
;
int32_t
num
=
0
;
SArray
*
colList
=
extractColMatchInfo
(
pScanNode
->
pScanCols
,
pDescNode
,
&
num
,
COL_MATCH_FROM_COL_ID
);
SArray
*
colList
=
extractColMatchInfo
(
pScanNode
->
pScanCols
,
pDescNode
,
&
num
,
COL_MATCH_FROM_COL_ID
);
pInfo
->
accountId
=
pScanPhyNode
->
accountId
;
pInfo
->
accountId
=
pScanPhyNode
->
accountId
;
pInfo
->
pUser
=
taosMemoryStrDup
((
void
*
)
pUser
);
pInfo
->
pUser
=
taosMemoryStrDup
((
void
*
)
pUser
);
pInfo
->
showRewrite
=
pScanPhyNode
->
showRewrite
;
pInfo
->
showRewrite
=
pScanPhyNode
->
showRewrite
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pRes
=
pResBlock
;
pInfo
->
pCondition
=
pScanNode
->
node
.
pConditions
;
pInfo
->
pCondition
=
pScanNode
->
node
.
pConditions
;
pInfo
->
scanCols
=
colList
;
pInfo
->
scanCols
=
colList
;
initResultSizeInfo
(
pOperator
,
4096
);
initResultSizeInfo
(
pOperator
,
4096
);
...
@@ -1766,13 +1767,13 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
...
@@ -1766,13 +1767,13 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
pInfo
->
readHandle
=
*
(
SReadHandle
*
)
readHandle
;
pInfo
->
readHandle
=
*
(
SReadHandle
*
)
readHandle
;
}
}
pOperator
->
name
=
"SysTableScanOperator"
;
pOperator
->
name
=
"SysTableScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
;
pOperator
->
blocking
=
false
;
pOperator
->
blocking
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
exprSupp
.
numOfExprs
=
taosArrayGetSize
(
pResBlock
->
pDataBlock
);
pOperator
->
exprSupp
.
numOfExprs
=
taosArrayGetSize
(
pResBlock
->
pDataBlock
);
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doSysTableScan
,
NULL
,
NULL
,
destroySysScanOperator
,
NULL
,
NULL
,
NULL
);
createOperatorFpSet
(
operatorDummyOpenFn
,
doSysTableScan
,
NULL
,
NULL
,
destroySysScanOperator
,
NULL
,
NULL
,
NULL
);
...
@@ -1959,11 +1960,11 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
...
@@ -1959,11 +1960,11 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
goto
_error
;
goto
_error
;
}
}
pInfo
->
pTableList
=
pTableListInfo
;
pInfo
->
pTableList
=
pTableListInfo
;
pInfo
->
pColMatchInfo
=
colList
;
pInfo
->
pColMatchInfo
=
colList
;
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pInfo
->
curPos
=
0
;
pOperator
->
name
=
"TagScanOperator"
;
pOperator
->
name
=
"TagScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
...
@@ -2034,7 +2035,7 @@ typedef struct STableMergeScanInfo {
...
@@ -2034,7 +2035,7 @@ typedef struct STableMergeScanInfo {
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
dataBlockLoadFlag
;
int32_t
dataBlockLoadFlag
;
SInterval
interval
;
// if the upstream is an interval operator, the interval info is also kept here to get the time
SInterval
interval
;
// if the upstream is an interval operator, the interval info is also kept here to get the time
// window to check if current data block needs to be loaded.
// window to check if current data block needs to be loaded.
SSampleExecInfo
sample
;
// sample execution info
SSampleExecInfo
sample
;
// sample execution info
}
STableMergeScanInfo
;
}
STableMergeScanInfo
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录