Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
5b3d0de3
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
5b3d0de3
编写于
11月 05, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
11月 05, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4118 from taosdata/feature/query
Feature/query
上级
6bf2e4d0
37f485a9
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
177 addition
and
211 deletion
+177
-211
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+2
-2
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+5
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+6
-6
src/query/inc/qFill.h
src/query/inc/qFill.h
+1
-2
src/query/inc/qTsbuf.h
src/query/inc/qTsbuf.h
+18
-18
src/query/src/qAst.c
src/query/src/qAst.c
+8
-46
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+3
-3
src/query/src/qFill.c
src/query/src/qFill.c
+2
-2
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+117
-117
src/query/tests/tsBufTest.cpp
src/query/tests/tsBufTest.cpp
+14
-14
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
5b3d0de3
...
...
@@ -3978,7 +3978,7 @@ static void interp_function(SQLFunctionCtx *pCtx) {
if
(
isNull
(
data1
,
srcType
)
||
isNull
(
data2
,
srcType
))
{
setNull
(
pCtx
->
aOutputBuf
,
srcType
,
pCtx
->
inputBytes
);
}
else
{
taos
DoLinearInterpolation
(
pCtx
->
outputType
,
&
point1
,
&
point2
,
&
point
);
taos
GetLinearInterpolationVal
(
pCtx
->
outputType
,
&
point1
,
&
point2
,
&
point
);
}
}
else
if
(
srcType
==
TSDB_DATA_TYPE_FLOAT
)
{
point1
.
val
=
data1
;
...
...
@@ -3987,7 +3987,7 @@ static void interp_function(SQLFunctionCtx *pCtx) {
if
(
isNull
(
data1
,
srcType
)
||
isNull
(
data2
,
srcType
))
{
setNull
(
pCtx
->
aOutputBuf
,
srcType
,
pCtx
->
inputBytes
);
}
else
{
taos
DoLinearInterpolation
(
pCtx
->
outputType
,
&
point1
,
&
point2
,
&
point
);
taos
GetLinearInterpolationVal
(
pCtx
->
outputType
,
&
point1
,
&
point2
,
&
point
);
}
}
else
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
5b3d0de3
...
...
@@ -2758,6 +2758,7 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
const
char
*
msg1
=
"too many columns in group by clause"
;
const
char
*
msg2
=
"invalid column name in group by clause"
;
const
char
*
msg3
=
"columns from one table allowed as group by columns"
;
const
char
*
msg4
=
"join query does not support group by"
;
const
char
*
msg7
=
"not support group by expression"
;
const
char
*
msg8
=
"not allowed column type for group by"
;
const
char
*
msg9
=
"tags not allowed for table query"
;
...
...
@@ -2778,6 +2779,10 @@ int32_t parseGroupbyClause(SQueryInfo* pQueryInfo, tVariantList* pList, SSqlCmd*
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
if
(
pQueryInfo
->
numOfTables
>
1
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
STableMeta
*
pTableMeta
=
NULL
;
SSchema
*
pSchema
=
NULL
;
SSchema
s
=
tscGetTbnameColumnSchema
();
...
...
src/client/src/tscServer.c
浏览文件 @
5b3d0de3
...
...
@@ -882,7 +882,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if
(
pQueryInfo
->
tsBuf
!=
NULL
)
{
// note: here used the index instead of actual vnode id.
int32_t
vnodeIndex
=
pTableMetaInfo
->
vgroupIndex
;
int32_t
code
=
dumpFileBlockBy
Vnode
Id
(
pQueryInfo
->
tsBuf
,
vnodeIndex
,
pMsg
,
&
pQueryMsg
->
tsLen
,
&
pQueryMsg
->
tsNumOfBlocks
);
int32_t
code
=
dumpFileBlockBy
Group
Id
(
pQueryInfo
->
tsBuf
,
vnodeIndex
,
pMsg
,
&
pQueryMsg
->
tsLen
,
&
pQueryMsg
->
tsNumOfBlocks
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
5b3d0de3
...
...
@@ -156,8 +156,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
win
->
ekey
=
elem1
.
ts
;
}
tsBufAppend
(
output1
,
elem1
.
vnode
,
elem1
.
tag
,
(
const
char
*
)
&
elem1
.
ts
,
sizeof
(
elem1
.
ts
));
tsBufAppend
(
output2
,
elem2
.
vnode
,
elem2
.
tag
,
(
const
char
*
)
&
elem2
.
ts
,
sizeof
(
elem2
.
ts
));
tsBufAppend
(
output1
,
elem1
.
id
,
elem1
.
tag
,
(
const
char
*
)
&
elem1
.
ts
,
sizeof
(
elem1
.
ts
));
tsBufAppend
(
output2
,
elem2
.
id
,
elem2
.
tag
,
(
const
char
*
)
&
elem2
.
ts
,
sizeof
(
elem2
.
ts
));
}
else
{
pLimit
->
offset
-=
1
;
//offset apply to projection?
}
...
...
@@ -193,8 +193,8 @@ static int64_t doTSBlockIntersect(SSqlObj* pSql, SJoinSupporter* pSupporter1, SJ
TSKEY
et
=
taosGetTimestampUs
();
tscDebug
(
"%p input1:%"
PRId64
", input2:%"
PRId64
", final:%"
PRId64
" in %d vnodes for secondary query after ts blocks "
"intersecting, skey:%"
PRId64
", ekey:%"
PRId64
", numOfVnode:%d, elapsed time:%"
PRId64
" us"
,
pSql
,
numOfInput1
,
numOfInput2
,
output1
->
numOfTotal
,
output1
->
numOf
Vnode
s
,
win
->
skey
,
win
->
ekey
,
tsBufGetNumOf
Vnodes
(
output1
),
et
-
st
);
pSql
,
numOfInput1
,
numOfInput2
,
output1
->
numOfTotal
,
output1
->
numOf
Group
s
,
win
->
skey
,
win
->
ekey
,
tsBufGetNumOf
Group
(
output1
),
et
-
st
);
return
output1
->
numOfTotal
;
}
...
...
@@ -282,7 +282,7 @@ static UNUSED_FUNC bool needSecondaryQuery(SQueryInfo* pQueryInfo) {
static
void
filterVgroupTables
(
SQueryInfo
*
pQueryInfo
,
SArray
*
pVgroupTables
)
{
int32_t
num
=
0
;
int32_t
*
list
=
NULL
;
tsBufGet
Vnode
IdList
(
pQueryInfo
->
tsBuf
,
&
num
,
&
list
);
tsBufGet
Group
IdList
(
pQueryInfo
->
tsBuf
,
&
num
,
&
list
);
// The virtual node, of which all tables are disqualified after the timestamp intersection,
// is removed to avoid next stage query.
...
...
@@ -314,7 +314,7 @@ static void filterVgroupTables(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
static
SArray
*
buildVgroupTableByResult
(
SQueryInfo
*
pQueryInfo
,
SArray
*
pVgroupTables
)
{
int32_t
num
=
0
;
int32_t
*
list
=
NULL
;
tsBufGet
Vnode
IdList
(
pQueryInfo
->
tsBuf
,
&
num
,
&
list
);
tsBufGet
Group
IdList
(
pQueryInfo
->
tsBuf
,
&
num
,
&
list
);
size_t
numOfGroups
=
taosArrayGetSize
(
pVgroupTables
);
...
...
src/query/inc/qFill.h
浏览文件 @
5b3d0de3
...
...
@@ -49,7 +49,6 @@ typedef struct SFillInfo {
int32_t
numOfTags
;
// number of tags
int32_t
numOfCols
;
// number of columns, including the tags columns
int32_t
rowSize
;
// size of each row
// char ** pTags; // tags value for current interpolation
SFillTagColInfo
*
pTags
;
// tags value for filling gap
SInterval
interval
;
char
*
prevValues
;
// previous row of data, to generate the interpolation results
...
...
@@ -83,7 +82,7 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, int64_t ekey, int32_t maxNumOfRo
int32_t
taosNumOfRemainRows
(
SFillInfo
*
pFillInfo
);
int
taosDoLinearInterpolation
(
int32_t
type
,
SPoint
*
point1
,
SPoint
*
point2
,
SPoint
*
point
);
int
32_t
taosGetLinearInterpolationVal
(
int32_t
type
,
SPoint
*
point1
,
SPoint
*
point2
,
SPoint
*
point
);
int64_t
taosGenerateDataBlock
(
SFillInfo
*
pFillInfo
,
tFilePage
**
output
,
int32_t
capacity
);
...
...
src/query/inc/qTsbuf.h
浏览文件 @
5b3d0de3
...
...
@@ -26,7 +26,7 @@ extern "C" {
#define MEM_BUF_SIZE (1 << 20)
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
#define TS_COMP_FILE_
VNODE
_MAX 512
#define TS_COMP_FILE_
GROUP
_MAX 512
typedef
struct
STSList
{
char
*
rawBuf
;
...
...
@@ -38,7 +38,7 @@ typedef struct STSList {
typedef
struct
STSElem
{
TSKEY
ts
;
tVariant
*
tag
;
int32_t
vnode
;
int32_t
id
;
}
STSElem
;
typedef
struct
STSCursor
{
...
...
@@ -60,17 +60,17 @@ typedef struct STSBlock {
* The size of buffer file should not be greater than 2G,
* and the offset of int32_t type is enough
*/
typedef
struct
STS
Vnode
BlockInfo
{
int32_t
vnode
;
// vnode
id
typedef
struct
STS
Group
BlockInfo
{
int32_t
id
;
// group
id
int32_t
offset
;
// offset set value in file
int32_t
numOfBlocks
;
// number of total blocks
int32_t
compLen
;
// compressed size
}
STS
Vnode
BlockInfo
;
}
STS
Group
BlockInfo
;
typedef
struct
STS
Vnode
BlockInfoEx
{
STS
Vnode
BlockInfo
info
;
typedef
struct
STS
Group
BlockInfoEx
{
STS
Group
BlockInfo
info
;
int32_t
len
;
// length before compress
}
STS
Vnode
BlockInfoEx
;
}
STS
Group
BlockInfoEx
;
typedef
struct
STSBuf
{
FILE
*
f
;
...
...
@@ -78,9 +78,9 @@ typedef struct STSBuf {
uint32_t
fileSize
;
// todo use array
STS
Vnode
BlockInfoEx
*
pData
;
STS
Group
BlockInfoEx
*
pData
;
uint32_t
numOfAlloc
;
uint32_t
numOf
Vnode
s
;
uint32_t
numOf
Group
s
;
char
*
assistBuf
;
int32_t
bufSize
;
...
...
@@ -94,22 +94,22 @@ typedef struct STSBuf {
typedef
struct
STSBufFileHeader
{
uint32_t
magic
;
// file magic number
uint32_t
numOf
Vnode
;
// number of vnode
stored in current file
uint32_t
numOf
Group
;
// number of group
stored in current file
int32_t
tsOrder
;
// timestamp order in current file
}
STSBufFileHeader
;
STSBuf
*
tsBufCreate
(
bool
autoDelete
,
int32_t
order
);
STSBuf
*
tsBufCreateFromFile
(
const
char
*
path
,
bool
autoDelete
);
STSBuf
*
tsBufCreateFromCompBlocks
(
const
char
*
pData
,
int32_t
numOfBlocks
,
int32_t
len
,
int32_t
tsOrder
,
int32_t
vnodeI
d
);
STSBuf
*
tsBufCreateFromCompBlocks
(
const
char
*
pData
,
int32_t
numOfBlocks
,
int32_t
len
,
int32_t
tsOrder
,
int32_t
i
d
);
void
*
tsBufDestroy
(
STSBuf
*
pTSBuf
);
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
,
tVariant
*
tag
,
const
char
*
pData
,
int32_t
len
);
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
i
d
,
tVariant
*
tag
,
const
char
*
pData
,
int32_t
len
);
int32_t
tsBufMerge
(
STSBuf
*
pDestBuf
,
const
STSBuf
*
pSrcBuf
);
STSBuf
*
tsBufClone
(
STSBuf
*
pTSBuf
);
STS
VnodeBlockInfo
*
tsBufGetVnodeBlockInfo
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
);
STS
GroupBlockInfo
*
tsBufGetGroupBlockInfo
(
STSBuf
*
pTSBuf
,
int32_t
i
d
);
void
tsBufFlush
(
STSBuf
*
pTSBuf
);
...
...
@@ -118,7 +118,7 @@ STSElem tsBufGetElem(STSBuf* pTSBuf);
bool
tsBufNextPos
(
STSBuf
*
pTSBuf
);
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
,
tVariant
*
tag
);
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
i
d
,
tVariant
*
tag
);
STSCursor
tsBufGetCursor
(
STSBuf
*
pTSBuf
);
void
tsBufSetTraverseOrder
(
STSBuf
*
pTSBuf
,
int32_t
order
);
...
...
@@ -131,11 +131,11 @@ void tsBufSetCursor(STSBuf* pTSBuf, STSCursor* pCur);
*/
void
tsBufDisplay
(
STSBuf
*
pTSBuf
);
int32_t
tsBufGetNumOf
Vnodes
(
STSBuf
*
pTSBuf
);
int32_t
tsBufGetNumOf
Group
(
STSBuf
*
pTSBuf
);
void
tsBufGet
VnodeIdList
(
STSBuf
*
pTSBuf
,
int32_t
*
num
,
int32_t
**
vnodeI
d
);
void
tsBufGet
GroupIdList
(
STSBuf
*
pTSBuf
,
int32_t
*
num
,
int32_t
**
i
d
);
int32_t
dumpFileBlockBy
VnodeId
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
,
void
*
buf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
);
int32_t
dumpFileBlockBy
GroupId
(
STSBuf
*
pTSBuf
,
int32_t
i
d
,
void
*
buf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
);
STSElem
tsBufFindElemStartPosByTag
(
STSBuf
*
pTSBuf
,
tVariant
*
pTag
);
...
...
src/query/src/qAst.c
浏览文件 @
5b3d0de3
...
...
@@ -609,7 +609,7 @@ int32_t intersect(SArray *pLeft, SArray *pRight, SArray *pFinalRes) {
/*
* traverse the result and apply the function to each item to check if the item is qualified or not
*/
static
void
tArrayTraverse
(
tExprNode
*
pExpr
,
__result_filter_fn_t
fp
,
SArray
*
pResult
)
{
static
UNUSED_FUNC
void
tArrayTraverse
(
tExprNode
*
pExpr
,
__result_filter_fn_t
fp
,
SArray
*
pResult
)
{
assert
(
pExpr
->
_node
.
pLeft
->
nodeType
==
TSQL_NODE_COL
&&
pExpr
->
_node
.
pRight
->
nodeType
==
TSQL_NODE_VALUE
&&
fp
!=
NULL
);
// scan the result array list and check for each item in the list
...
...
@@ -660,7 +660,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *p
* @param pSchema tag schemas
* @param fp filter callback function
*/
static
void
exprTreeTraverseImpl
(
tExprNode
*
pExpr
,
SArray
*
pResult
,
SExprTraverseSupp
*
param
)
{
static
UNUSED_FUNC
void
exprTreeTraverseImpl
(
tExprNode
*
pExpr
,
SArray
*
pResult
,
SExprTraverseSupp
*
param
)
{
size_t
size
=
taosArrayGetSize
(
pResult
);
SArray
*
array
=
taosArrayInit
(
size
,
POINTER_BYTES
);
...
...
@@ -733,10 +733,6 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
assert
(
pLeft
->
nodeType
==
TSQL_NODE_COL
&&
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
||
pRight
->
nodeType
==
TSQL_NODE_DUMMY
));
param
->
setupInfoFn
(
pExpr
,
param
->
pExtInfo
);
if
(
pSkipList
==
NULL
)
{
tArrayTraverse
(
pExpr
,
param
->
nodeFilterFn
,
result
);
return
;
}
tQueryInfo
*
pQueryInfo
=
pExpr
->
_node
.
info
;
if
(
pQueryInfo
->
indexed
&&
pQueryInfo
->
optr
!=
TSDB_RELATION_LIKE
)
{
...
...
@@ -748,49 +744,14 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
return
;
}
//
recursive traverse left child branch
//
The value of hasPK is always 0.
uint8_t
weight
=
pLeft
->
_node
.
hasPK
+
pRight
->
_node
.
hasPK
;
assert
(
weight
==
0
&&
pSkipList
!=
NULL
&&
taosArrayGetSize
(
result
)
==
0
);
if
(
weight
==
0
)
{
if
(
taosArrayGetSize
(
result
)
>
0
&&
pSkipList
==
NULL
)
{
/**
* Perform the filter operation based on the initial filter result, which is obtained from filtering from index.
* Since no index presented, the filter operation is done by scan all elements in the result set.
*
* if the query is a high selectivity filter, only small portion of meters are retrieved.
*/
exprTreeTraverseImpl
(
pExpr
,
result
,
param
);
}
else
{
/**
* apply the hierarchical expression to every node in skiplist for find the qualified nodes
*/
assert
(
taosArrayGetSize
(
result
)
==
0
);
tSQLBinaryTraverseOnSkipList
(
pExpr
,
result
,
pSkipList
,
param
);
}
return
;
}
if
(
weight
==
2
||
(
weight
==
1
&&
pExpr
->
_node
.
optr
==
TSDB_RELATION_OR
))
{
SArray
*
rLeft
=
taosArrayInit
(
10
,
POINTER_BYTES
);
SArray
*
rRight
=
taosArrayInit
(
10
,
POINTER_BYTES
);
tExprTreeTraverse
(
pLeft
,
pSkipList
,
rLeft
,
param
);
tExprTreeTraverse
(
pRight
,
pSkipList
,
rRight
,
param
);
if
(
pExpr
->
_node
.
optr
==
TSDB_RELATION_AND
)
{
// CROSS
intersect
(
rLeft
,
rRight
,
result
);
}
else
if
(
pExpr
->
_node
.
optr
==
TSDB_RELATION_OR
)
{
// or
merge
(
rLeft
,
rRight
,
result
);
}
else
{
assert
(
false
);
}
taosArrayDestroy
(
rLeft
);
taosArrayDestroy
(
rRight
);
return
;
}
//apply the hierarchical expression to every node in skiplist for find the qualified nodes
tSQLBinaryTraverseOnSkipList
(
pExpr
,
result
,
pSkipList
,
param
);
#if 0
/*
* (weight == 1 && pExpr->nSQLBinaryOptr == TSDB_RELATION_AND) is handled here
*
...
...
@@ -819,6 +780,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
* So, we do not set the skip list index as a parameter
*/
tExprTreeTraverse(pSecond, NULL, result, param);
#endif
}
void
tExprTreeCalcTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
...
...
src/query/src/qExecutor.c
浏览文件 @
5b3d0de3
...
...
@@ -3843,7 +3843,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ
STSElem
elem
=
tsBufGetElemStartPos
(
pRuntimeEnv
->
pTSBuf
,
pQInfo
->
vgId
,
&
pTableQueryInfo
->
tag
);
// failed to find data with the specified tag value and vnodeId
if
(
elem
.
vnode
<
0
)
{
if
(
!
tsBufIsValidElem
(
&
elem
)
)
{
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qError
(
"QInfo:%p failed to find tag:%s in ts_comp"
,
pQInfo
,
pTag
->
pz
);
}
else
{
...
...
@@ -4777,7 +4777,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
if
(
pRuntimeEnv
->
cur
.
vgroupIndex
==
-
1
)
{
STSElem
elem
=
tsBufGetElemStartPos
(
pRuntimeEnv
->
pTSBuf
,
pQInfo
->
vgId
,
pTag
);
// failed to find data with the specified tag value and vnodeId
if
(
elem
.
vnode
<
0
)
{
if
(
!
tsBufIsValidElem
(
&
elem
)
)
{
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qError
(
"QInfo:%p failed to find tag:%s in ts_comp"
,
pQInfo
,
pTag
->
pz
);
}
else
{
...
...
@@ -4802,7 +4802,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
STSElem
elem1
=
tsBufGetElemStartPos
(
pRuntimeEnv
->
pTSBuf
,
pQInfo
->
vgId
,
pTag
);
// failed to find data with the specified tag value and vnodeId
if
(
elem1
.
vnode
<
0
)
{
if
(
!
tsBufIsValidElem
(
&
elem1
)
)
{
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qError
(
"QInfo:%p failed to find tag:%s in ts_comp"
,
pQInfo
,
pTag
->
pz
);
}
else
{
...
...
src/query/src/qFill.c
浏览文件 @
5b3d0de3
...
...
@@ -215,7 +215,7 @@ static double linearInterpolationImpl(double v1, double v2, double k1, double k2
return
v1
+
(
v2
-
v1
)
*
(
k
-
k1
)
/
(
k2
-
k1
);
}
int
taosDoLinearInterpolation
(
int32_t
type
,
SPoint
*
point1
,
SPoint
*
point2
,
SPoint
*
point
)
{
int
32_t
taosGetLinearInterpolationVal
(
int32_t
type
,
SPoint
*
point1
,
SPoint
*
point2
,
SPoint
*
point
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
*
(
int32_t
*
)
point
->
val
=
(
int32_t
)
linearInterpolationImpl
(
*
(
int32_t
*
)
point1
->
val
,
*
(
int32_t
*
)
point2
->
val
,
(
double
)
point1
->
key
,
...
...
@@ -343,7 +343,7 @@ static void doFillResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* nu
point1
=
(
SPoint
){.
key
=
*
(
TSKEY
*
)(
prevValues
),
.
val
=
prevValues
+
pCol
->
col
.
offset
};
point2
=
(
SPoint
){.
key
=
ts
,
.
val
=
srcData
[
i
]
+
pFillInfo
->
rowIdx
*
bytes
};
point
=
(
SPoint
){.
key
=
pFillInfo
->
start
,
.
val
=
val1
};
taos
DoLinearInterpolation
(
type
,
&
point1
,
&
point2
,
&
point
);
taos
GetLinearInterpolationVal
(
type
,
&
point1
,
&
point2
,
&
point
);
}
setTagsValue
(
pFillInfo
,
data
,
*
num
);
...
...
src/query/src/qTsbuf.c
浏览文件 @
5b3d0de3
此差异已折叠。
点击以展开。
src/query/tests/tsBufTest.cpp
浏览文件 @
5b3d0de3
...
...
@@ -42,7 +42,7 @@ void simpleTest() {
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
sizeof
(
int64_t
)
*
num
);
EXPECT_EQ
(
tVariantCompare
(
&
pTSBuf
->
block
.
tag
,
&
t
),
0
);
EXPECT_EQ
(
pTSBuf
->
numOf
Vnode
s
,
1
);
EXPECT_EQ
(
pTSBuf
->
numOf
Group
s
,
1
);
tsBufFlush
(
pTSBuf
);
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
0
);
...
...
@@ -69,7 +69,7 @@ void largeTSTest() {
// the data has been flush to disk, no data in cache
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
0
);
EXPECT_EQ
(
tVariantCompare
(
&
pTSBuf
->
block
.
tag
,
&
t
),
0
);
EXPECT_EQ
(
pTSBuf
->
numOf
Vnode
s
,
1
);
EXPECT_EQ
(
pTSBuf
->
numOf
Group
s
,
1
);
EXPECT_EQ
(
pTSBuf
->
tsOrder
,
TSDB_ORDER_ASC
);
tsBufFlush
(
pTSBuf
);
...
...
@@ -105,7 +105,7 @@ void multiTagsTest() {
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
num
*
sizeof
(
int64_t
));
EXPECT_EQ
(
pTSBuf
->
block
.
tag
.
i64Key
,
numOfTags
-
1
);
EXPECT_EQ
(
pTSBuf
->
numOf
Vnode
s
,
1
);
EXPECT_EQ
(
pTSBuf
->
numOf
Group
s
,
1
);
tsBufFlush
(
pTSBuf
);
EXPECT_EQ
(
pTSBuf
->
tsData
.
len
,
0
);
...
...
@@ -139,7 +139,7 @@ void multiVnodeTagsTest() {
start
+=
step
*
num
;
}
EXPECT_EQ
(
pTSBuf
->
numOf
Vnode
s
,
j
+
1
);
EXPECT_EQ
(
pTSBuf
->
numOf
Group
s
,
j
+
1
);
}
EXPECT_EQ
(
pTSBuf
->
tsOrder
,
TSDB_ORDER_ASC
);
...
...
@@ -184,7 +184,7 @@ void loadDataTest() {
start
+=
step
*
num
;
}
EXPECT_EQ
(
pTSBuf
->
numOf
Vnode
s
,
j
+
1
);
EXPECT_EQ
(
pTSBuf
->
numOf
Group
s
,
j
+
1
);
}
EXPECT_EQ
(
pTSBuf
->
tsOrder
,
TSDB_ORDER_ASC
);
...
...
@@ -203,7 +203,7 @@ void loadDataTest() {
// create from exists file
STSBuf
*
pNewBuf
=
tsBufCreateFromFile
(
pTSBuf
->
path
,
false
);
EXPECT_EQ
(
pNewBuf
->
tsOrder
,
pTSBuf
->
tsOrder
);
EXPECT_EQ
(
pNewBuf
->
numOf
Vnode
s
,
numOfVnode
);
EXPECT_EQ
(
pNewBuf
->
numOf
Group
s
,
numOfVnode
);
EXPECT_EQ
(
pNewBuf
->
fileSize
,
pTSBuf
->
fileSize
);
EXPECT_EQ
(
pNewBuf
->
pData
[
0
].
info
.
offset
,
pTSBuf
->
pData
[
0
].
info
.
offset
);
...
...
@@ -269,7 +269,7 @@ void TSTraverse() {
start
+=
step
*
num
;
}
EXPECT_EQ
(
pTSBuf
->
numOf
Vnode
s
,
j
+
1
);
EXPECT_EQ
(
pTSBuf
->
numOf
Group
s
,
j
+
1
);
}
tsBufResetPos
(
pTSBuf
);
...
...
@@ -304,7 +304,7 @@ void TSTraverse() {
int32_t
totalOutput
=
10
;
while
(
1
)
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
printf
(
"%d-%"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
printf
(
"%d-%"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
id
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
if
(
!
tsBufNextPos
(
pTSBuf
))
{
break
;
...
...
@@ -352,7 +352,7 @@ void TSTraverse() {
totalOutput
=
10
;
while
(
1
)
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
printf
(
"%d-%"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
printf
(
"%d-%"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
id
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
if
(
!
tsBufNextPos
(
pTSBuf
))
{
break
;
...
...
@@ -427,7 +427,7 @@ void mergeDiffVnodeBufferTest() {
tsBufFlush
(
pTSBuf2
);
tsBufMerge
(
pTSBuf1
,
pTSBuf2
);
EXPECT_EQ
(
pTSBuf1
->
numOf
Vnode
s
,
2
);
EXPECT_EQ
(
pTSBuf1
->
numOf
Group
s
,
2
);
EXPECT_EQ
(
pTSBuf1
->
numOfTotal
,
numOfTags
*
2
*
num
);
tsBufDisplay
(
pTSBuf1
);
...
...
@@ -472,7 +472,7 @@ void mergeIdenticalVnodeBufferTest() {
tsBufFlush
(
pTSBuf2
);
tsBufMerge
(
pTSBuf1
,
pTSBuf2
);
EXPECT_EQ
(
pTSBuf1
->
numOf
Vnode
s
,
2
);
EXPECT_EQ
(
pTSBuf1
->
numOf
Group
s
,
2
);
EXPECT_EQ
(
pTSBuf1
->
numOfTotal
,
numOfTags
*
2
*
num
);
tsBufResetPos
(
pTSBuf1
);
...
...
@@ -482,12 +482,12 @@ void mergeIdenticalVnodeBufferTest() {
STSElem
elem
=
tsBufGetElem
(
pTSBuf1
);
if
(
count
++
<
numOfTags
*
num
)
{
EXPECT_EQ
(
elem
.
vnode
,
12
);
EXPECT_EQ
(
elem
.
id
,
12
);
}
else
{
EXPECT_EQ
(
elem
.
vnode
,
77
);
EXPECT_EQ
(
elem
.
id
,
77
);
}
printf
(
"%d-%"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
printf
(
"%d-%"
PRIu64
"-%"
PRIu64
"
\n
"
,
elem
.
id
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
}
tsBufDestroy
(
pTSBuf1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录