Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Cherenkov effect
TDengine
提交
5b3d0de3
T
TDengine
项目概览
Cherenkov effect
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
2
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
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
);
//apply the hierarchical expression to every node in skiplist for find the qualified nodes
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
;
}
#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
...
...
@@ -4,7 +4,7 @@
#include "tutil.h"
static
int32_t
getDataStartOffset
();
static
void
TSBufUpdate
VnodeInfo
(
STSBuf
*
pTSBuf
,
int32_t
index
,
STSVnode
BlockInfo
*
pBlockInfo
);
static
void
TSBufUpdate
GroupInfo
(
STSBuf
*
pTSBuf
,
int32_t
index
,
STSGroup
BlockInfo
*
pBlockInfo
);
static
STSBuf
*
allocResForTSBuf
(
STSBuf
*
pTSBuf
);
static
int32_t
STSBufUpdateHeader
(
STSBuf
*
pTSBuf
,
STSBufFileHeader
*
pHeader
);
...
...
@@ -32,7 +32,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
}
// update the header info
STSBufFileHeader
header
=
{.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Vnode
=
pTSBuf
->
numOfVnode
s
,
.
tsOrder
=
TSDB_ORDER_ASC
};
STSBufFileHeader
header
=
{.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Group
=
pTSBuf
->
numOfGroup
s
,
.
tsOrder
=
TSDB_ORDER_ASC
};
STSBufUpdateHeader
(
pTSBuf
,
&
header
);
tsBufResetPos
(
pTSBuf
);
...
...
@@ -75,9 +75,9 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
NULL
;
}
if
(
header
.
numOf
Vnode
>
pTSBuf
->
numOfAlloc
)
{
pTSBuf
->
numOfAlloc
=
header
.
numOf
Vnode
;
STS
VnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnode
BlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
if
(
header
.
numOf
Group
>
pTSBuf
->
numOfAlloc
)
{
pTSBuf
->
numOfAlloc
=
header
.
numOf
Group
;
STS
GroupBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSGroup
BlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
if
(
tmp
==
NULL
)
{
tsBufDestroy
(
pTSBuf
);
return
NULL
;
...
...
@@ -86,7 +86,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
pTSBuf
->
pData
=
tmp
;
}
pTSBuf
->
numOf
Vnodes
=
header
.
numOfVnode
;
pTSBuf
->
numOf
Groups
=
header
.
numOfGroup
;
// check the ts order
pTSBuf
->
tsOrder
=
header
.
tsOrder
;
...
...
@@ -96,9 +96,9 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
NULL
;
}
size_t
infoSize
=
sizeof
(
STS
VnodeBlockInfo
)
*
pTSBuf
->
numOfVnode
s
;
size_t
infoSize
=
sizeof
(
STS
GroupBlockInfo
)
*
pTSBuf
->
numOfGroup
s
;
STS
VnodeBlockInfo
*
buf
=
(
STSVnode
BlockInfo
*
)
calloc
(
1
,
infoSize
);
STS
GroupBlockInfo
*
buf
=
(
STSGroup
BlockInfo
*
)
calloc
(
1
,
infoSize
);
if
(
buf
==
NULL
)
{
tsBufDestroy
(
pTSBuf
);
return
NULL
;
...
...
@@ -109,9 +109,9 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
UNUSED
(
sz
);
// the length value for each vnode is not kept in file, so does not set the length value
for
(
int32_t
i
=
0
;
i
<
pTSBuf
->
numOf
Vnode
s
;
++
i
)
{
STS
Vnode
BlockInfoEx
*
pBlockList
=
&
pTSBuf
->
pData
[
i
];
memcpy
(
&
pBlockList
->
info
,
&
buf
[
i
],
sizeof
(
STS
Vnode
BlockInfo
));
for
(
int32_t
i
=
0
;
i
<
pTSBuf
->
numOf
Group
s
;
++
i
)
{
STS
Group
BlockInfoEx
*
pBlockList
=
&
pTSBuf
->
pData
[
i
];
memcpy
(
&
pBlockList
->
info
,
&
buf
[
i
],
sizeof
(
STS
Group
BlockInfo
));
}
free
(
buf
);
...
...
@@ -131,8 +131,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
autoDelete
=
autoDelete
;
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOf
Vnode
:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
// pTSBuf->fileSize, pTSBuf->numOf
Vnode
s, pTSBuf->autoDelete);
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOf
Groups
:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
// pTSBuf->fileSize, pTSBuf->numOf
Group
s, pTSBuf->autoDelete);
return
pTSBuf
;
}
...
...
@@ -162,53 +162,53 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
return
NULL
;
}
static
STS
VnodeBlockInfoEx
*
tsBufGetLastVnode
Info
(
STSBuf
*
pTSBuf
)
{
int32_t
last
=
pTSBuf
->
numOf
Vnode
s
-
1
;
static
STS
GroupBlockInfoEx
*
tsBufGetLastGroup
Info
(
STSBuf
*
pTSBuf
)
{
int32_t
last
=
pTSBuf
->
numOf
Group
s
-
1
;
assert
(
last
>=
0
);
return
&
pTSBuf
->
pData
[
last
];
}
static
STS
VnodeBlockInfoEx
*
addOneVnodeInfo
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
)
{
if
(
pTSBuf
->
numOfAlloc
<=
pTSBuf
->
numOf
Vnode
s
)
{
static
STS
GroupBlockInfoEx
*
addOneGroupInfo
(
STSBuf
*
pTSBuf
,
int32_t
i
d
)
{
if
(
pTSBuf
->
numOfAlloc
<=
pTSBuf
->
numOf
Group
s
)
{
uint32_t
newSize
=
(
uint32_t
)(
pTSBuf
->
numOfAlloc
*
1
.
5
);
assert
((
int32_t
)
newSize
>
pTSBuf
->
numOfAlloc
);
STS
VnodeBlockInfoEx
*
tmp
=
(
STSVnodeBlockInfoEx
*
)
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnode
BlockInfoEx
)
*
newSize
);
STS
GroupBlockInfoEx
*
tmp
=
(
STSGroupBlockInfoEx
*
)
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSGroup
BlockInfoEx
)
*
newSize
);
if
(
tmp
==
NULL
)
{
return
NULL
;
}
pTSBuf
->
pData
=
tmp
;
pTSBuf
->
numOfAlloc
=
newSize
;
memset
(
&
pTSBuf
->
pData
[
pTSBuf
->
numOf
Vnodes
],
0
,
sizeof
(
STSVnodeBlockInfoEx
)
*
(
newSize
-
pTSBuf
->
numOfVnode
s
));
memset
(
&
pTSBuf
->
pData
[
pTSBuf
->
numOf
Groups
],
0
,
sizeof
(
STSGroupBlockInfoEx
)
*
(
newSize
-
pTSBuf
->
numOfGroup
s
));
}
if
(
pTSBuf
->
numOf
Vnode
s
>
0
)
{
STS
VnodeBlockInfoEx
*
pPrevBlockInfoEx
=
tsBufGetLastVnode
Info
(
pTSBuf
);
if
(
pTSBuf
->
numOf
Group
s
>
0
)
{
STS
GroupBlockInfoEx
*
pPrevBlockInfoEx
=
tsBufGetLastGroup
Info
(
pTSBuf
);
// update prev vnode length info in file
TSBufUpdate
VnodeInfo
(
pTSBuf
,
pTSBuf
->
numOfVnode
s
-
1
,
&
pPrevBlockInfoEx
->
info
);
TSBufUpdate
GroupInfo
(
pTSBuf
,
pTSBuf
->
numOfGroup
s
-
1
,
&
pPrevBlockInfoEx
->
info
);
}
// set initial value for vnode block
STS
VnodeBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
pTSBuf
->
numOfVnode
s
].
info
;
pBlockInfo
->
vnode
=
vnodeI
d
;
STS
GroupBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
pTSBuf
->
numOfGroup
s
].
info
;
pBlockInfo
->
id
=
i
d
;
pBlockInfo
->
offset
=
pTSBuf
->
fileSize
;
assert
(
pBlockInfo
->
offset
>=
getDataStartOffset
());
// update vnode info in file
TSBufUpdate
VnodeInfo
(
pTSBuf
,
pTSBuf
->
numOfVnode
s
,
pBlockInfo
);
TSBufUpdate
GroupInfo
(
pTSBuf
,
pTSBuf
->
numOfGroup
s
,
pBlockInfo
);
// add one vnode info
pTSBuf
->
numOf
Vnode
s
+=
1
;
pTSBuf
->
numOf
Group
s
+=
1
;
// update the header info
STSBufFileHeader
header
=
{
.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Vnode
=
pTSBuf
->
numOfVnode
s
,
.
tsOrder
=
pTSBuf
->
tsOrder
};
.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Group
=
pTSBuf
->
numOfGroup
s
,
.
tsOrder
=
pTSBuf
->
tsOrder
};
STSBufUpdateHeader
(
pTSBuf
,
&
header
);
return
tsBufGetLast
Vnode
Info
(
pTSBuf
);
return
tsBufGetLast
Group
Info
(
pTSBuf
);
}
static
void
shrinkBuffer
(
STSList
*
ptsData
)
{
...
...
@@ -279,10 +279,10 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
pTSBuf
->
tsData
.
len
=
0
;
STS
VnodeBlockInfoEx
*
pVnodeBlockInfoEx
=
tsBufGetLastVnode
Info
(
pTSBuf
);
STS
GroupBlockInfoEx
*
pGroupBlockInfoEx
=
tsBufGetLastGroup
Info
(
pTSBuf
);
p
Vnode
BlockInfoEx
->
info
.
compLen
+=
blockSize
;
p
Vnode
BlockInfoEx
->
info
.
numOfBlocks
+=
1
;
p
Group
BlockInfoEx
->
info
.
compLen
+=
blockSize
;
p
Group
BlockInfoEx
->
info
.
numOfBlocks
+=
1
;
shrinkBuffer
(
&
pTSBuf
->
tsData
);
}
...
...
@@ -413,20 +413,20 @@ static int32_t setCheckTSOrder(STSBuf* pTSBuf, const char* pData, int32_t len) {
return
TSDB_CODE_SUCCESS
;
}
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
,
tVariant
*
tag
,
const
char
*
pData
,
int32_t
len
)
{
STS
Vnode
BlockInfoEx
*
pBlockInfo
=
NULL
;
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
i
d
,
tVariant
*
tag
,
const
char
*
pData
,
int32_t
len
)
{
STS
Group
BlockInfoEx
*
pBlockInfo
=
NULL
;
STSList
*
ptsData
=
&
pTSBuf
->
tsData
;
if
(
pTSBuf
->
numOf
Vnodes
==
0
||
tsBufGetLastVnodeInfo
(
pTSBuf
)
->
info
.
vnode
!=
vnodeI
d
)
{
if
(
pTSBuf
->
numOf
Groups
==
0
||
tsBufGetLastGroupInfo
(
pTSBuf
)
->
info
.
id
!=
i
d
)
{
writeDataToDisk
(
pTSBuf
);
shrinkBuffer
(
ptsData
);
pBlockInfo
=
addOne
VnodeInfo
(
pTSBuf
,
vnodeI
d
);
pBlockInfo
=
addOne
GroupInfo
(
pTSBuf
,
i
d
);
}
else
{
pBlockInfo
=
tsBufGetLast
Vnode
Info
(
pTSBuf
);
pBlockInfo
=
tsBufGetLast
Group
Info
(
pTSBuf
);
}
assert
(
pBlockInfo
->
info
.
vnode
==
vnodeI
d
);
assert
(
pBlockInfo
->
info
.
id
==
i
d
);
if
((
tVariantCompare
(
&
pTSBuf
->
block
.
tag
,
tag
)
!=
0
)
&&
ptsData
->
len
>
0
)
{
// new arrived data with different tags value, save current value into disk first
...
...
@@ -464,23 +464,23 @@ void tsBufFlush(STSBuf* pTSBuf) {
writeDataToDisk
(
pTSBuf
);
shrinkBuffer
(
&
pTSBuf
->
tsData
);
STS
VnodeBlockInfoEx
*
pBlockInfoEx
=
tsBufGetLastVnode
Info
(
pTSBuf
);
STS
GroupBlockInfoEx
*
pBlockInfoEx
=
tsBufGetLastGroup
Info
(
pTSBuf
);
// update prev vnode length info in file
TSBufUpdate
VnodeInfo
(
pTSBuf
,
pTSBuf
->
numOfVnode
s
-
1
,
&
pBlockInfoEx
->
info
);
TSBufUpdate
GroupInfo
(
pTSBuf
,
pTSBuf
->
numOfGroup
s
-
1
,
&
pBlockInfoEx
->
info
);
// save the ts order into header
STSBufFileHeader
header
=
{
.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Vnode
=
pTSBuf
->
numOfVnode
s
,
.
tsOrder
=
pTSBuf
->
tsOrder
};
.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Group
=
pTSBuf
->
numOfGroup
s
,
.
tsOrder
=
pTSBuf
->
tsOrder
};
STSBufUpdateHeader
(
pTSBuf
,
&
header
);
fsync
(
fileno
(
pTSBuf
->
f
));
}
static
int32_t
tsBufFind
VnodeById
(
STSVnodeBlockInfoEx
*
pVnodeInfoEx
,
int32_t
numOfVnodes
,
int32_t
vnodeI
d
)
{
static
int32_t
tsBufFind
GroupById
(
STSGroupBlockInfoEx
*
pGroupInfoEx
,
int32_t
numOfGroups
,
int32_t
i
d
)
{
int32_t
j
=
-
1
;
for
(
int32_t
i
=
0
;
i
<
numOf
Vnode
s
;
++
i
)
{
if
(
p
VnodeInfoEx
[
i
].
info
.
vnode
==
vnodeI
d
)
{
for
(
int32_t
i
=
0
;
i
<
numOf
Group
s
;
++
i
)
{
if
(
p
GroupInfoEx
[
i
].
info
.
id
==
i
d
)
{
j
=
i
;
break
;
}
...
...
@@ -490,7 +490,7 @@ static int32_t tsBufFindVnodeById(STSVnodeBlockInfoEx* pVnodeInfoEx, int32_t num
}
// todo opt performance by cache blocks info
static
int32_t
tsBufFindBlock
(
STSBuf
*
pTSBuf
,
STS
Vnode
BlockInfo
*
pBlockInfo
,
int32_t
blockIndex
)
{
static
int32_t
tsBufFindBlock
(
STSBuf
*
pTSBuf
,
STS
Group
BlockInfo
*
pBlockInfo
,
int32_t
blockIndex
)
{
if
(
fseek
(
pTSBuf
->
f
,
pBlockInfo
->
offset
,
SEEK_SET
)
!=
0
)
{
return
-
1
;
}
...
...
@@ -517,7 +517,7 @@ static int32_t tsBufFindBlock(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo, int
return
0
;
}
static
int32_t
tsBufFindBlockByTag
(
STSBuf
*
pTSBuf
,
STS
Vnode
BlockInfo
*
pBlockInfo
,
tVariant
*
tag
)
{
static
int32_t
tsBufFindBlockByTag
(
STSBuf
*
pTSBuf
,
STS
Group
BlockInfo
*
pBlockInfo
,
tVariant
*
tag
)
{
bool
decomp
=
false
;
int64_t
offset
=
0
;
...
...
@@ -544,14 +544,14 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo
return
-
1
;
}
static
void
tsBufGetBlock
(
STSBuf
*
pTSBuf
,
int32_t
vnode
Index
,
int32_t
blockIndex
)
{
STS
VnodeBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
vnode
Index
].
info
;
static
void
tsBufGetBlock
(
STSBuf
*
pTSBuf
,
int32_t
group
Index
,
int32_t
blockIndex
)
{
STS
GroupBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
group
Index
].
info
;
if
(
pBlockInfo
->
numOfBlocks
<=
blockIndex
)
{
assert
(
false
);
}
STSCursor
*
pCur
=
&
pTSBuf
->
cur
;
if
(
pCur
->
vgroupIndex
==
vnode
Index
&&
((
pCur
->
blockIndex
<=
blockIndex
&&
pCur
->
order
==
TSDB_ORDER_ASC
)
||
if
(
pCur
->
vgroupIndex
==
group
Index
&&
((
pCur
->
blockIndex
<=
blockIndex
&&
pCur
->
order
==
TSDB_ORDER_ASC
)
||
(
pCur
->
blockIndex
>=
blockIndex
&&
pCur
->
order
==
TSDB_ORDER_DESC
)))
{
int32_t
i
=
0
;
bool
decomp
=
false
;
...
...
@@ -586,13 +586,13 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t vnodeIndex, int32_t blockIndex
assert
((
pTSBuf
->
tsData
.
len
/
TSDB_KEYSIZE
==
pBlock
->
numOfElem
)
&&
(
pTSBuf
->
tsData
.
allocSize
>=
pTSBuf
->
tsData
.
len
));
pCur
->
vgroupIndex
=
vnode
Index
;
pCur
->
vgroupIndex
=
group
Index
;
pCur
->
blockIndex
=
blockIndex
;
pCur
->
tsIndex
=
(
pCur
->
order
==
TSDB_ORDER_ASC
)
?
0
:
pBlock
->
numOfElem
-
1
;
}
static
int32_t
doUpdate
VnodeInfo
(
STSBuf
*
pTSBuf
,
int64_t
offset
,
STSVnode
BlockInfo
*
pVInfo
)
{
static
int32_t
doUpdate
GroupInfo
(
STSBuf
*
pTSBuf
,
int64_t
offset
,
STSGroup
BlockInfo
*
pVInfo
)
{
if
(
offset
<
0
||
offset
>=
getDataStartOffset
())
{
return
-
1
;
}
...
...
@@ -601,12 +601,12 @@ static int32_t doUpdateVnodeInfo(STSBuf* pTSBuf, int64_t offset, STSVnodeBlockIn
return
-
1
;
}
fwrite
(
pVInfo
,
sizeof
(
STS
Vnode
BlockInfo
),
1
,
pTSBuf
->
f
);
fwrite
(
pVInfo
,
sizeof
(
STS
Group
BlockInfo
),
1
,
pTSBuf
->
f
);
return
0
;
}
STS
VnodeBlockInfo
*
tsBufGetVnodeBlockInfo
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
)
{
int32_t
j
=
tsBufFind
VnodeById
(
pTSBuf
->
pData
,
pTSBuf
->
numOfVnodes
,
vnodeI
d
);
STS
GroupBlockInfo
*
tsBufGetGroupBlockInfo
(
STSBuf
*
pTSBuf
,
int32_t
i
d
)
{
int32_t
j
=
tsBufFind
GroupById
(
pTSBuf
->
pData
,
pTSBuf
->
numOfGroups
,
i
d
);
if
(
j
==
-
1
)
{
return
NULL
;
}
...
...
@@ -615,7 +615,7 @@ STSVnodeBlockInfo* tsBufGetVnodeBlockInfo(STSBuf* pTSBuf, int32_t vnodeId) {
}
int32_t
STSBufUpdateHeader
(
STSBuf
*
pTSBuf
,
STSBufFileHeader
*
pHeader
)
{
if
((
pTSBuf
->
f
==
NULL
)
||
pHeader
==
NULL
||
pHeader
->
numOf
Vnode
==
0
||
pHeader
->
magic
!=
TS_COMP_FILE_MAGIC
)
{
if
((
pTSBuf
->
f
==
NULL
)
||
pHeader
==
NULL
||
pHeader
->
numOf
Group
==
0
||
pHeader
->
magic
!=
TS_COMP_FILE_MAGIC
)
{
return
-
1
;
}
...
...
@@ -631,7 +631,7 @@ int32_t STSBufUpdateHeader(STSBuf* pTSBuf, STSBufFileHeader* pHeader) {
}
bool
tsBufNextPos
(
STSBuf
*
pTSBuf
)
{
if
(
pTSBuf
==
NULL
||
pTSBuf
->
numOf
Vnode
s
==
0
)
{
if
(
pTSBuf
==
NULL
||
pTSBuf
->
numOf
Group
s
==
0
)
{
return
false
;
}
...
...
@@ -650,16 +650,16 @@ bool tsBufNextPos(STSBuf* pTSBuf) {
}
}
else
{
// get the last timestamp record in the last block of the last vnode
assert
(
pTSBuf
->
numOf
Vnode
s
>
0
);
assert
(
pTSBuf
->
numOf
Group
s
>
0
);
int32_t
vnodeIndex
=
pTSBuf
->
numOfVnode
s
-
1
;
pCur
->
vgroupIndex
=
vnode
Index
;
int32_t
groupIndex
=
pTSBuf
->
numOfGroup
s
-
1
;
pCur
->
vgroupIndex
=
group
Index
;
int32_t
vnodeId
=
pTSBuf
->
pData
[
pCur
->
vgroupIndex
].
info
.
vnode
;
STS
VnodeBlockInfo
*
pBlockInfo
=
tsBufGetVnodeBlockInfo
(
pTSBuf
,
vnodeI
d
);
int32_t
id
=
pTSBuf
->
pData
[
pCur
->
vgroupIndex
].
info
.
id
;
STS
GroupBlockInfo
*
pBlockInfo
=
tsBufGetGroupBlockInfo
(
pTSBuf
,
i
d
);
int32_t
blockIndex
=
pBlockInfo
->
numOfBlocks
-
1
;
tsBufGetBlock
(
pTSBuf
,
vnode
Index
,
blockIndex
);
tsBufGetBlock
(
pTSBuf
,
group
Index
,
blockIndex
);
pCur
->
tsIndex
=
pTSBuf
->
block
.
numOfElem
-
1
;
if
(
pTSBuf
->
block
.
numOfElem
==
0
)
{
...
...
@@ -678,12 +678,12 @@ bool tsBufNextPos(STSBuf* pTSBuf) {
if
((
pCur
->
order
==
TSDB_ORDER_ASC
&&
pCur
->
tsIndex
>=
pTSBuf
->
block
.
numOfElem
-
1
)
||
(
pCur
->
order
==
TSDB_ORDER_DESC
&&
pCur
->
tsIndex
<=
0
))
{
int32_t
vnodeId
=
pTSBuf
->
pData
[
pCur
->
vgroupIndex
].
info
.
vnode
;
int32_t
id
=
pTSBuf
->
pData
[
pCur
->
vgroupIndex
].
info
.
id
;
STS
VnodeBlockInfo
*
pBlockInfo
=
tsBufGetVnodeBlockInfo
(
pTSBuf
,
vnodeI
d
);
STS
GroupBlockInfo
*
pBlockInfo
=
tsBufGetGroupBlockInfo
(
pTSBuf
,
i
d
);
if
(
pBlockInfo
==
NULL
||
(
pCur
->
blockIndex
>=
pBlockInfo
->
numOfBlocks
-
1
&&
pCur
->
order
==
TSDB_ORDER_ASC
)
||
(
pCur
->
blockIndex
<=
0
&&
pCur
->
order
==
TSDB_ORDER_DESC
))
{
if
((
pCur
->
vgroupIndex
>=
pTSBuf
->
numOf
Vnode
s
-
1
&&
pCur
->
order
==
TSDB_ORDER_ASC
)
||
if
((
pCur
->
vgroupIndex
>=
pTSBuf
->
numOf
Group
s
-
1
&&
pCur
->
order
==
TSDB_ORDER_ASC
)
||
(
pCur
->
vgroupIndex
<=
0
&&
pCur
->
order
==
TSDB_ORDER_DESC
))
{
pCur
->
vgroupIndex
=
-
1
;
return
false
;
...
...
@@ -719,7 +719,7 @@ void tsBufResetPos(STSBuf* pTSBuf) {
}
STSElem
tsBufGetElem
(
STSBuf
*
pTSBuf
)
{
STSElem
elem1
=
{.
vnode
=
-
1
};
STSElem
elem1
=
{.
id
=
-
1
};
if
(
pTSBuf
==
NULL
)
{
return
elem1
;
}
...
...
@@ -731,7 +731,7 @@ STSElem tsBufGetElem(STSBuf* pTSBuf) {
STSBlock
*
pBlock
=
&
pTSBuf
->
block
;
elem1
.
vnode
=
pTSBuf
->
pData
[
pCur
->
vgroupIndex
].
info
.
vnode
;
elem1
.
id
=
pTSBuf
->
pData
[
pCur
->
vgroupIndex
].
info
.
id
;
elem1
.
ts
=
*
(
TSKEY
*
)(
pTSBuf
->
tsData
.
rawBuf
+
pCur
->
tsIndex
*
TSDB_KEYSIZE
);
elem1
.
tag
=
&
pBlock
->
tag
;
...
...
@@ -742,34 +742,34 @@ STSElem tsBufGetElem(STSBuf* pTSBuf) {
* current only support ts comp data from two vnode merge
* @param pDestBuf
* @param pSrcBuf
* @param
vnodeI
d
* @param
i
d
* @return
*/
int32_t
tsBufMerge
(
STSBuf
*
pDestBuf
,
const
STSBuf
*
pSrcBuf
)
{
if
(
pDestBuf
==
NULL
||
pSrcBuf
==
NULL
||
pSrcBuf
->
numOf
Vnode
s
<=
0
)
{
if
(
pDestBuf
==
NULL
||
pSrcBuf
==
NULL
||
pSrcBuf
->
numOf
Group
s
<=
0
)
{
return
0
;
}
if
(
pDestBuf
->
numOf
Vnodes
+
pSrcBuf
->
numOfVnodes
>
TS_COMP_FILE_VNODE
_MAX
)
{
if
(
pDestBuf
->
numOf
Groups
+
pSrcBuf
->
numOfGroups
>
TS_COMP_FILE_GROUP
_MAX
)
{
return
-
1
;
}
// src can only have one vnode index
assert
(
pSrcBuf
->
numOf
Vnode
s
==
1
);
assert
(
pSrcBuf
->
numOf
Group
s
==
1
);
// there are data in buffer, flush to disk first
tsBufFlush
(
pDestBuf
);
// compared with the last vnode id
int32_t
vnodeId
=
tsBufGetLastVnodeInfo
((
STSBuf
*
)
pSrcBuf
)
->
info
.
vnode
;
if
(
vnodeId
!=
tsBufGetLastVnodeInfo
(
pDestBuf
)
->
info
.
vnode
)
{
int32_t
oldSize
=
pDestBuf
->
numOf
Vnode
s
;
int32_t
newSize
=
oldSize
+
pSrcBuf
->
numOf
Vnode
s
;
int32_t
id
=
tsBufGetLastGroupInfo
((
STSBuf
*
)
pSrcBuf
)
->
info
.
id
;
if
(
id
!=
tsBufGetLastGroupInfo
(
pDestBuf
)
->
info
.
id
)
{
int32_t
oldSize
=
pDestBuf
->
numOf
Group
s
;
int32_t
newSize
=
oldSize
+
pSrcBuf
->
numOf
Group
s
;
if
(
pDestBuf
->
numOfAlloc
<
newSize
)
{
pDestBuf
->
numOfAlloc
=
newSize
;
STS
VnodeBlockInfoEx
*
tmp
=
realloc
(
pDestBuf
->
pData
,
sizeof
(
STSVnode
BlockInfoEx
)
*
newSize
);
STS
GroupBlockInfoEx
*
tmp
=
realloc
(
pDestBuf
->
pData
,
sizeof
(
STSGroup
BlockInfoEx
)
*
newSize
);
if
(
tmp
==
NULL
)
{
return
-
1
;
}
...
...
@@ -778,23 +778,23 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
}
// directly copy the vnode index information
memcpy
(
&
pDestBuf
->
pData
[
oldSize
],
pSrcBuf
->
pData
,
(
size_t
)
pSrcBuf
->
numOf
Vnodes
*
sizeof
(
STSVnode
BlockInfoEx
));
memcpy
(
&
pDestBuf
->
pData
[
oldSize
],
pSrcBuf
->
pData
,
(
size_t
)
pSrcBuf
->
numOf
Groups
*
sizeof
(
STSGroup
BlockInfoEx
));
// set the new offset value
for
(
int32_t
i
=
0
;
i
<
pSrcBuf
->
numOf
Vnode
s
;
++
i
)
{
STS
Vnode
BlockInfoEx
*
pBlockInfoEx
=
&
pDestBuf
->
pData
[
i
+
oldSize
];
for
(
int32_t
i
=
0
;
i
<
pSrcBuf
->
numOf
Group
s
;
++
i
)
{
STS
Group
BlockInfoEx
*
pBlockInfoEx
=
&
pDestBuf
->
pData
[
i
+
oldSize
];
pBlockInfoEx
->
info
.
offset
=
(
pSrcBuf
->
pData
[
i
].
info
.
offset
-
getDataStartOffset
())
+
pDestBuf
->
fileSize
;
pBlockInfoEx
->
info
.
vnode
=
vnodeI
d
;
pBlockInfoEx
->
info
.
id
=
i
d
;
}
pDestBuf
->
numOf
Vnode
s
=
newSize
;
pDestBuf
->
numOf
Group
s
=
newSize
;
}
else
{
STS
VnodeBlockInfoEx
*
pBlockInfoEx
=
tsBufGetLastVnode
Info
(
pDestBuf
);
STS
GroupBlockInfoEx
*
pBlockInfoEx
=
tsBufGetLastGroup
Info
(
pDestBuf
);
pBlockInfoEx
->
len
+=
pSrcBuf
->
pData
[
0
].
len
;
pBlockInfoEx
->
info
.
numOfBlocks
+=
pSrcBuf
->
pData
[
0
].
info
.
numOfBlocks
;
pBlockInfoEx
->
info
.
compLen
+=
pSrcBuf
->
pData
[
0
].
info
.
compLen
;
pBlockInfoEx
->
info
.
vnode
=
vnodeI
d
;
pBlockInfoEx
->
info
.
id
=
i
d
;
}
int32_t
r
=
fseek
(
pDestBuf
->
f
,
0
,
SEEK_END
);
...
...
@@ -827,23 +827,23 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) {
assert
(
pDestBuf
->
fileSize
==
oldSize
+
size
);
// tscDebug("tsBuf merge success, %p, path:%s, fd:%d, file size:%d, numOf
Vnode
:%d, autoDelete:%d", pDestBuf,
// pDestBuf->path, fileno(pDestBuf->f), pDestBuf->fileSize, pDestBuf->numOf
Vnode
s, pDestBuf->autoDelete);
// tscDebug("tsBuf merge success, %p, path:%s, fd:%d, file size:%d, numOf
Groups
:%d, autoDelete:%d", pDestBuf,
// pDestBuf->path, fileno(pDestBuf->f), pDestBuf->fileSize, pDestBuf->numOf
Group
s, pDestBuf->autoDelete);
return
0
;
}
STSBuf
*
tsBufCreateFromCompBlocks
(
const
char
*
pData
,
int32_t
numOfBlocks
,
int32_t
len
,
int32_t
order
,
int32_t
vnodeI
d
)
{
STSBuf
*
tsBufCreateFromCompBlocks
(
const
char
*
pData
,
int32_t
numOfBlocks
,
int32_t
len
,
int32_t
order
,
int32_t
i
d
)
{
STSBuf
*
pTSBuf
=
tsBufCreate
(
true
,
order
);
STS
VnodeBlockInfo
*
pBlockInfo
=
&
(
addOneVnode
Info
(
pTSBuf
,
0
)
->
info
);
STS
GroupBlockInfo
*
pBlockInfo
=
&
(
addOneGroup
Info
(
pTSBuf
,
0
)
->
info
);
pBlockInfo
->
numOfBlocks
=
numOfBlocks
;
pBlockInfo
->
compLen
=
len
;
pBlockInfo
->
offset
=
getDataStartOffset
();
pBlockInfo
->
vnode
=
vnodeI
d
;
pBlockInfo
->
id
=
i
d
;
// update prev vnode length info in file
TSBufUpdate
VnodeInfo
(
pTSBuf
,
pTSBuf
->
numOfVnode
s
-
1
,
pBlockInfo
);
TSBufUpdate
GroupInfo
(
pTSBuf
,
pTSBuf
->
numOfGroup
s
-
1
,
pBlockInfo
);
int32_t
ret
=
fseek
(
pTSBuf
->
f
,
pBlockInfo
->
offset
,
SEEK_SET
);
UNUSED
(
ret
);
...
...
@@ -855,7 +855,7 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
assert
(
order
==
TSDB_ORDER_ASC
||
order
==
TSDB_ORDER_DESC
);
STSBufFileHeader
header
=
{
.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Vnode
=
pTSBuf
->
numOfVnode
s
,
.
tsOrder
=
pTSBuf
->
tsOrder
};
.
magic
=
TS_COMP_FILE_MAGIC
,
.
numOf
Group
=
pTSBuf
->
numOfGroup
s
,
.
tsOrder
=
pTSBuf
->
tsOrder
};
STSBufUpdateHeader
(
pTSBuf
,
&
header
);
fsync
(
fileno
(
pTSBuf
->
f
));
...
...
@@ -863,14 +863,14 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
return
pTSBuf
;
}
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
vnodeI
d
,
tVariant
*
tag
)
{
STSElem
elem
=
{.
vnode
=
-
1
};
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
i
d
,
tVariant
*
tag
)
{
STSElem
elem
=
{.
id
=
-
1
};
if
(
pTSBuf
==
NULL
)
{
return
elem
;
}
int32_t
j
=
tsBufFind
VnodeById
(
pTSBuf
->
pData
,
pTSBuf
->
numOfVnodes
,
vnodeI
d
);
int32_t
j
=
tsBufFind
GroupById
(
pTSBuf
->
pData
,
pTSBuf
->
numOfGroups
,
i
d
);
if
(
j
==
-
1
)
{
return
elem
;
}
...
...
@@ -879,7 +879,7 @@ STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t vnodeId, tVariant* tag) {
// tsBufDisplay(pTSBuf);
STSCursor
*
pCur
=
&
pTSBuf
->
cur
;
STS
Vnode
BlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
j
].
info
;
STS
Group
BlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
j
].
info
;
int32_t
blockIndex
=
tsBufFindBlockByTag
(
pTSBuf
,
pBlockInfo
,
tag
);
if
(
blockIndex
<
0
)
{
...
...
@@ -935,7 +935,7 @@ STSBuf* tsBufClone(STSBuf* pTSBuf) {
void
tsBufDisplay
(
STSBuf
*
pTSBuf
)
{
printf
(
"-------start of ts comp file-------
\n
"
);
printf
(
"number of vnode:%d
\n
"
,
pTSBuf
->
numOf
Vnode
s
);
printf
(
"number of vnode:%d
\n
"
,
pTSBuf
->
numOf
Group
s
);
int32_t
old
=
pTSBuf
->
cur
.
order
;
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
...
...
@@ -945,7 +945,7 @@ void tsBufDisplay(STSBuf* pTSBuf) {
while
(
tsBufNextPos
(
pTSBuf
))
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
if
(
elem
.
tag
->
nType
==
TSDB_DATA_TYPE_BIGINT
)
{
printf
(
"%d-%"
PRId64
"-%"
PRId64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
printf
(
"%d-%"
PRId64
"-%"
PRId64
"
\n
"
,
elem
.
id
,
elem
.
tag
->
i64Key
,
elem
.
ts
);
}
}
...
...
@@ -954,20 +954,20 @@ void tsBufDisplay(STSBuf* pTSBuf) {
}
static
int32_t
getDataStartOffset
()
{
return
sizeof
(
STSBufFileHeader
)
+
TS_COMP_FILE_
VNODE_MAX
*
sizeof
(
STSVnode
BlockInfo
);
return
sizeof
(
STSBufFileHeader
)
+
TS_COMP_FILE_
GROUP_MAX
*
sizeof
(
STSGroup
BlockInfo
);
}
// update prev vnode length info in file
static
void
TSBufUpdate
VnodeInfo
(
STSBuf
*
pTSBuf
,
int32_t
index
,
STSVnode
BlockInfo
*
pBlockInfo
)
{
int32_t
offset
=
sizeof
(
STSBufFileHeader
)
+
index
*
sizeof
(
STS
Vnode
BlockInfo
);
doUpdate
Vnode
Info
(
pTSBuf
,
offset
,
pBlockInfo
);
static
void
TSBufUpdate
GroupInfo
(
STSBuf
*
pTSBuf
,
int32_t
index
,
STSGroup
BlockInfo
*
pBlockInfo
)
{
int32_t
offset
=
sizeof
(
STSBufFileHeader
)
+
index
*
sizeof
(
STS
Group
BlockInfo
);
doUpdate
Group
Info
(
pTSBuf
,
offset
,
pBlockInfo
);
}
static
STSBuf
*
allocResForTSBuf
(
STSBuf
*
pTSBuf
)
{
const
int32_t
INITIAL_
VNODE
INFO_SIZE
=
4
;
const
int32_t
INITIAL_
GROUP
INFO_SIZE
=
4
;
pTSBuf
->
numOfAlloc
=
INITIAL_
VNODE
INFO_SIZE
;
pTSBuf
->
pData
=
calloc
(
pTSBuf
->
numOfAlloc
,
sizeof
(
STS
Vnode
BlockInfoEx
));
pTSBuf
->
numOfAlloc
=
INITIAL_
GROUP
INFO_SIZE
;
pTSBuf
->
pData
=
calloc
(
pTSBuf
->
numOfAlloc
,
sizeof
(
STS
Group
BlockInfoEx
));
if
(
pTSBuf
->
pData
==
NULL
)
{
tsBufDestroy
(
pTSBuf
);
return
NULL
;
...
...
@@ -999,35 +999,35 @@ static STSBuf* allocResForTSBuf(STSBuf* pTSBuf) {
return
pTSBuf
;
}
int32_t
tsBufGetNumOf
Vnodes
(
STSBuf
*
pTSBuf
)
{
int32_t
tsBufGetNumOf
Group
(
STSBuf
*
pTSBuf
)
{
if
(
pTSBuf
==
NULL
)
{
return
0
;
}
return
pTSBuf
->
numOf
Vnode
s
;
return
pTSBuf
->
numOf
Group
s
;
}
void
tsBufGet
VnodeIdList
(
STSBuf
*
pTSBuf
,
int32_t
*
num
,
int32_t
**
vnodeI
d
)
{
int32_t
size
=
tsBufGetNumOf
Vnodes
(
pTSBuf
);
void
tsBufGet
GroupIdList
(
STSBuf
*
pTSBuf
,
int32_t
*
num
,
int32_t
**
i
d
)
{
int32_t
size
=
tsBufGetNumOf
Group
(
pTSBuf
);
if
(
num
!=
NULL
)
{
*
num
=
size
;
}
*
vnodeI
d
=
NULL
;
*
i
d
=
NULL
;
if
(
size
==
0
)
{
return
;
}
(
*
vnodeId
)
=
malloc
(
tsBufGetNumOfVnodes
(
pTSBuf
)
*
sizeof
(
int32_t
));
(
*
id
)
=
malloc
(
tsBufGetNumOfGroup
(
pTSBuf
)
*
sizeof
(
int32_t
));
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
(
*
vnodeId
)[
i
]
=
pTSBuf
->
pData
[
i
].
info
.
vnode
;
(
*
id
)[
i
]
=
pTSBuf
->
pData
[
i
].
info
.
id
;
}
}
int32_t
dumpFileBlockBy
VnodeId
(
STSBuf
*
pTSBuf
,
int32_t
vnode
Index
,
void
*
buf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
)
{
assert
(
vnodeIndex
>=
0
&&
vnodeIndex
<
pTSBuf
->
numOfVnode
s
);
STS
VnodeBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
vnode
Index
].
info
;
int32_t
dumpFileBlockBy
GroupId
(
STSBuf
*
pTSBuf
,
int32_t
group
Index
,
void
*
buf
,
int32_t
*
len
,
int32_t
*
numOfBlocks
)
{
assert
(
groupIndex
>=
0
&&
groupIndex
<
pTSBuf
->
numOfGroup
s
);
STS
GroupBlockInfo
*
pBlockInfo
=
&
pTSBuf
->
pData
[
group
Index
].
info
;
*
len
=
0
;
*
numOfBlocks
=
0
;
...
...
@@ -1052,11 +1052,11 @@ int32_t dumpFileBlockByVnodeId(STSBuf* pTSBuf, int32_t vnodeIndex, void* buf, in
}
STSElem
tsBufFindElemStartPosByTag
(
STSBuf
*
pTSBuf
,
tVariant
*
pTag
)
{
STSElem
el
=
{.
vnode
=
-
1
};
STSElem
el
=
{.
id
=
-
1
};
for
(
int32_t
i
=
0
;
i
<
pTSBuf
->
numOf
Vnode
s
;
++
i
)
{
el
=
tsBufGetElemStartPos
(
pTSBuf
,
pTSBuf
->
pData
[
i
].
info
.
vnode
,
pTag
);
if
(
el
.
vnode
==
pTSBuf
->
pData
[
i
].
info
.
vnode
)
{
for
(
int32_t
i
=
0
;
i
<
pTSBuf
->
numOf
Group
s
;
++
i
)
{
el
=
tsBufGetElemStartPos
(
pTSBuf
,
pTSBuf
->
pData
[
i
].
info
.
id
,
pTag
);
if
(
el
.
id
==
pTSBuf
->
pData
[
i
].
info
.
id
)
{
return
el
;
}
}
...
...
@@ -1065,5 +1065,5 @@ STSElem tsBufFindElemStartPosByTag(STSBuf* pTSBuf, tVariant* pTag) {
}
bool
tsBufIsValidElem
(
STSElem
*
pElem
)
{
return
pElem
->
vnode
>=
0
;
return
pElem
->
id
>=
0
;
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录