Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6120c73a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
6120c73a
编写于
2月 24, 2023
作者:
H
Haojun Liao
提交者:
GitHub
2月 24, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20122 from taosdata/enh/TD-22715
fix: fix distributed table error
上级
d4d246c5
02d0894d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
40 deletion
+44
-40
include/common/tcommon.h
include/common/tcommon.h
+6
-6
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+9
-4
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+29
-30
未找到文件。
include/common/tcommon.h
浏览文件 @
6120c73a
...
@@ -205,7 +205,7 @@ typedef struct SDataBlockInfo {
...
@@ -205,7 +205,7 @@ typedef struct SDataBlockInfo {
STimeWindow
calWin
;
// used for stream, do not serialize
STimeWindow
calWin
;
// used for stream, do not serialize
TSKEY
watermark
;
// used for stream
TSKEY
watermark
;
// used for stream
char
parTbName
[
TSDB_TABLE_NAME_LEN
];
// used for stream partition
char
parTbName
[
TSDB_TABLE_NAME_LEN
];
// used for stream partition
}
SDataBlockInfo
;
}
SDataBlockInfo
;
typedef
struct
SSDataBlock
{
typedef
struct
SSDataBlock
{
...
@@ -291,7 +291,6 @@ typedef struct STableBlockDistInfo {
...
@@ -291,7 +291,6 @@ typedef struct STableBlockDistInfo {
uint16_t
numOfFiles
;
uint16_t
numOfFiles
;
uint32_t
numOfTables
;
uint32_t
numOfTables
;
uint32_t
numOfBlocks
;
uint32_t
numOfBlocks
;
uint32_t
numOfVgroups
;
uint64_t
totalSize
;
uint64_t
totalSize
;
uint64_t
totalRows
;
uint64_t
totalRows
;
int32_t
maxRows
;
int32_t
maxRows
;
...
@@ -301,6 +300,7 @@ typedef struct STableBlockDistInfo {
...
@@ -301,6 +300,7 @@ typedef struct STableBlockDistInfo {
int32_t
firstSeekTimeUs
;
int32_t
firstSeekTimeUs
;
uint32_t
numOfInmemRows
;
uint32_t
numOfInmemRows
;
uint32_t
numOfSmallBlocks
;
uint32_t
numOfSmallBlocks
;
uint32_t
numOfVgroups
;
int32_t
blockRowsHisto
[
20
];
int32_t
blockRowsHisto
[
20
];
}
STableBlockDistInfo
;
}
STableBlockDistInfo
;
...
@@ -341,7 +341,7 @@ typedef struct SExprInfo {
...
@@ -341,7 +341,7 @@ typedef struct SExprInfo {
typedef
struct
{
typedef
struct
{
const
char
*
key
;
const
char
*
key
;
size_t
keyLen
;
size_t
keyLen
;
uint8_t
type
;
uint8_t
type
;
union
{
union
{
const
char
*
value
;
const
char
*
value
;
...
@@ -385,9 +385,9 @@ typedef struct STUidTagInfo {
...
@@ -385,9 +385,9 @@ typedef struct STUidTagInfo {
#define TABLE_NAME_COLUMN_INDEX 6
#define TABLE_NAME_COLUMN_INDEX 6
// stream create table block column
// stream create table block column
#define UD_TABLE_NAME_COLUMN_INDEX
0
#define UD_TABLE_NAME_COLUMN_INDEX 0
#define UD_GROUPID_COLUMN_INDEX
1
#define UD_GROUPID_COLUMN_INDEX 1
#define UD_TAG_COLUMN_INDEX
2
#define UD_TAG_COLUMN_INDEX 2
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
6120c73a
...
@@ -488,7 +488,7 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb
...
@@ -488,7 +488,7 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
filesetIteratorNext
(
SFilesetIter
*
pIter
,
STsdbReader
*
pReader
,
bool
*
hasNext
)
{
static
int32_t
filesetIteratorNext
(
SFilesetIter
*
pIter
,
STsdbReader
*
pReader
,
bool
*
hasNext
)
{
bool
asc
=
ASCENDING_TRAVERSE
(
pIter
->
order
);
bool
asc
=
ASCENDING_TRAVERSE
(
pIter
->
order
);
int32_t
step
=
asc
?
1
:
-
1
;
int32_t
step
=
asc
?
1
:
-
1
;
pIter
->
index
+=
step
;
pIter
->
index
+=
step
;
...
@@ -2802,13 +2802,13 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
...
@@ -2802,13 +2802,13 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
SArray
*
pIndexList
=
taosArrayInit
(
numOfTables
,
sizeof
(
SBlockIdx
));
SArray
*
pIndexList
=
taosArrayInit
(
numOfTables
,
sizeof
(
SBlockIdx
));
while
(
1
)
{
while
(
1
)
{
bool
hasNext
=
false
;
bool
hasNext
=
false
;
int32_t
code
=
filesetIteratorNext
(
&
pStatus
->
fileIter
,
pReader
,
&
hasNext
);
int32_t
code
=
filesetIteratorNext
(
&
pStatus
->
fileIter
,
pReader
,
&
hasNext
);
if
(
code
)
{
if
(
code
)
{
taosArrayDestroy
(
pIndexList
);
taosArrayDestroy
(
pIndexList
);
return
code
;
return
code
;
}
}
if
(
!
hasNext
)
{
// no data files on disk
if
(
!
hasNext
)
{
// no data files on disk
break
;
break
;
}
}
...
@@ -4688,6 +4688,11 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
...
@@ -4688,6 +4688,11 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
pTableBlockInfo
->
numOfVgroups
=
1
;
pTableBlockInfo
->
numOfVgroups
=
1
;
// find the start data block in file
// find the start data block in file
tsdbAcquireReader
(
pReader
);
if
(
pReader
->
suspended
)
{
tsdbReaderResume
(
pReader
);
}
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
SReaderStatus
*
pStatus
=
&
pReader
->
status
;
STsdbCfg
*
pc
=
&
pReader
->
pTsdb
->
pVnode
->
config
.
tsdbCfg
;
STsdbCfg
*
pc
=
&
pReader
->
pTsdb
->
pVnode
->
config
.
tsdbCfg
;
...
@@ -4749,7 +4754,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
...
@@ -4749,7 +4754,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
// tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %s", pReader, numOfBlocks, numOfTables,
// tsdbDebug("%p %d blocks found in file for %d table(s), fid:%d, %s", pReader, numOfBlocks, numOfTables,
// pReader->pFileGroup->fid, pReader->idStr);
// pReader->pFileGroup->fid, pReader->idStr);
}
}
tsdbReleaseReader
(
pReader
);
return
code
;
return
code
;
}
}
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
6120c73a
...
@@ -775,13 +775,13 @@ int32_t maxFunction(SqlFunctionCtx* pCtx) {
...
@@ -775,13 +775,13 @@ int32_t maxFunction(SqlFunctionCtx* pCtx) {
static
int32_t
setNullSelectivityValue
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
);
static
int32_t
setNullSelectivityValue
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
);
static
int32_t
setSelectivityValue
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
const
STuplePos
*
pTuplePos
,
static
int32_t
setSelectivityValue
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
const
STuplePos
*
pTuplePos
,
int32_t
rowIndex
);
int32_t
rowIndex
);
int32_t
minmaxFunctionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
int32_t
minmaxFunctionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
SMinmaxResInfo
*
pRes
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
SMinmaxResInfo
*
pRes
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
int32_t
currentRow
=
pBlock
->
info
.
rows
;
int32_t
currentRow
=
pBlock
->
info
.
rows
;
...
@@ -795,7 +795,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -795,7 +795,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
((
int64_t
*
)
pCol
->
pData
)[
currentRow
]
=
pRes
->
v
;
((
int64_t
*
)
pCol
->
pData
)[
currentRow
]
=
pRes
->
v
;
// colDataAppendInt64(pCol, currentRow, &pRes->v);
// colDataAppendInt64(pCol, currentRow, &pRes->v);
break
;
break
;
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
...
@@ -920,9 +920,7 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos)
...
@@ -920,9 +920,7 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos)
}
}
}
}
void
replaceTupleData
(
STuplePos
*
pDestPos
,
STuplePos
*
pSourcePos
)
{
void
replaceTupleData
(
STuplePos
*
pDestPos
,
STuplePos
*
pSourcePos
)
{
*
pDestPos
=
*
pSourcePos
;
}
*
pDestPos
=
*
pSourcePos
;
}
int32_t
minMaxCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
,
int32_t
isMinFunc
)
{
int32_t
minMaxCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
,
int32_t
isMinFunc
)
{
SResultRowEntryInfo
*
pDResInfo
=
GET_RES_INFO
(
pDestCtx
);
SResultRowEntryInfo
*
pDResInfo
=
GET_RES_INFO
(
pDestCtx
);
...
@@ -1686,7 +1684,7 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -1686,7 +1684,7 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SPercentileInfo
*
ppInfo
=
(
SPercentileInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
SPercentileInfo
*
ppInfo
=
(
SPercentileInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
int32_t
code
=
0
;
int32_t
code
=
0
;
double
v
=
0
;
double
v
=
0
;
tMemBucket
*
pMemBucket
=
ppInfo
->
pMemBucket
;
tMemBucket
*
pMemBucket
=
ppInfo
->
pMemBucket
;
if
(
pMemBucket
!=
NULL
&&
pMemBucket
->
total
>
0
)
{
// check for null
if
(
pMemBucket
!=
NULL
&&
pMemBucket
->
total
>
0
)
{
// check for null
...
@@ -1714,7 +1712,7 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
...
@@ -1714,7 +1712,7 @@ int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
varDataSetLen
(
buf
,
len
);
varDataSetLen
(
buf
,
len
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
buf
,
false
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
buf
,
false
);
...
@@ -1739,7 +1737,6 @@ _fin_error:
...
@@ -1739,7 +1737,6 @@ _fin_error:
tMemBucketDestroy
(
pMemBucket
);
tMemBucketDestroy
(
pMemBucket
);
return
code
;
return
code
;
}
}
bool
getApercentileFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
bool
getApercentileFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
...
@@ -2100,7 +2097,7 @@ static void prepareBuf(SqlFunctionCtx* pCtx) {
...
@@ -2100,7 +2097,7 @@ static void prepareBuf(SqlFunctionCtx* pCtx) {
}
}
static
int32_t
firstlastSaveTupleData
(
const
SSDataBlock
*
pSrcBlock
,
int32_t
rowIndex
,
SqlFunctionCtx
*
pCtx
,
static
int32_t
firstlastSaveTupleData
(
const
SSDataBlock
*
pSrcBlock
,
int32_t
rowIndex
,
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInfo
)
{
SFirstLastRes
*
pInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
pCtx
->
subsidiaries
.
num
<=
0
)
{
if
(
pCtx
->
subsidiaries
.
num
<=
0
)
{
...
@@ -2153,7 +2150,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
...
@@ -2153,7 +2150,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
}
}
// All null data column, return directly.
// All null data column, return directly.
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
&&
pInputCol
->
hasNull
==
true
)
{
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
&&
pInputCol
->
hasNull
==
true
)
{
// save selectivity value for column consisted of all null values
// save selectivity value for column consisted of all null values
int32_t
code
=
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
int32_t
code
=
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -2269,7 +2267,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
...
@@ -2269,7 +2267,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
}
}
// All null data column, return directly.
// All null data column, return directly.
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
&&
pInputCol
->
hasNull
==
true
)
{
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
&&
pInputCol
->
hasNull
==
true
)
{
// save selectivity value for column consisted of all null values
// save selectivity value for column consisted of all null values
int32_t
code
=
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
int32_t
code
=
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -2363,7 +2362,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
...
@@ -2363,7 +2362,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
}
}
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
cts
)
{
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
cts
)
{
char
*
data
=
colDataGetData
(
pInputCol
,
chosen
);
char
*
data
=
colDataGetData
(
pInputCol
,
chosen
);
int32_t
code
=
doSaveCurrentVal
(
pCtx
,
i
,
cts
,
type
,
data
);
int32_t
code
=
doSaveCurrentVal
(
pCtx
,
i
,
cts
,
type
,
data
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -2374,7 +2373,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
...
@@ -2374,7 +2373,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
for
(
int32_t
i
=
pInput
->
startRowIndex
+
round
*
4
;
i
<
pInput
->
startRowIndex
+
pInput
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
+
round
*
4
;
i
<
pInput
->
startRowIndex
+
pInput
->
numOfRows
;
++
i
)
{
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
pts
[
i
])
{
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
pts
[
i
])
{
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
int32_t
code
=
doSaveCurrentVal
(
pCtx
,
i
,
pts
[
i
],
type
,
data
);
int32_t
code
=
doSaveCurrentVal
(
pCtx
,
i
,
pts
[
i
],
type
,
data
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -2391,7 +2390,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
...
@@ -2391,7 +2390,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
numOfElems
++
;
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
pts
[
i
])
{
if
(
pResInfo
->
numOfRes
==
0
||
pInfo
->
ts
<
pts
[
i
])
{
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
int32_t
code
=
doSaveCurrentVal
(
pCtx
,
i
,
pts
[
i
],
type
,
data
);
int32_t
code
=
doSaveCurrentVal
(
pCtx
,
i
,
pts
[
i
],
type
,
data
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -2438,7 +2437,7 @@ static int32_t firstLastTransferInfoImpl(SFirstLastRes* pInput, SFirstLastRes* p
...
@@ -2438,7 +2437,7 @@ static int32_t firstLastTransferInfoImpl(SFirstLastRes* pInput, SFirstLastRes* p
}
}
static
int32_t
firstLastTransferInfo
(
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
,
static
int32_t
firstLastTransferInfo
(
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
,
int32_t
rowIndex
)
{
int32_t
rowIndex
)
{
if
(
TSDB_CODE_SUCCESS
==
firstLastTransferInfoImpl
(
pInput
,
pOutput
,
isFirst
))
{
if
(
TSDB_CODE_SUCCESS
==
firstLastTransferInfoImpl
(
pInput
,
pOutput
,
isFirst
))
{
int32_t
code
=
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
rowIndex
,
pCtx
,
pOutput
);
int32_t
code
=
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
rowIndex
,
pCtx
,
pOutput
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -2465,7 +2464,7 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer
...
@@ -2465,7 +2464,7 @@ static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuer
for
(
int32_t
i
=
start
;
i
<
start
+
pInput
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
start
+
pInput
->
numOfRows
;
++
i
)
{
char
*
data
=
colDataGetData
(
pCol
,
i
);
char
*
data
=
colDataGetData
(
pCol
,
i
);
SFirstLastRes
*
pInputInfo
=
(
SFirstLastRes
*
)
varDataVal
(
data
);
SFirstLastRes
*
pInputInfo
=
(
SFirstLastRes
*
)
varDataVal
(
data
);
int32_t
code
=
firstLastTransferInfo
(
pCtx
,
pInputInfo
,
pInfo
,
isFirstQuery
,
i
);
int32_t
code
=
firstLastTransferInfo
(
pCtx
,
pInputInfo
,
pInfo
,
isFirstQuery
,
i
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -2697,7 +2696,7 @@ static int32_t doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv,
...
@@ -2697,7 +2696,7 @@ static int32_t doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv,
}
}
static
int32_t
doHandleDiff
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
SColumnInfoData
*
pOutput
,
int32_t
pos
,
static
int32_t
doHandleDiff
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
SColumnInfoData
*
pOutput
,
int32_t
pos
,
int32_t
order
,
int64_t
ts
)
{
int32_t
order
,
int64_t
ts
)
{
int32_t
factor
=
(
order
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
factor
=
(
order
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
pDiffInfo
->
prevTs
=
ts
;
pDiffInfo
->
prevTs
=
ts
;
switch
(
type
)
{
switch
(
type
)
{
...
@@ -2905,8 +2904,8 @@ static STopBotRes* getTopBotOutputInfo(SqlFunctionCtx* pCtx) {
...
@@ -2905,8 +2904,8 @@ static STopBotRes* getTopBotOutputInfo(SqlFunctionCtx* pCtx) {
return
pRes
;
return
pRes
;
}
}
static
int32_t
doAddIntoResult
(
SqlFunctionCtx
*
pCtx
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
uint16_t
type
,
static
int32_t
doAddIntoResult
(
SqlFunctionCtx
*
pCtx
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
uint64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
,
bool
isTopQuery
);
uint
16_t
type
,
uint
64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
,
bool
isTopQuery
);
static
void
addResult
(
SqlFunctionCtx
*
pCtx
,
STopBotResItem
*
pSourceItem
,
int16_t
type
,
bool
isTopQuery
);
static
void
addResult
(
SqlFunctionCtx
*
pCtx
,
STopBotResItem
*
pSourceItem
,
int16_t
type
,
bool
isTopQuery
);
...
@@ -2927,7 +2926,7 @@ int32_t topFunction(SqlFunctionCtx* pCtx) {
...
@@ -2927,7 +2926,7 @@ int32_t topFunction(SqlFunctionCtx* pCtx) {
}
}
numOfElems
++
;
numOfElems
++
;
char
*
data
=
colDataGetData
(
pCol
,
i
);
char
*
data
=
colDataGetData
(
pCol
,
i
);
int32_t
code
=
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
true
);
int32_t
code
=
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
true
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -2961,7 +2960,7 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) {
...
@@ -2961,7 +2960,7 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) {
}
}
numOfElems
++
;
numOfElems
++
;
char
*
data
=
colDataGetData
(
pCol
,
i
);
char
*
data
=
colDataGetData
(
pCol
,
i
);
int32_t
code
=
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
false
);
int32_t
code
=
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
false
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -3013,7 +3012,7 @@ static int32_t topBotResComparFn(const void* p1, const void* p2, const void* par
...
@@ -3013,7 +3012,7 @@ static int32_t topBotResComparFn(const void* p1, const void* p2, const void* par
}
}
int32_t
doAddIntoResult
(
SqlFunctionCtx
*
pCtx
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
uint16_t
type
,
int32_t
doAddIntoResult
(
SqlFunctionCtx
*
pCtx
,
void
*
pData
,
int32_t
rowIndex
,
SSDataBlock
*
pSrcBlock
,
uint16_t
type
,
uint64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
,
bool
isTopQuery
)
{
uint64_t
uid
,
SResultRowEntryInfo
*
pEntryInfo
,
bool
isTopQuery
)
{
STopBotRes
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
STopBotRes
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
SVariant
val
=
{
0
};
SVariant
val
=
{
0
};
...
@@ -3204,7 +3203,7 @@ static char* doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* pPo
...
@@ -3204,7 +3203,7 @@ static char* doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* pPo
if
(
pPage
==
NULL
)
{
if
(
pPage
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
char
*
p
=
pPage
->
data
+
pPos
->
offset
;
char
*
p
=
pPage
->
data
+
pPos
->
offset
;
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
return
p
;
return
p
;
}
else
{
}
else
{
...
@@ -4665,7 +4664,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
...
@@ -4665,7 +4664,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
continue
;
continue
;
}
}
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
int32_t
code
=
doReservoirSample
(
pCtx
,
pInfo
,
data
,
i
);
int32_t
code
=
doReservoirSample
(
pCtx
,
pInfo
,
data
,
i
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -4685,7 +4684,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
...
@@ -4685,7 +4684,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
}
}
int32_t
sampleFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
int32_t
sampleFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
SSampleInfo
*
pInfo
=
getSampleOutputInfo
(
pCtx
);
SSampleInfo
*
pInfo
=
getSampleOutputInfo
(
pCtx
);
...
@@ -5019,7 +5018,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
...
@@ -5019,7 +5018,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
}
}
numOfElems
++
;
numOfElems
++
;
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
char
*
data
=
colDataGetData
(
pInputCol
,
i
);
int32_t
code
=
doModeAdd
(
pInfo
,
i
,
pCtx
,
data
);
int32_t
code
=
doModeAdd
(
pInfo
,
i
,
pCtx
,
data
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -5425,7 +5424,6 @@ int32_t blockDistFunction(SqlFunctionCtx* pCtx) {
...
@@ -5425,7 +5424,6 @@ int32_t blockDistFunction(SqlFunctionCtx* pCtx) {
pDistInfo
->
numOfBlocks
+=
p1
.
numOfBlocks
;
pDistInfo
->
numOfBlocks
+=
p1
.
numOfBlocks
;
pDistInfo
->
numOfTables
+=
p1
.
numOfTables
;
pDistInfo
->
numOfTables
+=
p1
.
numOfTables
;
pDistInfo
->
numOfInmemRows
+=
p1
.
numOfInmemRows
;
pDistInfo
->
numOfInmemRows
+=
p1
.
numOfInmemRows
;
pDistInfo
->
numOfVgroups
+=
p1
.
numOfVgroups
;
pDistInfo
->
totalSize
+=
p1
.
totalSize
;
pDistInfo
->
totalSize
+=
p1
.
totalSize
;
pDistInfo
->
totalRows
+=
p1
.
totalRows
;
pDistInfo
->
totalRows
+=
p1
.
totalRows
;
pDistInfo
->
numOfFiles
+=
p1
.
numOfFiles
;
pDistInfo
->
numOfFiles
+=
p1
.
numOfFiles
;
...
@@ -5442,6 +5440,7 @@ int32_t blockDistFunction(SqlFunctionCtx* pCtx) {
...
@@ -5442,6 +5440,7 @@ int32_t blockDistFunction(SqlFunctionCtx* pCtx) {
pDistInfo
->
maxRows
=
p1
.
maxRows
;
pDistInfo
->
maxRows
=
p1
.
maxRows
;
}
}
pDistInfo
->
numOfVgroups
+=
(
p1
.
numOfTables
!=
0
?
1
:
0
);
for
(
int32_t
i
=
0
;
i
<
tListLen
(
pDistInfo
->
blockRowsHisto
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tListLen
(
pDistInfo
->
blockRowsHisto
);
++
i
)
{
pDistInfo
->
blockRowsHisto
[
i
]
+=
p1
.
blockRowsHisto
[
i
];
pDistInfo
->
blockRowsHisto
[
i
]
+=
p1
.
blockRowsHisto
[
i
];
}
}
...
@@ -5460,7 +5459,6 @@ int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDist
...
@@ -5460,7 +5459,6 @@ int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDist
if
(
tEncodeU16
(
&
encoder
,
pInfo
->
numOfFiles
)
<
0
)
return
-
1
;
if
(
tEncodeU16
(
&
encoder
,
pInfo
->
numOfFiles
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfBlocks
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfBlocks
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfTables
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfTables
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfVgroups
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pInfo
->
totalSize
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pInfo
->
totalSize
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pInfo
->
totalRows
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
&
encoder
,
pInfo
->
totalRows
)
<
0
)
return
-
1
;
...
@@ -5470,6 +5468,7 @@ int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDist
...
@@ -5470,6 +5468,7 @@ int32_t tSerializeBlockDistInfo(void* buf, int32_t bufLen, const STableBlockDist
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
defMinRows
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
defMinRows
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfInmemRows
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfInmemRows
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfSmallBlocks
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfSmallBlocks
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
&
encoder
,
pInfo
->
numOfVgroups
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
tListLen
(
pInfo
->
blockRowsHisto
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tListLen
(
pInfo
->
blockRowsHisto
);
++
i
)
{
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
blockRowsHisto
[
i
])
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
blockRowsHisto
[
i
])
<
0
)
return
-
1
;
...
@@ -5492,7 +5491,6 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo
...
@@ -5492,7 +5491,6 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo
if
(
tDecodeU16
(
&
decoder
,
&
pInfo
->
numOfFiles
)
<
0
)
return
-
1
;
if
(
tDecodeU16
(
&
decoder
,
&
pInfo
->
numOfFiles
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfBlocks
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfBlocks
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfTables
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfTables
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfVgroups
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pInfo
->
totalSize
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pInfo
->
totalSize
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pInfo
->
totalRows
)
<
0
)
return
-
1
;
if
(
tDecodeU64
(
&
decoder
,
&
pInfo
->
totalRows
)
<
0
)
return
-
1
;
...
@@ -5502,6 +5500,7 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo
...
@@ -5502,6 +5500,7 @@ int32_t tDeserializeBlockDistInfo(void* buf, int32_t bufLen, STableBlockDistInfo
if
(
tDecodeI32
(
&
decoder
,
&
pInfo
->
defMinRows
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pInfo
->
defMinRows
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfInmemRows
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfInmemRows
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfSmallBlocks
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfSmallBlocks
)
<
0
)
return
-
1
;
if
(
tDecodeU32
(
&
decoder
,
&
pInfo
->
numOfVgroups
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
tListLen
(
pInfo
->
blockRowsHisto
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
tListLen
(
pInfo
->
blockRowsHisto
);
++
i
)
{
if
(
tDecodeI32
(
&
decoder
,
&
pInfo
->
blockRowsHisto
[
i
])
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pInfo
->
blockRowsHisto
[
i
])
<
0
)
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录