Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8a773d6b
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
未验证
提交
8a773d6b
编写于
1月 04, 2023
作者:
D
dapan1121
提交者:
GitHub
1月 04, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19325 from taosdata/enh/TD-21206
fix: fix ASSERTs
上级
6f3cc64f
795fcab2
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
298 addition
and
282 deletion
+298
-282
include/common/ttypes.h
include/common/ttypes.h
+1
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+36
-41
source/common/src/tname.c
source/common/src/tname.c
+8
-22
source/common/src/trow.c
source/common/src/trow.c
+2
-23
source/common/src/ttime.c
source/common/src/ttime.c
+10
-7
source/common/src/ttszip.c
source/common/src/ttszip.c
+27
-21
source/common/src/ttypes.c
source/common/src/ttypes.c
+5
-4
source/common/src/tvariant.c
source/common/src/tvariant.c
+2
-2
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+5
-2
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+62
-46
source/libs/function/src/detail/tavgfunction.c
source/libs/function/src/detail/tavgfunction.c
+4
-3
source/libs/function/src/detail/tminmax.c
source/libs/function/src/detail/tminmax.c
+0
-2
source/libs/function/src/tfunctionInt.c
source/libs/function/src/tfunctionInt.c
+0
-3
source/libs/function/src/thistogram.c
source/libs/function/src/thistogram.c
+48
-16
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+13
-12
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+44
-38
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+4
-1
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+4
-9
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+23
-29
未找到文件。
include/common/ttypes.h
浏览文件 @
8a773d6b
...
...
@@ -342,8 +342,8 @@ typedef struct tDataTypeDescriptor {
extern
tDataTypeDescriptor
tDataTypes
[
TSDB_DATA_TYPE_MAX
];
bool
isValidDataType
(
int32_t
type
);
int32_t
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
);
void
assignVal
(
char
*
val
,
const
char
*
src
,
int32_t
len
,
int32_t
type
);
void
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
);
void
*
getDataMin
(
int32_t
type
,
void
*
value
);
void
*
getDataMax
(
int32_t
type
,
void
*
value
);
...
...
source/common/src/tdatablock.c
浏览文件 @
8a773d6b
...
...
@@ -22,7 +22,6 @@
#define MALLOC_ALIGN_BYTES 256
int32_t
colDataGetLength
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRows
)
{
ASSERT
(
pColumnInfoData
!=
NULL
);
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
return
pColumnInfoData
->
varmeta
.
length
;
}
else
{
...
...
@@ -65,8 +64,6 @@ int32_t getJsonValueLen(const char* data) {
}
int32_t
colDataAppend
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
bool
isNull
)
{
ASSERT
(
pColumnInfoData
!=
NULL
);
if
(
isNull
)
{
// There is a placehold for each NULL value of binary or nchar type.
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
...
...
@@ -177,8 +174,6 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren
int32_t
colDataAppendNItems
(
SColumnInfoData
*
pColumnInfoData
,
uint32_t
currentRow
,
const
char
*
pData
,
uint32_t
numOfRows
)
{
ASSERT
(
pData
!=
NULL
&&
pColumnInfoData
!=
NULL
);
int32_t
len
=
pColumnInfoData
->
info
.
bytes
;
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
len
=
varDataTLen
(
pData
);
...
...
@@ -236,7 +231,10 @@ static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, c
int32_t
colDataMergeCol
(
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRow1
,
int32_t
*
capacity
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRow2
)
{
ASSERT
(
pColumnInfoData
!=
NULL
&&
pSource
!=
NULL
&&
pColumnInfoData
->
info
.
type
==
pSource
->
info
.
type
);
if
(
pColumnInfoData
->
info
.
type
!=
pSource
->
info
.
type
)
{
return
TSDB_CODE_FAILED
;
}
if
(
numOfRow2
==
0
)
{
return
numOfRow1
;
}
...
...
@@ -316,13 +314,13 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
int32_t
colDataAssign
(
SColumnInfoData
*
pColumnInfoData
,
const
SColumnInfoData
*
pSource
,
int32_t
numOfRows
,
const
SDataBlockInfo
*
pBlockInfo
)
{
ASSERT
(
pColumnInfoData
!=
NULL
&&
pSource
!=
NULL
&&
pColumnInfoData
->
info
.
type
==
pSource
->
info
.
type
);
if
(
numOfRows
<=
0
)
{
return
numOfRows
;
if
(
pColumnInfoData
->
info
.
type
!=
pSource
->
info
.
type
||
(
pBlockInfo
!=
NULL
&&
pBlockInfo
->
capacity
<
numOfRows
)
)
{
return
TSDB_CODE_FAILED
;
}
if
(
pBlockInfo
!=
NULL
)
{
ASSERT
(
pBlockInfo
->
capacity
>=
numOfRows
)
;
if
(
numOfRows
<=
0
)
{
return
numOfRows
;
}
if
(
IS_VAR_DATA_TYPE
(
pColumnInfoData
->
info
.
type
))
{
...
...
@@ -388,7 +386,6 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex)
}
int32_t
blockDataMerge
(
SSDataBlock
*
pDest
,
const
SSDataBlock
*
pSrc
)
{
assert
(
pSrc
!=
NULL
&&
pDest
!=
NULL
);
int32_t
capacity
=
pDest
->
info
.
capacity
;
size_t
numOfCols
=
taosArrayGetSize
(
pDest
->
pDataBlock
);
...
...
@@ -406,8 +403,6 @@ int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc) {
}
size_t
blockDataGetSize
(
const
SSDataBlock
*
pBlock
)
{
assert
(
pBlock
!=
NULL
);
size_t
total
=
0
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
...
...
@@ -422,8 +417,6 @@ size_t blockDataGetSize(const SSDataBlock* pBlock) {
// Actual data rows pluses the corresponding meta data must fit in one memory buffer of the given page size.
int32_t
blockDataSplitRows
(
SSDataBlock
*
pBlock
,
bool
hasVarCol
,
int32_t
startIndex
,
int32_t
*
stopIndex
,
int32_t
pageSize
)
{
ASSERT
(
pBlock
!=
NULL
&&
stopIndex
!=
NULL
);
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
...
...
@@ -437,7 +430,9 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
if
(
!
hasVarCol
)
{
size_t
rowSize
=
blockDataGetRowSize
(
pBlock
);
int32_t
capacity
=
payloadSize
/
(
rowSize
+
numOfCols
*
bitmapChar
/
8
.
0
);
ASSERT
(
capacity
>
0
);
if
(
capacity
<=
0
)
{
return
TSDB_CODE_FAILED
;
}
*
stopIndex
=
startIndex
+
capacity
-
1
;
if
(
*
stopIndex
>=
numOfRows
)
{
...
...
@@ -469,7 +464,9 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
if
(
size
>
pageSize
)
{
// pageSize must be able to hold one row
*
stopIndex
=
j
-
1
;
ASSERT
(
*
stopIndex
>=
startIndex
);
if
(
*
stopIndex
<
startIndex
)
{
return
TSDB_CODE_FAILED
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -540,8 +537,6 @@ SSDataBlock* blockDataExtractBlock(SSDataBlock* pBlock, int32_t startIndex, int3
* @return
*/
int32_t
blockDataToBuf
(
char
*
buf
,
const
SSDataBlock
*
pBlock
)
{
ASSERT
(
pBlock
!=
NULL
);
// write the number of rows
*
(
uint32_t
*
)
buf
=
pBlock
->
info
.
rows
;
...
...
@@ -612,7 +607,9 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
}
pCol
->
varmeta
.
length
=
colLength
;
ASSERT
(
pCol
->
varmeta
.
length
<=
pCol
->
varmeta
.
allocLen
);
if
(
pCol
->
varmeta
.
length
>
pCol
->
varmeta
.
allocLen
)
{
return
TSDB_CODE_FAILED
;
}
}
memcpy
(
pCol
->
pData
,
pStart
,
colLength
);
...
...
@@ -659,7 +656,9 @@ int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity)
}
pCol
->
varmeta
.
length
=
colLength
;
ASSERT
(
pCol
->
varmeta
.
length
<=
pCol
->
varmeta
.
allocLen
);
if
(
pCol
->
varmeta
.
length
>
pCol
->
varmeta
.
allocLen
)
{
return
TSDB_CODE_FAILED
;
}
}
if
(
!
colDataIsNNull_s
(
pCol
,
0
,
pBlock
->
info
.
rows
))
{
...
...
@@ -673,7 +672,6 @@ int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity)
}
size_t
blockDataGetRowSize
(
SSDataBlock
*
pBlock
)
{
ASSERT
(
pBlock
!=
NULL
);
if
(
pBlock
->
info
.
rowSize
==
0
)
{
size_t
rowSize
=
0
;
...
...
@@ -702,7 +700,6 @@ size_t blockDataGetSerialMetaSize(uint32_t numOfCols) {
}
double
blockDataGetSerialRowSize
(
const
SSDataBlock
*
pBlock
)
{
ASSERT
(
pBlock
!=
NULL
);
double
rowSize
=
0
;
size_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
...
...
@@ -905,7 +902,6 @@ static int32_t* createTupleIndex(size_t rows) {
static
void
destroyTupleIndex
(
int32_t
*
index
)
{
taosMemoryFreeClear
(
index
);
}
int32_t
blockDataSort
(
SSDataBlock
*
pDataBlock
,
SArray
*
pOrderInfo
)
{
ASSERT
(
pDataBlock
!=
NULL
&&
pOrderInfo
!=
NULL
);
if
(
pDataBlock
->
info
.
rows
<=
1
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1149,8 +1145,7 @@ void blockDataCleanup(SSDataBlock* pDataBlock) {
void
blockDataEmpty
(
SSDataBlock
*
pDataBlock
)
{
SDataBlockInfo
*
pInfo
=
&
pDataBlock
->
info
;
ASSERT
(
pInfo
->
rows
<=
pDataBlock
->
info
.
capacity
);
if
(
pInfo
->
capacity
==
0
)
{
if
(
pInfo
->
capacity
==
0
||
pInfo
->
rows
>
pDataBlock
->
info
.
capacity
)
{
return
;
}
...
...
@@ -1168,8 +1163,7 @@ void blockDataEmpty(SSDataBlock* pDataBlock) {
// todo temporarily disable it
static
int32_t
doEnsureCapacity
(
SColumnInfoData
*
pColumn
,
const
SDataBlockInfo
*
pBlockInfo
,
uint32_t
numOfRows
,
bool
clearPayload
)
{
ASSERT
(
numOfRows
>
0
);
if
(
numOfRows
<=
pBlockInfo
->
capacity
)
{
if
(
numOfRows
<=
0
||
numOfRows
<=
pBlockInfo
->
capacity
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1196,7 +1190,9 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
int32_t
oldLen
=
BitmapLen
(
existedRows
);
pColumn
->
nullbitmap
=
tmp
;
memset
(
&
pColumn
->
nullbitmap
[
oldLen
],
0
,
BitmapLen
(
numOfRows
)
-
oldLen
);
ASSERT
(
pColumn
->
info
.
bytes
);
if
(
pColumn
->
info
.
bytes
==
0
)
{
return
TSDB_CODE_FAILED
;
}
// make sure the allocated memory is MALLOC_ALIGN_BYTES aligned
tmp
=
taosMemoryMallocAlign
(
MALLOC_ALIGN_BYTES
,
numOfRows
*
pColumn
->
info
.
bytes
);
...
...
@@ -1214,7 +1210,9 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo*
// todo remove it soon
#if defined LINUX
ASSERT
((((
uint64_t
)
pColumn
->
pData
)
&
(
MALLOC_ALIGN_BYTES
-
1
))
==
0x0
);
if
((((
uint64_t
)
pColumn
->
pData
)
&
(
MALLOC_ALIGN_BYTES
-
1
))
!=
0x0
)
{
return
TSDB_CODE_FAILED
;
}
#endif
if
(
clearPayload
)
{
...
...
@@ -1308,8 +1306,6 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
}
int32_t
assignOneDataBlock
(
SSDataBlock
*
dst
,
const
SSDataBlock
*
src
)
{
ASSERT
(
src
!=
NULL
);
dst
->
info
=
src
->
info
;
dst
->
info
.
rows
=
0
;
dst
->
info
.
capacity
=
0
;
...
...
@@ -1344,8 +1340,6 @@ int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
}
int32_t
copyDataBlock
(
SSDataBlock
*
dst
,
const
SSDataBlock
*
src
)
{
ASSERT
(
src
!=
NULL
&&
dst
!=
NULL
);
blockDataCleanup
(
dst
);
int32_t
code
=
blockDataEnsureCapacity
(
dst
,
src
->
info
.
rows
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1501,7 +1495,6 @@ SSDataBlock* createDataBlock() {
}
int32_t
blockDataAppendColInfo
(
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
)
{
ASSERT
(
pBlock
!=
NULL
&&
pColInfoData
!=
NULL
);
if
(
pBlock
->
pDataBlock
==
NULL
)
{
pBlock
->
pDataBlock
=
taosArrayInit
(
4
,
sizeof
(
SColumnInfoData
));
if
(
pBlock
->
pDataBlock
==
NULL
)
{
...
...
@@ -1536,7 +1529,6 @@ SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId)
}
SColumnInfoData
*
bdGetColumnInfoData
(
const
SSDataBlock
*
pBlock
,
int32_t
index
)
{
ASSERT
(
pBlock
!=
NULL
);
if
(
index
>=
taosArrayGetSize
(
pBlock
->
pDataBlock
))
{
return
NULL
;
}
...
...
@@ -2142,7 +2134,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_MEDIUMBLOB
:
uError
(
"the column type %"
PRIi16
" is defined but not implemented yet"
,
pColInfoData
->
info
.
type
);
ASSERT
(
0
);
break
;
default:
if
(
pColInfoData
->
info
.
type
<
TSDB_DATA_TYPE_MAX
&&
pColInfoData
->
info
.
type
>
TSDB_DATA_TYPE_NULL
)
{
...
...
@@ -2176,7 +2167,6 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
}
}
else
{
uError
(
"the column type %"
PRIi16
" is undefined
\n
"
,
pColInfoData
->
info
.
type
);
ASSERT
(
0
);
}
break
;
}
...
...
@@ -2222,7 +2212,10 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
}
char
*
buildCtbNameByGroupId
(
const
char
*
stbFullName
,
uint64_t
groupId
)
{
ASSERT
(
stbFullName
[
0
]
!=
0
);
if
(
stbFullName
[
0
]
==
0
)
{
return
NULL
;
}
SArray
*
tags
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
if
(
tags
==
NULL
)
{
return
NULL
;
...
...
@@ -2260,7 +2253,9 @@ char* buildCtbNameByGroupId(const char* stbFullName, uint64_t groupId) {
taosMemoryFree
(
pTag
);
taosArrayDestroy
(
tags
);
ASSERT
(
rname
.
ctbShortName
&&
rname
.
ctbShortName
[
0
]);
if
((
rname
.
ctbShortName
&&
rname
.
ctbShortName
[
0
])
==
0
)
{
return
NULL
;
}
return
rname
.
ctbShortName
;
}
...
...
source/common/src/tname.c
浏览文件 @
8a773d6b
...
...
@@ -98,8 +98,6 @@ SName* toName(int32_t acctId, const char* pDbName, const char* pTableName, SName
}
int32_t
tNameExtractFullName
(
const
SName
*
name
,
char
*
dst
)
{
assert
(
name
!=
NULL
&&
dst
!=
NULL
);
// invalid full name format, abort
if
(
!
tNameIsValid
(
name
))
{
return
-
1
;
...
...
@@ -109,7 +107,7 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
size_t
tnameLen
=
strlen
(
name
->
tname
);
if
(
tnameLen
>
0
)
{
/*
assert
(name->type == TSDB_TABLE_NAME_T);*/
/*
ASSERT
(name->type == TSDB_TABLE_NAME_T);*/
dst
[
len
]
=
TS_PATH_DELIMITER
[
0
];
memcpy
(
dst
+
len
+
1
,
name
->
tname
,
tnameLen
);
...
...
@@ -120,25 +118,21 @@ int32_t tNameExtractFullName(const SName* name, char* dst) {
}
int32_t
tNameLen
(
const
SName
*
name
)
{
assert
(
name
!=
NULL
);
char
tmp
[
12
]
=
{
0
};
int32_t
len
=
sprintf
(
tmp
,
"%d"
,
name
->
acctId
);
int32_t
len1
=
(
int32_t
)
strlen
(
name
->
dbname
);
int32_t
len2
=
(
int32_t
)
strlen
(
name
->
tname
);
if
(
name
->
type
==
TSDB_DB_NAME_T
)
{
assert
(
len2
==
0
);
ASSERT
(
len2
==
0
);
return
len
+
len1
+
TSDB_NAME_DELIMITER_LEN
;
}
else
{
assert
(
len2
>
0
);
ASSERT
(
len2
>
0
);
return
len
+
len1
+
len2
+
TSDB_NAME_DELIMITER_LEN
*
2
;
}
}
bool
tNameIsValid
(
const
SName
*
name
)
{
assert
(
name
!=
NULL
);
if
(
!
VALID_NAME_TYPE
(
name
->
type
))
{
return
false
;
}
...
...
@@ -151,15 +145,12 @@ bool tNameIsValid(const SName* name) {
}
SName
*
tNameDup
(
const
SName
*
name
)
{
assert
(
name
!=
NULL
);
SName
*
p
=
taosMemoryMalloc
(
sizeof
(
SName
));
memcpy
(
p
,
name
,
sizeof
(
SName
));
return
p
;
}
int32_t
tNameGetDbName
(
const
SName
*
name
,
char
*
dst
)
{
assert
(
name
!=
NULL
&&
dst
!=
NULL
);
strncpy
(
dst
,
name
->
dbname
,
tListLen
(
name
->
dbname
));
return
0
;
}
...
...
@@ -167,28 +158,24 @@ int32_t tNameGetDbName(const SName* name, char* dst) {
const
char
*
tNameGetDbNameP
(
const
SName
*
name
)
{
return
&
name
->
dbname
[
0
];
}
int32_t
tNameGetFullDbName
(
const
SName
*
name
,
char
*
dst
)
{
assert
(
name
!=
NULL
&&
dst
!=
NULL
);
snprintf
(
dst
,
TSDB_DB_FNAME_LEN
,
"%d.%s"
,
name
->
acctId
,
name
->
dbname
);
return
0
;
}
bool
tNameIsEmpty
(
const
SName
*
name
)
{
assert
(
name
!=
NULL
);
return
name
->
type
==
0
||
name
->
acctId
==
0
;
}
const
char
*
tNameGetTableName
(
const
SName
*
name
)
{
assert
(
name
!=
NULL
&&
name
->
type
==
TSDB_TABLE_NAME_T
);
ASSERT
(
name
!=
NULL
&&
name
->
type
==
TSDB_TABLE_NAME_T
);
return
&
name
->
tname
[
0
];
}
void
tNameAssign
(
SName
*
dst
,
const
SName
*
src
)
{
memcpy
(
dst
,
src
,
sizeof
(
SName
));
}
int32_t
tNameSetDbName
(
SName
*
dst
,
int32_t
acct
,
const
char
*
dbName
,
size_t
nameLen
)
{
assert
(
dst
!=
NULL
&&
dbName
!=
NULL
&&
nameLen
>
0
);
// too long account id or too long db name
if
(
nameLen
>=
tListLen
(
dst
->
dbname
))
{
if
(
nameLen
<=
0
||
nameLen
>=
tListLen
(
dst
->
dbname
))
{
return
-
1
;
}
...
...
@@ -199,8 +186,6 @@ int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t name
}
int32_t
tNameAddTbName
(
SName
*
dst
,
const
char
*
tbName
,
size_t
nameLen
)
{
assert
(
dst
!=
NULL
&&
tbName
!=
NULL
&&
nameLen
>
0
);
// too long account id or too long db name
if
(
nameLen
>=
tListLen
(
dst
->
tname
)
||
nameLen
<=
0
)
{
return
-
1
;
...
...
@@ -212,7 +197,6 @@ int32_t tNameAddTbName(SName* dst, const char* tbName, size_t nameLen) {
}
int32_t
tNameSetAcctId
(
SName
*
dst
,
int32_t
acctId
)
{
assert
(
dst
!=
NULL
);
dst
->
acctId
=
acctId
;
return
0
;
}
...
...
@@ -247,7 +231,9 @@ bool tNameTbNameEqual(SName* left, SName* right) {
}
int32_t
tNameFromString
(
SName
*
dst
,
const
char
*
str
,
uint32_t
type
)
{
assert
(
dst
!=
NULL
&&
str
!=
NULL
&&
strlen
(
str
)
>
0
);
if
(
strlen
(
str
)
==
0
)
{
return
-
1
;
}
char
*
p
=
NULL
;
if
((
type
&
T_NAME_ACCT
)
==
T_NAME_ACCT
)
{
...
...
source/common/src/trow.c
浏览文件 @
8a773d6b
...
...
@@ -76,7 +76,6 @@ void tdSCellValPrint(SCellVal *pVal, int8_t colType) {
return
;
}
if
(
!
pVal
->
val
)
{
ASSERT
(
0
);
printf
(
"BadVal "
);
return
;
}
...
...
@@ -490,7 +489,6 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
int32_t
tdGetBitmapValTypeII
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
)
{
if
(
!
pBitmap
||
colIdx
<
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -512,7 +510,6 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa
*
pValType
=
((
*
pDestByte
)
&
0x03
);
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -521,7 +518,6 @@ int32_t tdGetBitmapValTypeII(const void *pBitmap, int16_t colIdx, TDRowValT *pVa
int32_t
tdGetBitmapValTypeI
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
)
{
if
(
!
pBitmap
||
colIdx
<
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -555,7 +551,6 @@ int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pVal
*
pValType
=
((
*
pDestByte
)
&
0x01
);
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -564,7 +559,6 @@ int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pVal
int32_t
tdSetBitmapValTypeI
(
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
valType
)
{
if
(
!
pBitmap
||
colIdx
<
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -607,7 +601,6 @@ int32_t tdSetBitmapValTypeI(void *pBitmap, int16_t colIdx, TDRowValT valType) {
// *pDestByte |= (valType);
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -630,7 +623,6 @@ int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, void *pBitmap, int32_
output
->
val
=
POINTER_SHIFT
(
pRow
,
offset
);
}
#else
ASSERT
(
0
);
if
(
offset
<
0
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
output
->
valType
=
TD_VTYPE_NONE
;
...
...
@@ -680,7 +672,6 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
return
terrno
;
}
#else
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
#endif
...
...
@@ -707,8 +698,8 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
if
(
!
pBuilder
->
hasNone
)
pBuilder
->
hasNone
=
true
;
return
TSDB_CODE_SUCCESS
;
default:
ASSERT
(
0
)
;
break
;
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
if
(
TD_IS_TP_ROW
(
pRow
))
{
...
...
@@ -722,7 +713,6 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
int32_t
tdAppendColValToKvRow
(
SRowBuilder
*
pBuilder
,
TDRowValT
valType
,
const
void
*
val
,
bool
isCopyVarData
,
int8_t
colType
,
int16_t
colIdx
,
int32_t
offset
,
col_id_t
colId
)
{
if
((
offset
<
(
int32_t
)
sizeof
(
SKvRowIdx
))
||
(
colIdx
<
1
))
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -810,7 +800,6 @@ int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBou
pBuilder
->
nCols
=
nCols
;
pBuilder
->
nBoundCols
=
nBoundCols
;
if
(
pBuilder
->
flen
<=
0
||
pBuilder
->
nCols
<=
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -832,7 +821,6 @@ int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBou
int32_t
tdSRowResetBuf
(
SRowBuilder
*
pBuilder
,
void
*
pBuf
)
{
pBuilder
->
pBuf
=
(
STSRow
*
)
pBuf
;
if
(
!
pBuilder
->
pBuf
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -869,7 +857,6 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
TD_ROW_SET_NCOLS
(
pBuilder
->
pBuf
,
pBuilder
->
nBoundCols
);
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -880,7 +867,6 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
int32_t
tdSRowGetBuf
(
SRowBuilder
*
pBuilder
,
void
*
pBuf
)
{
pBuilder
->
pBuf
=
(
STSRow
*
)
pBuf
;
if
(
!
pBuilder
->
pBuf
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -900,7 +886,6 @@ int32_t tdSRowGetBuf(SRowBuilder *pBuilder, void *pBuf) {
#endif
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -920,7 +905,6 @@ int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen) {
pBuilder
->
flen
=
flen
;
pBuilder
->
nCols
=
nCols
;
if
(
pBuilder
->
flen
<=
0
||
pBuilder
->
nCols
<=
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -939,7 +923,6 @@ int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols,
pBuilder
->
nCols
=
nCols
;
pBuilder
->
nBoundCols
=
nBoundCols
;
if
(
pBuilder
->
flen
<=
0
||
pBuilder
->
nCols
<=
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -968,7 +951,6 @@ int32_t tdGetBitmapValType(const void *pBitmap, int16_t colIdx, TDRowValT *pValT
tdGetBitmapValTypeI
(
pBitmap
,
colIdx
,
pValType
);
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
TSDB_CODE_FAILED
;
}
...
...
@@ -987,7 +969,6 @@ bool tdIsBitmapValTypeNorm(const void *pBitmap, int16_t idx, int8_t bitmapMode)
int32_t
tdSetBitmapValTypeII
(
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
valType
)
{
if
(
!
pBitmap
||
colIdx
<
0
)
{
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -1014,7 +995,6 @@ int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx, TDRowValT valType) {
// *pDestByte |= (valType);
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
terrno
;
}
...
...
@@ -1031,7 +1011,6 @@ int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TDRowValT valType, int
tdSetBitmapValTypeI
(
pBitmap
,
colIdx
,
valType
);
break
;
default:
ASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
return
TSDB_CODE_FAILED
;
}
...
...
source/common/src/ttime.c
浏览文件 @
8a773d6b
...
...
@@ -168,12 +168,13 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) {
i
=
MICRO_SEC_FRACTION_LEN
;
}
times
=
MICRO_SEC_FRACTION_LEN
-
i
;
}
else
{
assert
(
timePrec
==
TSDB_TIME_PRECISION_NANO
);
}
else
if
(
timePrec
==
TSDB_TIME_PRECISION_NANO
)
{
if
(
i
>=
NANO_SEC_FRACTION_LEN
)
{
i
=
NANO_SEC_FRACTION_LEN
;
}
times
=
NANO_SEC_FRACTION_LEN
-
i
;
}
else
{
return
-
1
;
}
fraction
=
strnatoi
(
str
,
i
)
*
factor
[
times
];
...
...
@@ -510,8 +511,11 @@ int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPre
// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double =
// 1626006833631000064
int64_t
convertTimeFromPrecisionToUnit
(
int64_t
time
,
int32_t
fromPrecision
,
char
toUnit
)
{
assert
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
fromPrecision
==
TSDB_TIME_PRECISION_NANO
);
if
(
fromPrecision
!=
TSDB_TIME_PRECISION_MILLI
&&
fromPrecision
!=
TSDB_TIME_PRECISION_MICRO
&&
fromPrecision
!=
TSDB_TIME_PRECISION_NANO
)
{
return
-
1
;
}
int64_t
factors
[
3
]
=
{
NANOSECOND_PER_MSEC
,
NANOSECOND_PER_USEC
,
1
};
double
tmp
=
time
;
switch
(
toUnit
)
{
...
...
@@ -761,8 +765,7 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
}
int64_t
taosTimeTruncate
(
int64_t
t
,
const
SInterval
*
pInterval
,
int32_t
precision
)
{
if
(
pInterval
->
sliding
==
0
)
{
assert
(
pInterval
->
interval
==
0
);
if
(
pInterval
->
sliding
==
0
&&
pInterval
->
interval
==
0
)
{
return
t
;
}
...
...
@@ -931,7 +934,7 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision)
default:
fractionLen
=
0
;
assert
(
false
);
ASSERT
(
false
);
}
taosLocalTime
(
&
quot
,
&
ptm
);
...
...
source/common/src/ttszip.c
浏览文件 @
8a773d6b
...
...
@@ -17,6 +17,7 @@
#include "ttszip.h"
#include "taoserror.h"
#include "tcompression.h"
#include "tlog.h"
static
int32_t
getDataStartOffset
();
static
void
TSBufUpdateGroupInfo
(
STSBuf
*
pTSBuf
,
int32_t
index
,
STSGroupBlockInfo
*
pBlockInfo
);
...
...
@@ -202,14 +203,14 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
static
STSGroupBlockInfoEx
*
tsBufGetLastGroupInfo
(
STSBuf
*
pTSBuf
)
{
int32_t
last
=
pTSBuf
->
numOfGroups
-
1
;
assert
(
last
>=
0
);
ASSERT
(
last
>=
0
);
return
&
pTSBuf
->
pData
[
last
];
}
static
STSGroupBlockInfoEx
*
addOneGroupInfo
(
STSBuf
*
pTSBuf
,
int32_t
id
)
{
if
(
pTSBuf
->
numOfAlloc
<=
pTSBuf
->
numOfGroups
)
{
uint32_t
newSize
=
(
uint32_t
)(
pTSBuf
->
numOfAlloc
*
1
.
5
);
assert
((
int32_t
)
newSize
>
pTSBuf
->
numOfAlloc
);
ASSERT
((
int32_t
)
newSize
>
pTSBuf
->
numOfAlloc
);
STSGroupBlockInfoEx
*
tmp
=
(
STSGroupBlockInfoEx
*
)
taosMemoryRealloc
(
pTSBuf
->
pData
,
sizeof
(
STSGroupBlockInfoEx
)
*
newSize
);
...
...
@@ -233,7 +234,7 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) {
STSGroupBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
pTSBuf
->
numOfGroups
].
info
;
pBlockInfo
->
id
=
id
;
pBlockInfo
->
offset
=
pTSBuf
->
fileSize
;
assert
(
pBlockInfo
->
offset
>=
getDataStartOffset
());
ASSERT
(
pBlockInfo
->
offset
>=
getDataStartOffset
());
// update vnode info in file
TSBufUpdateGroupInfo
(
pTSBuf
,
pTSBuf
->
numOfGroups
,
pBlockInfo
);
...
...
@@ -282,7 +283,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
pTsData
->
allocSize
,
TWO_STAGE_COMP
,
pTSBuf
->
assistBuf
,
pTSBuf
->
bufSize
);
int64_t
r
=
taosLSeekFile
(
pTSBuf
->
pFile
,
pTSBuf
->
fileSize
,
SEEK_SET
);
assert
(
r
==
0
);
ASSERT
(
r
==
0
);
/*
* format for output data:
...
...
@@ -316,7 +317,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
taosWriteFile
(
pTSBuf
->
pFile
,
&
pBlock
->
compLen
,
sizeof
(
pBlock
->
compLen
));
metaLen
+=
(
int32_t
)
taosWriteFile
(
pTSBuf
->
pFile
,
&
trueLen
,
sizeof
(
pBlock
->
tag
.
nLen
));
assert
(
metaLen
==
getTagAreaLength
(
&
pBlock
->
tag
));
ASSERT
(
metaLen
==
getTagAreaLength
(
&
pBlock
->
tag
));
int32_t
blockSize
=
metaLen
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
compLen
)
*
2
+
pBlock
->
compLen
;
pTSBuf
->
fileSize
+=
blockSize
;
...
...
@@ -379,7 +380,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
size_t
sz
=
0
;
if
(
pBlock
->
tag
.
nType
==
TSDB_DATA_TYPE_BINARY
||
pBlock
->
tag
.
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
char
*
tp
=
taosMemoryRealloc
(
pBlock
->
tag
.
pz
,
pBlock
->
tag
.
nLen
+
1
);
assert
(
tp
!=
NULL
);
ASSERT
(
tp
!=
NULL
);
memset
(
tp
,
0
,
pBlock
->
tag
.
nLen
+
1
);
pBlock
->
tag
.
pz
=
tp
;
...
...
@@ -410,14 +411,14 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
// read the comp length at the length of comp block
sz
=
taosReadFile
(
pTSBuf
->
pFile
,
&
pBlock
->
padding
,
sizeof
(
pBlock
->
padding
));
assert
(
pBlock
->
padding
==
pBlock
->
compLen
);
ASSERT
(
pBlock
->
padding
==
pBlock
->
compLen
);
int32_t
n
=
0
;
sz
=
taosReadFile
(
pTSBuf
->
pFile
,
&
n
,
sizeof
(
pBlock
->
tag
.
nLen
));
if
(
pBlock
->
tag
.
nType
==
TSDB_DATA_TYPE_NULL
)
{
assert
(
n
==
0
);
ASSERT
(
n
==
0
);
}
else
{
assert
(
n
==
pBlock
->
tag
.
nLen
);
ASSERT
(
n
==
pBlock
->
tag
.
nLen
);
}
UNUSED
(
sz
);
...
...
@@ -477,7 +478,7 @@ void tsBufAppend(STSBuf* pTSBuf, int32_t id, SVariant* tag, const char* pData, i
pBlockInfo
=
tsBufGetLastGroupInfo
(
pTSBuf
);
}
assert
(
pBlockInfo
->
info
.
id
==
id
);
ASSERT
(
pBlockInfo
->
info
.
id
==
id
);
if
((
taosVariantCompare
(
&
pTSBuf
->
block
.
tag
,
tag
)
!=
0
)
&&
ptsData
->
len
>
0
)
{
// new arrived data with different tags value, save current value into disk first
...
...
@@ -596,7 +597,7 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSGroupBlockInfo* pBlockInfo
static
void
tsBufGetBlock
(
STSBuf
*
pTSBuf
,
int32_t
groupIndex
,
int32_t
blockIndex
)
{
STSGroupBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
groupIndex
].
info
;
if
(
pBlockInfo
->
numOfBlocks
<=
blockIndex
)
{
assert
(
false
);
ASSERT
(
false
);
}
STSCursor
*
pCur
=
&
pTSBuf
->
cur
;
...
...
@@ -613,7 +614,7 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t groupIndex, int32_t blockIndex
}
}
else
{
if
(
tsBufFindBlock
(
pTSBuf
,
pBlockInfo
,
blockIndex
)
==
-
1
)
{
assert
(
false
);
ASSERT
(
false
);
}
}
...
...
@@ -633,7 +634,7 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t groupIndex, int32_t blockIndex
tsDecompressTimestamp
(
pBlock
->
payload
,
pBlock
->
compLen
,
pBlock
->
numOfElem
,
pTSBuf
->
tsData
.
rawBuf
,
pTSBuf
->
tsData
.
allocSize
,
TWO_STAGE_COMP
,
pTSBuf
->
assistBuf
,
pTSBuf
->
bufSize
);
assert
((
pTSBuf
->
tsData
.
len
/
TSDB_KEYSIZE
==
pBlock
->
numOfElem
)
&&
(
pTSBuf
->
tsData
.
allocSize
>=
pTSBuf
->
tsData
.
len
));
ASSERT
((
pTSBuf
->
tsData
.
len
/
TSDB_KEYSIZE
==
pBlock
->
numOfElem
)
&&
(
pTSBuf
->
tsData
.
allocSize
>=
pTSBuf
->
tsData
.
len
));
pCur
->
vgroupIndex
=
groupIndex
;
pCur
->
blockIndex
=
blockIndex
;
...
...
@@ -668,7 +669,9 @@ int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) {
return
-
1
;
}
assert
(
pHeader
->
tsOrder
==
TSDB_ORDER_ASC
||
pHeader
->
tsOrder
==
TSDB_ORDER_DESC
);
if
(
pHeader
->
tsOrder
!=
TSDB_ORDER_ASC
&&
pHeader
->
tsOrder
!=
TSDB_ORDER_DESC
)
{
return
-
1
;
}
int32_t
r
=
taosLSeekFile
(
pTSBuf
->
pFile
,
0
,
SEEK_SET
);
if
(
r
!=
0
)
{
...
...
@@ -705,7 +708,7 @@ bool tsBufNextPos(STSBuf* pTSBuf) {
}
}
else
{
// get the last timestamp record in the last block of the last vnode
assert
(
pTSBuf
->
numOfGroups
>
0
);
ASSERT
(
pTSBuf
->
numOfGroups
>
0
);
int32_t
groupIndex
=
pTSBuf
->
numOfGroups
-
1
;
pCur
->
vgroupIndex
=
groupIndex
;
...
...
@@ -729,7 +732,7 @@ bool tsBufNextPos(STSBuf* pTSBuf) {
int32_t
step
=
pCur
->
order
==
TSDB_ORDER_ASC
?
1
:
-
1
;
while
(
1
)
{
assert
(
pTSBuf
->
tsData
.
len
==
pTSBuf
->
block
.
numOfElem
*
TSDB_KEYSIZE
);
ASSERT
(
pTSBuf
->
tsData
.
len
==
pTSBuf
->
block
.
numOfElem
*
TSDB_KEYSIZE
);
if
((
pCur
->
order
==
TSDB_ORDER_ASC
&&
pCur
->
tsIndex
>=
pTSBuf
->
block
.
numOfElem
-
1
)
||
(
pCur
->
order
==
TSDB_ORDER_DESC
&&
pCur
->
tsIndex
<=
0
))
{
...
...
@@ -810,7 +813,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
}
// src can only have one vnode index
assert
(
pSrcBuf
->
numOfGroups
==
1
);
ASSERT
(
pSrcBuf
->
numOfGroups
==
1
);
// there are data in buffer, flush to disk first
tsBufFlush
(
pDestBuf
);
...
...
@@ -853,7 +856,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
}
int32_t
r
=
taosLSeekFile
(
pDestBuf
->
pFile
,
0
,
SEEK_END
);
assert
(
r
==
0
);
ASSERT
(
r
==
0
);
int64_t
offset
=
getDataStartOffset
();
int32_t
size
=
(
int32_t
)
pSrcBuf
->
fileSize
-
(
int32_t
)
offset
;
...
...
@@ -881,7 +884,7 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
}
pDestBuf
->
fileSize
=
(
uint32_t
)
file_size
;
assert
(
pDestBuf
->
fileSize
==
oldSize
+
size
);
ASSERT
(
pDestBuf
->
fileSize
==
oldSize
+
size
);
return
0
;
}
...
...
@@ -913,7 +916,10 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
pTSBuf
->
fileSize
+=
len
;
pTSBuf
->
tsOrder
=
order
;
assert
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
);
if
(
order
!=
TSDB_ORDER_ASC
&&
order
!=
TSDB_ORDER_DESC
)
{
tsBufDestroy
(
pTSBuf
);
return
NULL
;
}
STSBufFileHeader
header
=
{
.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOfGroup
=
pTSBuf
->
numOfGroups
,
.
tsOrder
=
pTSBuf
->
tsOrder
};
...
...
@@ -1095,7 +1101,7 @@ void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id) {
}
int32_t
dumpFileBlockByGroupId
(
STSBuf
*
pTSBuf
,
int32_t
groupIndex
,
void
*
buf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
)
{
assert
(
groupIndex
>=
0
&&
groupIndex
<
pTSBuf
->
numOfGroups
);
ASSERT
(
groupIndex
>=
0
&&
groupIndex
<
pTSBuf
->
numOfGroups
);
STSGroupBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
groupIndex
].
info
;
*
len
=
0
;
...
...
source/common/src/ttypes.c
浏览文件 @
8a773d6b
...
...
@@ -140,7 +140,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
}
}
void
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
)
{
int32_t
operateVal
(
void
*
dst
,
void
*
s1
,
void
*
s2
,
int32_t
optr
,
int32_t
type
)
{
if
(
optr
==
OP_TYPE_ADD
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
...
...
@@ -177,11 +177,12 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type) {
SET_DOUBLE_VAL
(
dst
,
GET_DOUBLE_VAL
(
s1
)
+
GET_DOUBLE_VAL
(
s2
));
break
;
default:
{
assert
(
0
);
break
;
return
-
1
;
}
}
}
else
{
assert
(
0
)
;
return
-
1
;
}
return
0
;
}
source/common/src/tvariant.c
浏览文件 @
8a773d6b
...
...
@@ -168,7 +168,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
pSrc
->
nType
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
len
=
pSrc
->
nLen
+
TSDB_NCHAR_SIZE
;
char
*
p
=
taosMemoryRealloc
(
pDst
->
pz
,
len
);
assert
(
p
);
ASSERT
(
p
);
memset
(
p
,
0
,
len
);
pDst
->
pz
=
p
;
...
...
@@ -192,7 +192,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
size_t
num
=
taosArrayGetSize
(
pSrc
->
arr
);
pDst
->
arr
=
taosArrayInit
(
num
,
sizeof
(
int64_t
));
pDst
->
nLen
=
pSrc
->
nLen
;
assert
(
pSrc
->
nLen
==
num
);
ASSERT
(
pSrc
->
nLen
==
num
);
for
(
size_t
i
=
0
;
i
<
num
;
i
++
)
{
int64_t
*
p
=
taosArrayGet
(
pSrc
->
arr
,
i
);
taosArrayPush
(
pDst
->
arr
,
p
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
8a773d6b
...
...
@@ -1009,7 +1009,10 @@ static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* err
intervals
[
0
]
=
-
INFINITY
;
intervals
[
numOfBins
-
1
]
=
INFINITY
;
// in case of desc bin orders, -inf/inf should be swapped
ASSERT
(
numOfBins
>=
4
);
if
(
numOfBins
<
4
)
{
return
false
;
}
if
(
intervals
[
1
]
>
intervals
[
numOfBins
-
2
])
{
TSWAP
(
intervals
[
0
],
intervals
[
numOfBins
-
1
]);
}
...
...
@@ -1354,7 +1357,7 @@ static int32_t translateCsum(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
}
else
if
(
IS_FLOAT_TYPE
(
colType
))
{
resType
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
{
ASSERT
(
0
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
8a773d6b
...
...
@@ -506,7 +506,6 @@ static int32_t getNumOfElems(SqlFunctionCtx* pCtx) {
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
if
(
pInput
->
colDataSMAIsSet
&&
pInput
->
totalRows
==
pInput
->
numOfRows
&&
!
IS_VAR_DATA_TYPE
(
pInputCol
->
info
.
type
))
{
numOfElem
=
pInput
->
numOfRows
-
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
}
else
{
if
(
pInputCol
->
hasNull
)
{
for
(
int32_t
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
startRowIndex
+
pInput
->
numOfRows
;
++
i
)
{
...
...
@@ -596,7 +595,6 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) {
if
(
pInput
->
colDataSMAIsSet
)
{
numOfElem
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
pSumRes
->
isum
+=
pAgg
->
sum
;
...
...
@@ -661,7 +659,6 @@ int32_t sumInvertFunction(SqlFunctionCtx* pCtx) {
if
(
pInput
->
colDataSMAIsSet
)
{
numOfElem
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
pSumRes
->
isum
-=
pAgg
->
sum
;
...
...
@@ -832,7 +829,6 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
int32_t
dstSlotId
=
pc
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pDstCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
dstSlotId
);
ASSERT
(
pc
->
pExpr
->
base
.
resSchema
.
bytes
==
pDstCol
->
info
.
bytes
);
if
(
nullList
[
j
])
{
colDataAppendNULL
(
pDstCol
,
rowIndex
);
}
else
{
...
...
@@ -876,7 +872,6 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos)
int32_t
dstSlotId
=
pc
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pDstCol
=
taosArrayGet
(
pCtx
->
pDstBlock
->
pDataBlock
,
dstSlotId
);
ASSERT
(
pc
->
pExpr
->
base
.
resSchema
.
bytes
==
pDstCol
->
info
.
bytes
);
if
(
colDataIsNull_s
(
pSrcCol
,
rowIndex
)
==
true
)
{
colDataAppendNULL
(
pDstCol
,
pos
);
...
...
@@ -1145,7 +1140,9 @@ static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) {
int32_t
stddevFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SStddevRes
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -1771,7 +1768,10 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
type
,
data
);
tHistogramAdd
(
&
pInfo
->
pHisto
,
v
);
int32_t
code
=
tHistogramAdd
(
&
pInfo
->
pHisto
,
v
);
if
(
code
!=
0
)
{
return
TSDB_CODE_FAILED
;
}
}
qDebug
(
"%s after add %d elements into histogram, total:%"
PRId64
", numOfEntry:%d, pHisto:%p, elems: %p"
,
...
...
@@ -1841,7 +1841,9 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SAPercentileInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
...
...
@@ -2009,9 +2011,6 @@ static void prepareBuf(SqlFunctionCtx* pCtx) {
pCtx
->
subsidiaries
.
rowLen
=
rowLen
+
pCtx
->
subsidiaries
.
num
*
sizeof
(
bool
);
pCtx
->
subsidiaries
.
buf
=
taosMemoryMalloc
(
pCtx
->
subsidiaries
.
rowLen
);
}
ASSERT
(
pCtx
->
subsidiaries
.
buf
!=
NULL
);
ASSERT
(
pCtx
->
subsidiaries
.
rowLen
>
0
);
}
static
void
firstlastSaveTupleData
(
const
SSDataBlock
*
pSrcBlock
,
int32_t
rowIndex
,
SqlFunctionCtx
*
pCtx
,
...
...
@@ -2060,8 +2059,7 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
}
// All null data column, return directly.
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
))
{
ASSERT
(
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
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2168,8 +2166,7 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
}
// All null data column, return directly.
if
(
pInput
->
colDataSMAIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
))
{
ASSERT
(
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
firstlastSaveTupleData
(
pCtx
->
pSrcBlock
,
pInput
->
startRowIndex
,
pCtx
,
pInfo
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2333,7 +2330,9 @@ static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, S
static
int32_t
firstLastFunctionMergeImpl
(
SqlFunctionCtx
*
pCtx
,
bool
isFirstQuery
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SFirstLastRes
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -2528,7 +2527,7 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
return
true
;
}
static
void
doSetPrevVal
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
int64_t
ts
)
{
static
int32_t
doSetPrevVal
(
SDiffInfo
*
pDiffInfo
,
int32_t
type
,
const
char
*
pv
,
int64_t
ts
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
pDiffInfo
->
prev
.
i64
=
*
(
bool
*
)
pv
?
1
:
0
;
...
...
@@ -2553,12 +2552,14 @@ static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv, int
pDiffInfo
->
prev
.
d64
=
*
(
double
*
)
pv
;
break
;
default:
ASSERT
(
0
)
;
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
pDiffInfo
->
prevTs
=
ts
;
return
TSDB_CODE_SUCCESS
;
}
static
void
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
factor
=
(
order
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
pDiffInfo
->
prevTs
=
ts
;
...
...
@@ -2633,8 +2634,10 @@ static void doHandleDiff(SDiffInfo* pDiffInfo, int32_t type, const char* pv, SCo
break
;
}
default:
ASSERT
(
0
)
;
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
diffFunction
(
SqlFunctionCtx
*
pCtx
)
{
...
...
@@ -2671,7 +2674,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
if
(
tsList
[
i
]
==
pDiffInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
int32_t
code
=
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
appendSelectivityValue
(
pCtx
,
i
,
pos
);
...
...
@@ -2679,7 +2685,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
}
else
{
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
int32_t
code
=
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
pDiffInfo
->
hasPrev
=
true
;
...
...
@@ -2704,7 +2713,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
if
(
tsList
[
i
]
==
pDiffInfo
->
prevTs
)
{
return
TSDB_CODE_FUNC_DUP_TIMESTAMP
;
}
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
int32_t
code
=
doHandleDiff
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
pOutput
,
pos
,
pCtx
->
order
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
// handle selectivity
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
appendSelectivityValue
(
pCtx
,
i
,
pos
);
...
...
@@ -2712,7 +2724,10 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
numOfElems
++
;
}
else
{
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
int32_t
code
=
doSetPrevVal
(
pDiffInfo
,
pInputCol
->
info
.
type
,
pv
,
tsList
[
i
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
pDiffInfo
->
hasPrev
=
true
;
...
...
@@ -2857,7 +2872,6 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
taosVariantCreateFromBinary
(
&
val
,
pData
,
tDataTypes
[
type
].
bytes
,
type
);
STopBotResItem
*
pItems
=
pRes
->
pItems
;
assert
(
pItems
!=
NULL
);
// not full yet
if
(
pEntryInfo
->
numOfRes
<
pRes
->
maxSize
)
{
...
...
@@ -2967,10 +2981,9 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
}
else
{
// other tuple save policy
if
(
streamStateFuncPut
(
pHandle
->
pState
,
&
key
,
pBuf
,
length
)
<
0
)
{
ASSERT
(
0
)
;
if
(
streamStateFuncPut
(
pHandle
->
pState
,
&
key
,
pBuf
,
length
)
>=
0
)
{
p
.
streamTupleKey
=
key
;
}
p
.
streamTupleKey
=
key
;
}
return
p
;
...
...
@@ -2982,12 +2995,13 @@ STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBloc
STupleKey
key
;
if
(
pCtx
->
saveHandle
.
pBuf
==
NULL
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
0
);
ASSERT
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
int64_t
skey
=
*
(
int64_t
*
)
colDataGetData
(
pColInfo
,
rowIndex
);
if
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
int64_t
skey
=
*
(
int64_t
*
)
colDataGetData
(
pColInfo
,
rowIndex
);
key
.
groupId
=
pSrcBlock
->
info
.
id
.
groupId
;
key
.
ts
=
skey
;
key
.
exprIdx
=
pCtx
->
exprIdx
;
key
.
groupId
=
pSrcBlock
->
info
.
id
.
groupId
;
key
.
ts
=
skey
;
key
.
exprIdx
=
pCtx
->
exprIdx
;
}
}
char
*
buf
=
serializeTupleData
(
pSrcBlock
,
rowIndex
,
&
pCtx
->
subsidiaries
,
pCtx
->
subsidiaries
.
buf
);
...
...
@@ -3067,7 +3081,6 @@ void addResult(SqlFunctionCtx* pCtx, STopBotResItem* pSourceItem, int16_t type,
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
STopBotRes
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
STopBotResItem
*
pItems
=
pRes
->
pItems
;
assert
(
pItems
!=
NULL
);
// not full yet
if
(
pEntryInfo
->
numOfRes
<
pRes
->
maxSize
)
{
...
...
@@ -3225,7 +3238,9 @@ static void spreadTransferInfo(SSpreadInfo* pInput, SSpreadInfo* pOutput) {
int32_t
spreadFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SSpreadInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -3404,7 +3419,9 @@ static void elapsedTransferInfo(SElapsedInfo* pInput, SElapsedInfo* pOutput) {
int32_t
elapsedFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SElapsedInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -3574,7 +3591,9 @@ static bool getHistogramBinDesc(SHistoFuncInfo* pInfo, char* binDescStr, int8_t
intervals
[
0
]
=
-
INFINITY
;
intervals
[
numOfBins
-
1
]
=
INFINITY
;
// in case of desc bin orders, -inf/inf should be swapped
ASSERT
(
numOfBins
>=
4
);
if
(
numOfBins
<
4
)
{
return
false
;
}
if
(
intervals
[
1
]
>
intervals
[
numOfBins
-
2
])
{
TSWAP
(
intervals
[
0
],
intervals
[
numOfBins
-
1
]);
}
...
...
@@ -3717,7 +3736,9 @@ static void histogramTransferInfo(SHistoFuncInfo* pInput, SHistoFuncInfo* pOutpu
int32_t
histogramFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SHistoFuncInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
@@ -4099,7 +4120,7 @@ static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SVaria
break
;
}
default:
{
ASSERT
(
0
)
;
return
false
;
}
}
return
false
;
...
...
@@ -4900,11 +4921,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
int32_t
i
=
pInput
->
startRowIndex
;
if
(
pCtx
->
start
.
key
!=
INT64_MIN
)
{
// ASSERT((pCtx->start.key < tsList[i] && pCtx->order == TSDB_ORDER_ASC) ||
// (pCtx->start.key > tsList[i] && pCtx->order == TSDB_ORDER_DESC));
ASSERT
(
last
->
key
==
INT64_MIN
);
if
(
pCtx
->
start
.
key
!=
INT64_MIN
&&
last
->
key
==
INT64_MIN
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
++
i
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
...
...
@@ -5124,7 +5141,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
default:
ASSERT
(
0
)
;
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
// the last interpolated time window value
...
...
@@ -5151,7 +5168,6 @@ _twa_over:
* is required, we simply copy to the resut ot interResBuffer.
*/
// void twa_function_copy(SQLFunctionCtx *pCtx) {
// assert(pCtx->inputType == TSDB_DATA_TYPE_BINARY);
// SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
//
// memcpy(GET_ROWCELL_INTERBUF(pResInfo), pCtx->pInput, (size_t)pCtx->inputBytes);
...
...
source/libs/function/src/detail/tavgfunction.c
浏览文件 @
8a773d6b
...
...
@@ -366,7 +366,6 @@ bool avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) {
static
int32_t
calculateAvgBySMAInfo
(
SAvgRes
*
pRes
,
int32_t
numOfRows
,
int32_t
type
,
const
SColumnDataAgg
*
pAgg
)
{
int32_t
numOfElem
=
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
pRes
->
count
+=
numOfElem
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
...
...
@@ -672,7 +671,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
break
;
}
default:
ASSERT
(
0
)
;
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
}
else
{
numOfElem
=
doAddNumericVector
(
pCol
,
type
,
pInput
,
pAvgRes
);
...
...
@@ -706,7 +705,9 @@ static void avgTransferInfo(SAvgRes* pInput, SAvgRes* pOutput) {
int32_t
avgFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
if
(
pCol
->
info
.
type
!=
TSDB_DATA_TYPE_BINARY
)
{
return
TSDB_CODE_FUNC_FUNTION_PARA_TYPE
;
}
SAvgRes
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
...
...
source/libs/function/src/detail/tminmax.c
浏览文件 @
8a773d6b
...
...
@@ -721,7 +721,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
// data in current data block are qualified to the query
if
(
pInput
->
colDataSMAIsSet
)
{
numOfElems
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
pInput
->
numOfRows
==
pInput
->
totalRows
&&
numOfElems
>=
0
);
if
(
numOfElems
==
0
)
{
goto
_over
;
...
...
@@ -832,7 +831,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
}
if
(
i
>=
end
)
{
ASSERT
(
numOfElems
==
0
);
goto
_over
;
}
...
...
source/libs/function/src/tfunctionInt.c
浏览文件 @
8a773d6b
...
...
@@ -40,8 +40,6 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock
}
}
assert
(
maxRows
>=
0
);
blockDataEnsureCapacity
(
pResBlock
,
maxRows
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
...
...
@@ -63,7 +61,6 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock
}
bool
isRowEntryCompleted
(
struct
SResultRowEntryInfo
*
pEntry
)
{
assert
(
pEntry
!=
NULL
);
return
pEntry
->
complete
;
}
...
...
source/libs/function/src/thistogram.c
浏览文件 @
8a773d6b
...
...
@@ -73,7 +73,10 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
#if defined(USE_ARRAYLIST)
int32_t
idx
=
histoBinarySearch
((
*
pHisto
)
->
elems
,
(
*
pHisto
)
->
numOfEntries
,
val
);
assert
(
idx
>=
0
&&
idx
<=
(
*
pHisto
)
->
maxEntries
&&
(
*
pHisto
)
->
elems
!=
NULL
);
if
(
ASSERTS
(
idx
>=
0
&&
idx
<=
(
*
pHisto
)
->
maxEntries
&&
(
*
pHisto
)
->
elems
!=
NULL
,
"tHistogramAdd Error, idx:%d, maxEntries:%d, elems:%p"
,
idx
,
(
*
pHisto
)
->
maxEntries
,
(
*
pHisto
)
->
elems
))
{
return
-
1
;
}
if
((
*
pHisto
)
->
elems
[
idx
].
val
==
val
&&
idx
>=
0
)
{
(
*
pHisto
)
->
elems
[
idx
].
num
+=
1
;
...
...
@@ -84,15 +87,27 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
}
else
{
/* insert a new slot */
if
((
*
pHisto
)
->
numOfElems
>=
1
&&
idx
<
(
*
pHisto
)
->
numOfEntries
)
{
if
(
idx
>
0
)
{
assert
((
*
pHisto
)
->
elems
[
idx
-
1
].
val
<=
val
);
if
(
ASSERTS
((
*
pHisto
)
->
elems
[
idx
-
1
].
val
<=
val
,
"tHistogramAdd Error, elems[%d].val:%lf, val:%lf"
,
idx
-
1
,
(
*
pHisto
)
->
elems
[
idx
-
1
].
val
,
val
))
{
return
-
1
;
}
}
else
{
assert
((
*
pHisto
)
->
elems
[
idx
].
val
>
val
);
if
(
ASSERTS
((
*
pHisto
)
->
elems
[
idx
].
val
>
val
,
"tHistogramAdd Error, elems[%d].val:%lf, val:%lf"
,
idx
,
(
*
pHisto
)
->
elems
[
idx
].
val
,
val
))
{
return
-
1
;
}
}
}
else
if
((
*
pHisto
)
->
numOfElems
>
0
)
{
assert
((
*
pHisto
)
->
elems
[(
*
pHisto
)
->
numOfEntries
].
val
<=
val
);
if
(
ASSERTS
((
*
pHisto
)
->
elems
[(
*
pHisto
)
->
numOfEntries
].
val
<=
val
,
"tHistogramAdd Error, elems[%d].val:%lf, val:%lf"
,
(
*
pHisto
)
->
numOfEntries
,
(
*
pHisto
)
->
elems
[
idx
].
val
,
val
))
{
return
-
1
;
}
}
histogramCreateBin
(
*
pHisto
,
idx
,
val
);
int32_t
code
=
histogramCreateBin
(
*
pHisto
,
idx
,
val
);
if
(
code
!=
0
)
{
return
code
;
}
}
#else
tSkipListKey
key
=
tSkipListCreateKey
(
TSDB_DATA_TYPE_DOUBLE
,
&
val
,
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
nSize
);
...
...
@@ -151,7 +166,6 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
if
((
*
pHisto
)
->
numOfEntries
>=
(
*
pHisto
)
->
maxEntries
+
1
)
{
// set the right value for loser-tree
assert
((
*
pHisto
)
->
pLoserTree
!=
NULL
);
if
(
!
(
*
pHisto
)
->
ordered
)
{
SSkipListPrint
((
*
pHisto
)
->
pList
,
1
);
...
...
@@ -203,7 +217,10 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
tSkipListNode
*
pNext
=
pNode
->
pForward
[
0
];
SHistBin
*
pNextEntry
=
(
SHistBin
*
)
pNext
->
pData
;
assert
(
pNextEntry
->
val
-
pEntry
->
val
==
pEntry
->
delta
);
if
(
ASSERTS
(
pNextEntry
->
val
-
pEntry
->
val
==
pEntry
->
delta
,
"tHistogramAdd Error, pNextEntry->val:%lf, pEntry->val:%lf, pEntry->delta:%lf"
,
pNextEntry
->
val
,
pEntry
->
val
,
pEntry
->
delta
))
{
return
-
1
;
}
double
newVal
=
(
pEntry
->
val
*
pEntry
->
num
+
pNextEntry
->
val
*
pNextEntry
->
num
)
/
(
pEntry
->
num
+
pNextEntry
->
num
);
pEntry
->
val
=
newVal
;
...
...
@@ -253,7 +270,9 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
}
else
{
SHistBin
*
pEntry
=
(
SHistBin
*
)
pResNode
->
pData
;
assert
(
pEntry
->
val
==
val
);
if
(
ASSERTS
(
pEntry
->
val
==
val
,
"tHistogramAdd Error, pEntry->val:%lf, val:%lf"
))
{
return
-
1
;
}
pEntry
->
num
+=
1
;
}
...
...
@@ -329,7 +348,10 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) {
memmove
(
&
pHisto
->
elems
[
index
+
1
],
&
pHisto
->
elems
[
index
],
sizeof
(
SHistBin
)
*
remain
);
}
assert
(
index
>=
0
&&
index
<=
pHisto
->
maxEntries
);
if
(
ASSERTS
(
index
>=
0
&&
index
<=
pHisto
->
maxEntries
,
"histogramCreateBin Error, index:%d, maxEntries:%d"
,
index
,
pHisto
->
maxEntries
))
{
return
-
1
;
}
pHisto
->
elems
[
index
].
num
=
1
;
pHisto
->
elems
[
index
].
val
=
val
;
...
...
@@ -343,7 +365,11 @@ int32_t histogramCreateBin(SHistogramInfo* pHisto, int32_t index, double val) {
pHisto
->
elems
[
pHisto
->
maxEntries
].
num
=
0
;
}
#endif
assert
(
pHisto
->
numOfEntries
<=
pHisto
->
maxEntries
);
if
(
ASSERTS
(
pHisto
->
numOfEntries
<=
pHisto
->
maxEntries
,
"histogramCreateBin Error, numOfEntries:%d, maxEntries:%d"
,
pHisto
->
numOfEntries
,
pHisto
->
maxEntries
))
{
return
-
1
;
}
return
0
;
}
...
...
@@ -386,12 +412,14 @@ int64_t tHistogramSum(SHistogramInfo* pHisto, double v) {
if
(
slotIdx
<
0
)
{
slotIdx
=
0
;
assert
(
v
<=
pHisto
->
elems
[
slotIdx
].
val
);
ASSERTS
(
v
<=
pHisto
->
elems
[
slotIdx
].
val
,
"tHistogramSum Error, elems[%d].val:%lf, v:%lf"
,
slotIdx
,
pHisto
->
elems
[
slotIdx
].
val
,
v
);
}
else
{
assert
(
v
>=
pHisto
->
elems
[
slotIdx
].
val
);
ASSERTS
(
v
>=
pHisto
->
elems
[
slotIdx
].
val
,
"tHistogramSum Error, elems[%d].val:%lf, v:%lf"
,
slotIdx
,
pHisto
->
elems
[
slotIdx
].
val
,
v
);
if
(
slotIdx
+
1
<
pHisto
->
numOfEntries
)
{
assert
(
v
<
pHisto
->
elems
[
slotIdx
+
1
].
val
);
ASSERTS
(
v
<
pHisto
->
elems
[
slotIdx
+
1
].
val
,
"tHistogramSum Error, elems[%d].val:%lf, v:%lf"
,
slotIdx
+
1
,
pHisto
->
elems
[
slotIdx
+
1
].
val
,
v
);
}
}
}
...
...
@@ -445,7 +473,9 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) {
j
+=
1
;
}
assert
(
total
<=
numOfElem
&&
total
+
pHisto
->
elems
[
j
+
1
].
num
>
numOfElem
);
ASSERTS
(
total
<=
numOfElem
&&
total
+
pHisto
->
elems
[
j
+
1
].
num
>
numOfElem
,
"tHistogramUniform Error, total:%d, numOfElem:%d, elems[%d].num:%d"
,
total
,
numOfElem
,
j
+
1
,
pHisto
->
elems
[
j
+
1
].
num
);
double
delta
=
numOfElem
-
total
;
if
(
fabs
(
delta
)
<
FLT_EPSILON
)
{
...
...
@@ -502,7 +532,9 @@ double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num) {
j
+=
1
;
}
assert
(
total
<=
numOfElem
&&
total
+
pEntry
->
num
>
numOfElem
);
ASSERTS
(
total
<=
numOfElem
&&
total
+
pEntry
->
num
>
numOfElem
,
"tHistogramUniform Error, total:%d, numOfElem:%d, pEntry->num:%d"
,
total
,
numOfElem
,
pEntry
->
num
);
double
delta
=
numOfElem
-
total
;
if
(
fabs
(
delta
)
<
FLT_EPSILON
)
{
...
...
source/libs/function/src/tpercentile.c
浏览文件 @
8a773d6b
...
...
@@ -88,7 +88,7 @@ static void resetPosInfo(SSlotInfo *pInfo) {
}
double
findOnlyResult
(
tMemBucket
*
pMemBucket
)
{
assert
(
pMemBucket
->
total
==
1
);
ASSERT
(
pMemBucket
->
total
==
1
);
for
(
int32_t
i
=
0
;
i
<
pMemBucket
->
numOfSlots
;
++
i
)
{
tMemBucketSlot
*
pSlot
=
&
pMemBucket
->
pSlots
[
i
];
...
...
@@ -100,11 +100,11 @@ double findOnlyResult(tMemBucket *pMemBucket) {
SArray
**
pList
=
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
if
(
pList
!=
NULL
)
{
SArray
*
list
=
*
pList
;
assert
(
list
->
size
==
1
);
ASSERT
(
list
->
size
==
1
);
int32_t
*
pageId
=
taosArrayGet
(
list
,
0
);
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
assert
(
pPage
->
num
==
1
);
ASSERT
(
pPage
->
num
==
1
);
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pMemBucket
->
type
,
pPage
->
data
);
...
...
@@ -140,7 +140,8 @@ int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) {
}
}
assert
(
index
>=
0
&&
index
<
pBucket
->
numOfSlots
);
ASSERTS
(
index
>=
0
&&
index
<
pBucket
->
numOfSlots
,
"tBucketIntHash Error, index:%d, numOfSlots:%d"
,
index
,
pBucket
->
numOfSlots
);
return
index
;
}
...
...
@@ -167,7 +168,7 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) {
}
}
assert
(
index
>=
0
&&
index
<
pBucket
->
numOfSlots
);
ASSERT
(
index
>=
0
&&
index
<
pBucket
->
numOfSlots
);
return
index
;
}
...
...
@@ -198,7 +199,7 @@ int32_t tBucketDoubleHash(tMemBucket *pBucket, const void *value) {
}
}
assert
(
index
>=
0
&&
index
<
pBucket
->
numOfSlots
);
ASSERT
(
index
>=
0
&&
index
<
pBucket
->
numOfSlots
);
return
index
;
}
...
...
@@ -331,7 +332,7 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT
r
->
dMaxVal
=
v
;
}
}
else
{
assert
(
0
);
ASSERT
(
0
);
}
}
...
...
@@ -339,7 +340,7 @@ void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataT
* in memory bucket, we only accept data array list
*/
int32_t
tMemBucketPut
(
tMemBucket
*
pBucket
,
const
void
*
data
,
size_t
size
)
{
assert
(
pBucket
!=
NULL
&&
data
!=
NULL
&&
size
>
0
);
ASSERT
(
pBucket
!=
NULL
&&
data
!=
NULL
&&
size
>
0
);
int32_t
count
=
0
;
int32_t
bytes
=
pBucket
->
bytes
;
...
...
@@ -361,7 +362,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
if
(
pSlot
->
info
.
data
==
NULL
||
pSlot
->
info
.
data
->
num
>=
pBucket
->
elemPerPage
)
{
if
(
pSlot
->
info
.
data
!=
NULL
)
{
assert
(
pSlot
->
info
.
data
->
num
>=
pBucket
->
elemPerPage
&&
pSlot
->
info
.
size
>
0
);
ASSERT
(
pSlot
->
info
.
data
->
num
>=
pBucket
->
elemPerPage
&&
pSlot
->
info
.
size
>
0
);
// keep the pointer in memory
setBufPageDirty
(
pSlot
->
info
.
data
,
true
);
...
...
@@ -407,14 +408,14 @@ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int3
++
j
;
}
assert
(
j
<
pMemBucket
->
numOfSlots
);
ASSERT
(
j
<
pMemBucket
->
numOfSlots
);
return
pMemBucket
->
pSlots
[
j
].
range
;
}
static
bool
isIdenticalData
(
tMemBucket
*
pMemBucket
,
int32_t
index
);
static
double
getIdenticalDataVal
(
tMemBucket
*
pMemBucket
,
int32_t
slotIndex
)
{
assert
(
isIdenticalData
(
pMemBucket
,
slotIndex
));
ASSERT
(
isIdenticalData
(
pMemBucket
,
slotIndex
));
tMemBucketSlot
*
pSlot
=
&
pMemBucket
->
pSlots
[
slotIndex
];
...
...
@@ -461,7 +462,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
minOfNextSlot
=
(
double
)
next
.
dMinVal
;
}
assert
(
minOfNextSlot
>
maxOfThisSlot
);
ASSERT
(
minOfNextSlot
>
maxOfThisSlot
);
double
val
=
(
1
-
fraction
)
*
maxOfThisSlot
+
fraction
*
minOfNextSlot
;
return
val
;
...
...
source/libs/scalar/src/filter.c
浏览文件 @
8a773d6b
...
...
@@ -90,7 +90,7 @@ rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRan
int8_t
filterGetRangeCompFuncFromOptrs
(
uint8_t
optr
,
uint8_t
optr2
)
{
if
(
optr2
)
{
assert
(
optr2
==
OP_TYPE_LOWER_THAN
||
optr2
==
OP_TYPE_LOWER_EQUAL
);
ASSERT
(
optr2
==
OP_TYPE_LOWER_THAN
||
optr2
==
OP_TYPE_LOWER_EQUAL
);
if
(
optr
==
OP_TYPE_GREATER_THAN
)
{
if
(
optr2
==
OP_TYPE_LOWER_THAN
)
{
...
...
@@ -705,7 +705,7 @@ int32_t filterAddRangeImpl(void *h, SFilterRange *ra, int32_t optr) {
int32_t
filterAddRange
(
void
*
h
,
SFilterRange
*
ra
,
int32_t
optr
)
{
SFilterRangeCtx
*
ctx
=
(
SFilterRangeCtx
*
)
h
;
int64_t
tmp
=
0
;
if
(
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
{
SIMPLE_COPY_VALUES
(
&
ra
->
s
,
getDataMin
(
ctx
->
type
,
&
tmp
));
// FILTER_CLR_FLAG(ra->sflag, RA_NULL);
...
...
@@ -723,7 +723,7 @@ int32_t filterAddRangeCtx(void *dst, void *src, int32_t optr) {
SFilterRangeCtx
*
dctx
=
(
SFilterRangeCtx
*
)
dst
;
SFilterRangeCtx
*
sctx
=
(
SFilterRangeCtx
*
)
src
;
assert
(
optr
==
LOGIC_COND_TYPE_OR
);
ASSERT
(
optr
==
LOGIC_COND_TYPE_OR
);
if
(
sctx
->
rs
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -778,7 +778,10 @@ int32_t filterFinishRange(void *h) {
while
(
r
&&
r
->
next
)
{
int64_t
tmp
=
1
;
operateVal
(
&
tmp
,
&
r
->
ra
.
e
,
&
tmp
,
OP_TYPE_ADD
,
ctx
->
type
);
int32_t
code
=
operateVal
(
&
tmp
,
&
r
->
ra
.
e
,
&
tmp
,
OP_TYPE_ADD
,
ctx
->
type
);
if
(
code
!=
0
)
{
return
TSDB_CODE_APP_ERROR
;
}
if
(
ctx
->
pCompareFunc
(
&
tmp
,
&
r
->
next
->
ra
.
s
)
==
0
)
{
rn
=
r
->
next
;
SIMPLE_COPY_VALUES
((
char
*
)
&
r
->
next
->
ra
.
s
,
(
char
*
)
&
r
->
ra
.
s
);
...
...
@@ -1122,7 +1125,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
if
(
u
->
right
.
type
==
FLD_TYPE_VALUE
)
{
SFilterField
*
val
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
u
);
assert
(
FILTER_GET_FLAG
(
val
->
flag
,
FLD_TYPE_VALUE
));
ASSERT
(
FILTER_GET_FLAG
(
val
->
flag
,
FLD_TYPE_VALUE
));
}
else
{
int32_t
paramNum
=
scalarGetOperatorParamNum
(
optr
);
if
(
1
!=
paramNum
)
{
...
...
@@ -1132,7 +1135,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
}
SFilterField
*
col
=
FILTER_UNIT_LEFT_FIELD
(
info
,
u
);
assert
(
FILTER_GET_FLAG
(
col
->
flag
,
FLD_TYPE_COLUMN
));
ASSERT
(
FILTER_GET_FLAG
(
col
->
flag
,
FLD_TYPE_COLUMN
));
info
->
units
[
info
->
unitNum
].
compare
.
type
=
FILTER_GET_COL_FIELD_TYPE
(
col
);
info
->
units
[
info
->
unitNum
].
compare
.
precision
=
FILTER_GET_COL_FIELD_PRECISION
(
col
);
...
...
@@ -1292,29 +1295,29 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
if
(
optr
==
LOGIC_COND_TYPE_AND
)
{
if
(
ctx
->
isnull
)
{
assert
(
ctx
->
notnull
==
false
&&
ctx
->
isrange
==
false
);
ASSERT
(
ctx
->
notnull
==
false
&&
ctx
->
isrange
==
false
);
filterAddUnit
(
dst
,
OP_TYPE_IS_NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
}
if
(
ctx
->
notnull
)
{
assert
(
ctx
->
isnull
==
false
&&
ctx
->
isrange
==
false
);
ASSERT
(
ctx
->
isnull
==
false
&&
ctx
->
isrange
==
false
);
filterAddUnit
(
dst
,
OP_TYPE_IS_NOT_NULL
,
&
left
,
NULL
,
&
uidx
);
filterAddUnitToGroup
(
g
,
uidx
);
return
TSDB_CODE_SUCCESS
;
}
if
(
!
ctx
->
isrange
)
{
assert
(
ctx
->
isnull
||
ctx
->
notnull
);
ASSERT
(
ctx
->
isnull
||
ctx
->
notnull
);
return
TSDB_CODE_SUCCESS
;
}
assert
(
ctx
->
rs
&&
ctx
->
rs
->
next
==
NULL
);
ASSERT
(
ctx
->
rs
&&
ctx
->
rs
->
next
==
NULL
);
SFilterRange
*
ra
=
&
ctx
->
rs
->
ra
;
assert
(
!
((
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
&&
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_NULL
))));
ASSERT
(
!
((
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
&&
(
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_NULL
))));
if
((
!
FILTER_GET_FLAG
(
ra
->
sflag
,
RANGE_FLG_NULL
))
&&
(
!
FILTER_GET_FLAG
(
ra
->
eflag
,
RANGE_FLG_NULL
)))
{
__compar_fn_t
func
=
getComparFunc
(
type
,
0
);
...
...
@@ -1368,7 +1371,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
SFilterGroup
ng
=
{
0
};
g
=
&
ng
;
assert
(
ctx
->
isnull
||
ctx
->
notnull
||
ctx
->
isrange
);
ASSERT
(
ctx
->
isnull
||
ctx
->
notnull
||
ctx
->
isrange
);
if
(
ctx
->
isnull
)
{
filterAddUnit
(
dst
,
OP_TYPE_IS_NULL
,
&
left
,
NULL
,
&
uidx
);
...
...
@@ -1377,7 +1380,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
}
if
(
ctx
->
notnull
)
{
assert
(
!
ctx
->
isrange
);
ASSERT
(
!
ctx
->
isrange
);
memset
(
g
,
0
,
sizeof
(
*
g
));
filterAddUnit
(
dst
,
OP_TYPE_IS_NOT_NULL
,
&
left
,
NULL
,
&
uidx
);
...
...
@@ -1386,7 +1389,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
}
if
(
!
ctx
->
isrange
)
{
assert
(
ctx
->
isnull
||
ctx
->
notnull
);
ASSERT
(
ctx
->
isnull
||
ctx
->
notnull
);
g
->
unitNum
=
0
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1444,7 +1447,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan
filterAddUnitToGroup
(
g
,
uidx
);
}
assert
(
g
->
unitNum
>
0
);
ASSERT
(
g
->
unitNum
>
0
);
taosArrayPush
(
res
,
g
);
...
...
@@ -1900,7 +1903,7 @@ void filterFreeInfo(SFilterInfo *info) {
}
int32_t
filterHandleValueExtInfo
(
SFilterUnit
*
unit
,
char
extInfo
)
{
assert
(
extInfo
>
0
||
extInfo
<
0
);
ASSERT
(
extInfo
>
0
||
extInfo
<
0
);
uint8_t
optr
=
FILTER_UNIT_OPTR
(
unit
);
switch
(
optr
)
{
...
...
@@ -1916,7 +1919,8 @@ int32_t filterHandleValueExtInfo(SFilterUnit *unit, char extInfo) {
unit
->
compare
.
optr
=
FILTER_DUMMY_EMPTY_OPTR
;
break
;
default:
assert
(
0
);
fltError
(
"unsupported operator type"
);
return
TSDB_CODE_APP_ERROR
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1926,13 +1930,13 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
for
(
uint32_t
i
=
0
;
i
<
info
->
unitNum
;
++
i
)
{
SFilterUnit
*
unit
=
&
info
->
units
[
i
];
if
(
unit
->
right
.
type
!=
FLD_TYPE_VALUE
)
{
assert
(
unit
->
compare
.
optr
==
FILTER_DUMMY_EMPTY_OPTR
||
scalarGetOperatorParamNum
(
unit
->
compare
.
optr
)
==
1
);
ASSERT
(
unit
->
compare
.
optr
==
FILTER_DUMMY_EMPTY_OPTR
||
scalarGetOperatorParamNum
(
unit
->
compare
.
optr
)
==
1
);
continue
;
}
SFilterField
*
right
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
unit
);
assert
(
FILTER_GET_FLAG
(
right
->
flag
,
FLD_TYPE_VALUE
));
ASSERT
(
FILTER_GET_FLAG
(
right
->
flag
,
FLD_TYPE_VALUE
));
uint32_t
type
=
FILTER_UNIT_DATA_TYPE
(
unit
);
int8_t
precision
=
FILTER_UNIT_DATA_PRECISION
(
unit
);
...
...
@@ -1940,7 +1944,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
SValueNode
*
var
=
(
SValueNode
*
)
fi
->
desc
;
if
(
var
==
NULL
)
{
assert
(
fi
->
data
!=
NULL
);
ASSERT
(
fi
->
data
!=
NULL
);
continue
;
}
...
...
@@ -2068,7 +2072,8 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
}
default:
assert
(
false
);
fltError
(
"unsupported operator type"
);
return
false
;
}
return
true
;
...
...
@@ -2101,7 +2106,7 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit *u, SFilterRangeCtx *c
FILTER_SET_FLAG
(
ra
.
sflag
,
RANGE_FLG_NULL
);
break
;
case
OP_TYPE_NOT_EQUAL
:
assert
(
type
==
TSDB_DATA_TYPE_BOOL
);
ASSERT
(
type
==
TSDB_DATA_TYPE_BOOL
);
if
(
GET_INT8_VAL
(
val
))
{
SIMPLE_COPY_VALUES
(
&
ra
.
s
,
&
tmp
);
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
&
tmp
);
...
...
@@ -2116,7 +2121,8 @@ int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit *u, SFilterRangeCtx *c
SIMPLE_COPY_VALUES
(
&
ra
.
e
,
val
);
break
;
default:
assert
(
0
);
fltError
(
"unsupported operator type"
);
return
TSDB_CODE_APP_ERROR
;
}
filterAddRange
(
ctx
,
&
ra
,
optr
);
...
...
@@ -2368,8 +2374,8 @@ int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32
filterReuseRangeCtx
(
*
ctx
,
type
,
0
);
}
assert
(
gRes2
->
colInfo
[
cidx
].
type
==
RANGE_TYPE_MR_CTX
);
assert
(
gRes1
->
colInfo
[
cidx
].
type
==
RANGE_TYPE_MR_CTX
);
ASSERT
(
gRes2
->
colInfo
[
cidx
].
type
==
RANGE_TYPE_MR_CTX
);
ASSERT
(
gRes1
->
colInfo
[
cidx
].
type
==
RANGE_TYPE_MR_CTX
);
filterCopyRangeCtx
(
*
ctx
,
gRes2
->
colInfo
[
cidx
].
info
);
filterSourceRangeFromCtx
(
*
ctx
,
gRes1
->
colInfo
[
cidx
].
info
,
optr
,
empty
,
all
);
...
...
@@ -2405,7 +2411,7 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilter
continue
;
}
assert
(
idx1
==
idx2
);
ASSERT
(
idx1
==
idx2
);
++
merNum
;
...
...
@@ -2455,15 +2461,15 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilter
}
}
assert
(
merNum
>
0
);
ASSERT
(
merNum
>
0
);
SFilterColInfo
*
colInfo
=
NULL
;
assert
(
merNum
==
equal1
||
merNum
==
equal2
);
ASSERT
(
merNum
==
equal1
||
merNum
==
equal2
);
filterFreeGroupCtx
(
*
gRes2
);
*
gRes2
=
NULL
;
assert
(
colCtxs
&&
taosArrayGetSize
(
colCtxs
)
>
0
);
ASSERT
(
colCtxs
&&
taosArrayGetSize
(
colCtxs
)
>
0
);
int32_t
ctxSize
=
(
int32_t
)
taosArrayGetSize
(
colCtxs
);
SFilterColCtx
*
pctx
=
NULL
;
...
...
@@ -2520,7 +2526,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gR
if
(
pColNum
>
0
)
{
for
(
int32_t
m
=
0
;
m
<=
pEnd
;
++
m
)
{
for
(
int32_t
n
=
cStart
;
n
<=
cEnd
;
++
n
)
{
assert
(
m
<
n
);
ASSERT
(
m
<
n
);
filterMergeTwoGroups
(
info
,
&
gRes
[
m
],
&
gRes
[
n
],
&
all
);
FLT_CHK_JMP
(
all
);
...
...
@@ -2541,7 +2547,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gR
for
(
int32_t
m
=
cStart
;
m
<
cEnd
;
++
m
)
{
for
(
int32_t
n
=
m
+
1
;
n
<=
cEnd
;
++
n
)
{
assert
(
m
<
n
);
ASSERT
(
m
<
n
);
filterMergeTwoGroups
(
info
,
&
gRes
[
m
],
&
gRes
[
n
],
&
all
);
FLT_CHK_JMP
(
all
);
...
...
@@ -2636,7 +2642,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum
for
(
uint32_t
m
=
0
;
m
<
res
->
colNum
;
++
m
)
{
colInfo
=
&
res
->
colInfo
[
res
->
colIdx
[
m
]];
if
(
FILTER_NO_MERGE_DATA_TYPE
(
colInfo
->
dataType
))
{
assert
(
colInfo
->
type
==
RANGE_TYPE_UNIT
);
ASSERT
(
colInfo
->
type
==
RANGE_TYPE_UNIT
);
int32_t
usize
=
(
int32_t
)
taosArrayGetSize
((
SArray
*
)
colInfo
->
info
);
for
(
int32_t
n
=
0
;
n
<
usize
;
++
n
)
{
...
...
@@ -2649,7 +2655,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum
continue
;
}
assert
(
colInfo
->
type
==
RANGE_TYPE_MR_CTX
);
ASSERT
(
colInfo
->
type
==
RANGE_TYPE_MR_CTX
);
filterAddGroupUnitFromCtx
(
info
,
&
oinfo
,
colInfo
->
info
,
res
->
colIdx
[
m
],
&
ng
,
optr
,
group
);
}
...
...
@@ -2690,7 +2696,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
continue
;
}
assert
(
idxNum
[
i
]
==
gResNum
);
ASSERT
(
idxNum
[
i
]
==
gResNum
);
if
(
idxs
==
NULL
)
{
idxs
=
taosMemoryCalloc
(
info
->
fields
[
FLD_TYPE_COLUMN
].
num
,
sizeof
(
*
idxs
));
...
...
@@ -2714,7 +2720,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
continue
;
}
assert
(
res
->
colIdx
[
n
]
==
idxs
[
m
]);
ASSERT
(
res
->
colIdx
[
n
]
==
idxs
[
m
]);
SFilterColInfo
*
colInfo
=
&
res
->
colInfo
[
res
->
colIdx
[
n
]];
if
(
info
->
colRange
[
m
]
==
NULL
)
{
...
...
@@ -2723,7 +2729,7 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_
info
->
colRange
[
m
]
->
colId
=
FILTER_GET_COL_FIELD_ID
(
fi
);
}
assert
(
colInfo
->
type
==
RANGE_TYPE_MR_CTX
);
ASSERT
(
colInfo
->
type
==
RANGE_TYPE_MR_CTX
);
bool
all
=
false
;
filterSourceRangeFromCtx
(
info
->
colRange
[
m
],
colInfo
->
info
,
LOGIC_COND_TYPE_OR
,
NULL
,
&
all
);
...
...
@@ -2971,7 +2977,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3
unitIdx
=
pGroupIdx
;
--
info
->
blkGroupNum
;
assert
(
empty
||
all
);
ASSERT
(
empty
||
all
);
if
(
empty
)
{
FILTER_SET_FLAG
(
info
->
blkFlag
,
FI_STATUS_BLK_EMPTY
);
...
...
@@ -3077,7 +3083,7 @@ int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, SColumn
goto
_return
;
}
assert
(
info
->
unitNum
>
1
);
ASSERT
(
info
->
unitNum
>
1
);
*
all
=
filterExecuteBasedOnStatisImpl
(
info
,
numOfRows
,
p
,
statis
,
numOfCols
);
goto
_return
;
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
8a773d6b
...
...
@@ -327,7 +327,10 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t
case
QUERY_NODE_VALUE
:
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
;
ASSERT
(
param
->
columnData
==
NULL
);
if
(
param
->
columnData
!=
NULL
)
{
sclError
(
"columnData should be NULL"
);
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
param
->
numOfRows
=
1
;
int32_t
code
=
sclCreateColumnInfoData
(
&
valueNode
->
node
.
resType
,
1
,
param
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
8a773d6b
...
...
@@ -361,7 +361,6 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
SColumnInfoData
*
pInputData
=
pInput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
ASSERT
(
pOutputData
->
info
.
type
==
TSDB_DATA_TYPE_BIGINT
);
int64_t
*
out
=
(
int64_t
*
)
pOutputData
->
pData
;
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfRows
;
++
i
)
{
...
...
@@ -1729,37 +1728,31 @@ bool getTimePseudoFuncEnv(SFunctionNode *UNUSED_PARAM(pFunc), SFuncExecEnv *pEnv
}
int32_t
qStartTsFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
ASSERT
(
inputNum
==
1
);
colDataAppendInt64
(
pOutput
->
columnData
,
pOutput
->
numOfRows
,
(
int64_t
*
)
colDataGetData
(
pInput
->
columnData
,
0
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
qEndTsFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
ASSERT
(
inputNum
==
1
);
colDataAppendInt64
(
pOutput
->
columnData
,
pOutput
->
numOfRows
,
(
int64_t
*
)
colDataGetData
(
pInput
->
columnData
,
1
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
winDurFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
ASSERT
(
inputNum
==
1
);
colDataAppendInt64
(
pOutput
->
columnData
,
pOutput
->
numOfRows
,
(
int64_t
*
)
colDataGetData
(
pInput
->
columnData
,
2
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
winStartTsFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
ASSERT
(
inputNum
==
1
);
colDataAppendInt64
(
pOutput
->
columnData
,
pOutput
->
numOfRows
,
(
int64_t
*
)
colDataGetData
(
pInput
->
columnData
,
3
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
winEndTsFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
ASSERT
(
inputNum
==
1
);
colDataAppendInt64
(
pOutput
->
columnData
,
pOutput
->
numOfRows
,
(
int64_t
*
)
colDataGetData
(
pInput
->
columnData
,
4
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
qTbnameFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
ASSERT
(
inputNum
==
1
);
char
*
p
=
colDataGetVarData
(
pInput
->
columnData
,
0
);
colDataAppendNItems
(
pOutput
->
columnData
,
pOutput
->
numOfRows
,
p
,
pInput
->
numOfRows
);
...
...
@@ -2598,7 +2591,7 @@ static bool checkStateOp(int8_t op, SColumnInfoData *pCol, int32_t index, SScala
break
;
}
default:
{
ASSERT
(
0
)
;
return
false
;
}
}
return
false
;
...
...
@@ -2771,7 +2764,9 @@ static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *bin
intervals
[
0
]
=
-
INFINITY
;
intervals
[
numOfBins
-
1
]
=
INFINITY
;
// in case of desc bin orders, -inf/inf should be swapped
ASSERT
(
numOfBins
>=
4
);
if
(
numOfBins
<
4
)
{
return
false
;
}
if
(
intervals
[
1
]
>
intervals
[
numOfBins
-
2
])
{
TSWAP
(
intervals
[
0
],
intervals
[
numOfBins
-
1
]);
}
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
8a773d6b
...
...
@@ -389,18 +389,18 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
func
=
varToUnsigned
;
}
else
if
(
IS_FLOAT_TYPE
(
pCtx
->
outType
))
{
func
=
varToFloat
;
}
else
if
(
pCtx
->
outType
==
TSDB_DATA_TYPE_
BINARY
)
{
// nchar -> binary
ASSERT
(
pCtx
->
inType
==
TSDB_DATA_TYPE_NCHAR
);
}
else
if
(
pCtx
->
outType
==
TSDB_DATA_TYPE_
VARCHAR
&&
pCtx
->
inType
==
TSDB_DATA_TYPE_NCHAR
)
{
// nchar -> binary
func
=
ncharToVar
;
vton
=
true
;
}
else
if
(
pCtx
->
outType
==
TSDB_DATA_TYPE_NCHAR
)
{
// binary -> nchar
ASSERT
(
pCtx
->
inType
==
TSDB_DATA_TYPE_VARCHAR
);
}
else
if
(
pCtx
->
outType
==
TSDB_DATA_TYPE_NCHAR
&&
pCtx
->
inType
==
TSDB_DATA_TYPE_VARCHAR
)
{
// binary -> nchar
func
=
varToNchar
;
vton
=
true
;
}
else
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
pCtx
->
outType
)
{
func
=
varToTimestamp
;
}
else
{
sclError
(
"invalid convert outType:%d
"
,
pCtx
->
out
Type
);
sclError
(
"invalid convert outType:%d
, inType:%d"
,
pCtx
->
outType
,
pCtx
->
in
Type
);
return
TSDB_CODE_APP_ERROR
;
}
...
...
@@ -416,12 +416,10 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
char
*
data
=
colDataGetVarData
(
pCtx
->
pIn
->
columnData
,
i
);
int32_t
convertType
=
pCtx
->
inType
;
if
(
pCtx
->
inType
==
TSDB_DATA_TYPE_JSON
)
{
if
(
*
data
==
TSDB_DATA_TYPE_NULL
)
{
ASSERT
(
0
);
}
else
if
(
*
data
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
*
data
==
TSDB_DATA_TYPE_NCHAR
)
{
data
+=
CHAR_BYTES
;
convertType
=
TSDB_DATA_TYPE_NCHAR
;
}
else
if
(
tTagIsJson
(
data
))
{
}
else
if
(
tTagIsJson
(
data
)
||
*
data
==
TSDB_DATA_TYPE_NULL
)
{
terrno
=
TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR
;
return
terrno
;
}
else
{
...
...
@@ -447,7 +445,11 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) {
tmp
[
varDataLen
(
data
)]
=
0
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
convertType
)
{
// we need to convert it to native char string, and then perform the string to numeric data
ASSERT
(
varDataLen
(
data
)
<=
bufSize
);
if
(
varDataLen
(
data
)
>
bufSize
)
{
sclError
(
"castConvert convert buffer size too small"
);
taosMemoryFreeClear
(
tmp
);
return
TSDB_CODE_APP_ERROR
;
}
int
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
data
),
varDataLen
(
data
),
tmp
);
if
(
len
<
0
)
{
...
...
@@ -557,27 +559,17 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
*
fp
=
filterGetCompFunc
(
type
,
optr
);
if
(
IS_NUMERIC_TYPE
(
type
))
{
if
(
typeLeft
==
TSDB_DATA_TYPE_NCHAR
)
{
ASSERT
(
0
);
// convertNcharToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
}
else
if
(
typeLeft
==
TSDB_DATA_TYPE_BINARY
)
{
ASSERT
(
0
);
// convertBinaryToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
if
(
typeLeft
==
TSDB_DATA_TYPE_NCHAR
||
typeLeft
==
TSDB_DATA_TYPE_VARCHAR
)
{
return
false
;
}
else
if
(
typeLeft
!=
type
)
{
convertNumberToNumber
(
*
pLeftData
,
pLeftOut
,
typeLeft
,
type
);
*
pLeftData
=
pLeftOut
;
}
if
(
typeRight
==
TSDB_DATA_TYPE_NCHAR
)
{
ASSERT
(
0
);
// convertNcharToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
}
else
if
(
typeRight
==
TSDB_DATA_TYPE_BINARY
)
{
ASSERT
(
0
);
// convertBinaryToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
if
(
typeRight
==
TSDB_DATA_TYPE_NCHAR
||
typeRight
==
TSDB_DATA_TYPE_VARCHAR
)
{
return
false
;
}
else
if
(
typeRight
!=
type
)
{
convertNumberToNumber
(
*
pRightData
,
pRightOut
,
typeRight
,
type
);
*
pRightData
=
pRightOut
;
...
...
@@ -592,7 +584,7 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
*
freeRight
=
true
;
}
}
else
{
ASSERT
(
0
)
;
return
false
;
}
return
true
;
...
...
@@ -683,7 +675,10 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut,
}
if
(
overflow
)
{
ASSERT
(
1
==
pIn
->
numOfRows
);
if
(
1
!=
pIn
->
numOfRows
)
{
sclError
(
"invalid numOfRows %d"
,
pIn
->
numOfRows
);
return
TSDB_CODE_APP_ERROR
;
}
pOut
->
numOfRows
=
0
;
...
...
@@ -1938,7 +1933,6 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
case
OP_TYPE_JSON_CONTAINS
:
return
vectorJsonContains
;
default:
ASSERT
(
0
);
return
NULL
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录