Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
电商架构修炼
TDengine
提交
7ee01d6d
TDengine
项目概览
电商架构修炼
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7ee01d6d
编写于
1月 23, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225]refactor.
上级
9dc0bf6c
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
88 addition
and
225 deletion
+88
-225
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+3
-3
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+7
-7
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-1
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+1
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-2
src/common/inc/texpr.h
src/common/inc/texpr.h
+23
-15
src/common/inc/tname.h
src/common/inc/tname.h
+15
-0
src/common/src/texpr.c
src/common/src/texpr.c
+11
-12
src/query/inc/qAggMain.h
src/query/inc/qAggMain.h
+3
-7
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-1
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+6
-6
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+4
-3
src/query/src/qExtbuffer.c
src/query/src/qExtbuffer.c
+2
-2
src/query/src/qFill.c
src/query/src/qFill.c
+1
-1
src/query/tests/astTest.cpp
src/query/tests/astTest.cpp
+1
-1
src/query/tests/patternMatchTest.cpp
src/query/tests/patternMatchTest.cpp
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+5
-161
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
7ee01d6d
...
...
@@ -22,15 +22,15 @@ extern "C" {
#include "os.h"
#include "qAggMain.h"
#include "taos.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tglobal.h"
#include "tsqlfunction.h"
#include "tutil.h"
#include "tcache.h"
#include "tglobal.h"
#include "tref.h"
#include "tutil.h"
#include "qExecutor.h"
#include "qSqlparser.h"
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
7ee01d6d
...
...
@@ -16,7 +16,7 @@
#include "tscLocalMerge.h"
#include "tscSubquery.h"
#include "os.h"
#include "
qAst
.h"
#include "
texpr
.h"
#include "tlosertree.h"
#include "tscLog.h"
#include "tscUtil.h"
...
...
src/client/src/tscSQLParser.c
浏览文件 @
7ee01d6d
...
...
@@ -20,7 +20,7 @@
#include "os.h"
#include "ttype.h"
#include "
qAst
.h"
#include "
texpr
.h"
#include "taos.h"
#include "taosmsg.h"
#include "tcompare.h"
...
...
@@ -1354,7 +1354,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pNode
,
pItem
->
pNode
,
pQueryInfo
,
colList
,
NULL
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
taosArrayDestroy
(
colList
);
tExprTreeDestroy
(
&
pNode
,
NULL
);
tExprTreeDestroy
(
pNode
,
NULL
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
...
...
@@ -1363,9 +1363,9 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
for
(
int32_t
k
=
0
;
k
<
numOfNode
;
++
k
)
{
SColIndex
*
pIndex
=
taosArrayGet
(
colList
,
k
);
if
(
TSDB_COL_IS_TAG
(
pIndex
->
flag
))
{
tExprTreeDestroy
(
&
pNode
,
NULL
);
tExprTreeDestroy
(
pNode
,
NULL
);
taosArrayDestroy
(
colList
);
tExprTreeDestroy
(
&
pNode
,
NULL
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
...
...
@@ -1392,7 +1392,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
tbufCloseWriter
(
&
bw
);
taosArrayDestroy
(
colList
);
tExprTreeDestroy
(
&
pNode
,
NULL
);
tExprTreeDestroy
(
pNode
,
NULL
);
}
else
{
columnList
.
num
=
0
;
columnList
.
ids
[
0
]
=
(
SColumnIndex
)
{
0
,
0
};
...
...
@@ -1424,7 +1424,7 @@ static int32_t handleArithmeticExpr(SSqlCmd* pCmd, int32_t clauseIndex, int32_t
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pArithExprInfo
->
pExpr
,
pItem
->
pNode
,
pQueryInfo
,
NULL
,
&
pArithExprInfo
->
uid
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tExprTreeDestroy
(
&
pArithExprInfo
->
pExpr
,
NULL
);
tExprTreeDestroy
(
pArithExprInfo
->
pExpr
,
NULL
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"invalid expression in select clause"
);
}
...
...
@@ -4304,7 +4304,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
doCompactQueryExpr
(
pExpr
);
tSqlExprDestroy
(
p1
);
tExprTreeDestroy
(
&
p
,
NULL
);
tExprTreeDestroy
(
p
,
NULL
);
taosArrayDestroy
(
colList
);
if
(
pQueryInfo
->
tagCond
.
pCond
!=
NULL
&&
taosArrayGetSize
(
pQueryInfo
->
tagCond
.
pCond
)
>
0
&&
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
...
...
src/client/src/tscSql.c
浏览文件 @
7ee01d6d
...
...
@@ -15,7 +15,7 @@
#include "hash.h"
#include "os.h"
#include "
qAst
.h"
#include "
texpr
.h"
#include "tkey.h"
#include "tcache.h"
#include "tnote.h"
...
...
src/client/src/tscSubquery.c
浏览文件 @
7ee01d6d
...
...
@@ -16,7 +16,7 @@
#include "os.h"
#include "
qAst
.h"
#include "
texpr
.h"
#include "qTsbuf.h"
#include "tcompare.h"
#include "tscLog.h"
...
...
src/client/src/tscUtil.c
浏览文件 @
7ee01d6d
...
...
@@ -16,7 +16,7 @@
#include "tscUtil.h"
#include "hash.h"
#include "os.h"
#include "
qAst
.h"
#include "
texpr
.h"
#include "taosmsg.h"
#include "tkey.h"
#include "tmd5.h"
...
...
@@ -1054,7 +1054,7 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
SInternalField
*
pInfo
=
taosArrayGet
(
pFieldInfo
->
internalField
,
i
);
if
(
pInfo
->
pArithExprInfo
!=
NULL
)
{
tExprTreeDestroy
(
&
pInfo
->
pArithExprInfo
->
pExpr
,
NULL
);
tExprTreeDestroy
(
pInfo
->
pArithExprInfo
->
pExpr
,
NULL
);
SSqlFuncMsg
*
pFuncMsg
=
&
pInfo
->
pArithExprInfo
->
base
;
for
(
int32_t
j
=
0
;
j
<
pFuncMsg
->
numOfParams
;
++
j
)
{
...
...
src/
query/inc/qAst
.h
→
src/
common/inc/texpr
.h
浏览文件 @
7ee01d6d
...
...
@@ -31,6 +31,15 @@ extern "C" {
struct
tExprNode
;
struct
SSchema
;
#define QUERY_COND_REL_PREFIX_IN "IN|"
#define QUERY_COND_REL_PREFIX_LIKE "LIKE|"
#define QUERY_COND_REL_PREFIX_IN_LEN 3
#define QUERY_COND_REL_PREFIX_LIKE_LEN 5
typedef
bool
(
*
__result_filter_fn_t
)(
const
void
*
,
void
*
);
typedef
void
(
*
__do_filter_suppl_fn_t
)(
void
*
,
void
*
);
enum
{
TSQL_NODE_DUMMY
=
0x0
,
TSQL_NODE_EXPR
=
0x1
,
...
...
@@ -38,9 +47,6 @@ enum {
TSQL_NODE_VALUE
=
0x4
,
};
typedef
bool
(
*
__result_filter_fn_t
)(
const
void
*
,
void
*
);
typedef
void
(
*
__do_filter_suppl_fn_t
)(
void
*
,
void
*
);
/**
* this structure is used to filter data in tags, so the offset of filtered tag column in tagdata string is required
*/
...
...
@@ -52,12 +58,6 @@ typedef struct tQueryInfo {
bool
indexed
;
// indexed columns
}
tQueryInfo
;
typedef
struct
SExprTraverseSupp
{
__result_filter_fn_t
nodeFilterFn
;
__do_filter_suppl_fn_t
setupInfoFn
;
void
*
pExtInfo
;
}
SExprTraverseSupp
;
typedef
struct
tExprNode
{
uint8_t
nodeType
;
union
{
...
...
@@ -74,19 +74,27 @@ typedef struct tExprNode {
};
}
tExprNode
;
void
arithmeticTreeTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
cb
)(
void
*
,
const
char
*
,
int32_t
));
typedef
struct
SExprTraverseSupp
{
__result_filter_fn_t
nodeFilterFn
;
__do_filter_suppl_fn_t
setupInfoFn
;
void
*
pExtInfo
;
}
SExprTraverseSupp
;
void
tExprTreeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
tExprNode
*
exprTreeFromBinary
(
const
void
*
data
,
size_t
size
);
tExprNode
*
exprTreeFromTableName
(
const
char
*
tbnameCond
);
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
tExprTreeDestroy
(
tExprNode
**
pExprs
,
void
(
*
fp
)(
void
*
));
bool
exprTreeApplayFilter
(
tExprNode
*
pExpr
,
const
void
*
pItem
,
SExprTraverseSupp
*
param
);
typedef
void
(
*
_arithmetic_operator_fn_t
)(
void
*
left
,
int32_t
numLeft
,
int32_t
leftType
,
void
*
right
,
int32_t
numRight
,
int32_t
rightType
,
void
*
output
,
int32_t
order
);
void
arithmeticTreeTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
cb
)(
void
*
,
const
char
*
,
int32_t
));
#ifdef __cplusplus
}
#endif
...
...
src/common/inc/tname.h
浏览文件 @
7ee01d6d
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_NAME_H
#define TDENGINE_NAME_H
...
...
src/
query/src/qAst
.c
→
src/
common/src/texpr
.c
浏览文件 @
7ee01d6d
...
...
@@ -16,18 +16,15 @@
#include "os.h"
#include "exception.h"
#include "qArithmeticOperator.h"
#include "qAst.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tarray.h"
#include "tbuffer.h"
#include "tcompare.h"
#include "tname.h"
#include "tschemautil.h"
#include "tsdb.h"
#include "tskiplist.h"
#include "tsqlfunction.h"
#include "texpr.h"
static
uint8_t
UNUSED_FUNC
isQueryOnPrimaryKey
(
const
char
*
primaryColumnName
,
const
tExprNode
*
pLeft
,
const
tExprNode
*
pRight
)
{
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
...
...
@@ -102,13 +99,15 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf
}
}
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
))
{
static
void
doExprTreeDestroy
(
tExprNode
**
pExpr
,
void
(
*
fp
)(
void
*
));
void
tExprTreeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
))
{
if
(
pNode
==
NULL
)
{
return
;
}
if
(
pNode
->
nodeType
==
TSQL_NODE_EXPR
)
{
t
ExprTreeDestroy
(
&
pNode
,
fp
);
do
ExprTreeDestroy
(
&
pNode
,
fp
);
}
else
if
(
pNode
->
nodeType
==
TSQL_NODE_VALUE
)
{
tVariantDestroy
(
pNode
->
pVal
);
}
else
if
(
pNode
->
nodeType
==
TSQL_NODE_COL
)
{
...
...
@@ -118,14 +117,14 @@ void tExprNodeDestroy(tExprNode *pNode, void (*fp)(void *)) {
free
(
pNode
);
}
void
t
ExprTreeDestroy
(
tExprNode
**
pExpr
,
void
(
*
fp
)(
void
*
))
{
static
void
do
ExprTreeDestroy
(
tExprNode
**
pExpr
,
void
(
*
fp
)(
void
*
))
{
if
(
*
pExpr
==
NULL
)
{
return
;
}
if
((
*
pExpr
)
->
nodeType
==
TSQL_NODE_EXPR
)
{
t
ExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pLeft
,
fp
);
t
ExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pRight
,
fp
);
do
ExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pLeft
,
fp
);
do
ExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pRight
,
fp
);
if
(
fp
!=
NULL
)
{
fp
((
*
pExpr
)
->
_node
.
info
);
...
...
@@ -342,7 +341,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) {
}
tExprNode
*
pExpr
=
exception_calloc
(
1
,
sizeof
(
tExprNode
));
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Nod
eDestroy
,
pExpr
,
NULL
);
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Tre
eDestroy
,
pExpr
,
NULL
);
pExpr
->
nodeType
=
tbufReadUint8
(
br
);
if
(
pExpr
->
nodeType
==
TSQL_NODE_VALUE
)
{
...
...
@@ -396,7 +395,7 @@ tExprNode* exprTreeFromTableName(const char* tbnameCond) {
int32_t
anchor
=
CLEANUP_GET_ANCHOR
();
tExprNode
*
expr
=
exception_calloc
(
1
,
sizeof
(
tExprNode
));
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Nod
eDestroy
,
expr
,
NULL
);
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Tre
eDestroy
,
expr
,
NULL
);
expr
->
nodeType
=
TSQL_NODE_EXPR
;
...
...
src/query/inc/
tsqlfunctio
n.h
→
src/query/inc/
qAggMai
n.h
浏览文件 @
7ee01d6d
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
TSQLFUNCTIO
N_H
#define TDENGINE_
TSQLFUNCTIO
N_H
#ifndef TDENGINE_
QAGGMAI
N_H
#define TDENGINE_
QAGGMAI
N_H
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -97,11 +97,7 @@ extern "C" {
#define DATA_SET_FLAG ',' // to denote the output area has data, not null value
#define DATA_SET_FLAG_SIZE sizeof(DATA_SET_FLAG)
#define QUERY_COND_REL_PREFIX_IN "IN|"
#define QUERY_COND_REL_PREFIX_LIKE "LIKE|"
#define QUERY_COND_REL_PREFIX_IN_LEN 3
#define QUERY_COND_REL_PREFIX_LIKE_LEN 5
#define QUERY_ASC_FORWARD_STEP 1
#define QUERY_DESC_FORWARD_STEP -1
...
...
@@ -279,4 +275,4 @@ static FORCE_INLINE void initResultInfo(SResultRowCellInfo *pResInfo, uint32_t b
}
#endif
#endif // TDENGINE_
TSQLFUNCTIO
N_H
#endif // TDENGINE_
QAGGMAI
N_H
src/query/inc/qExecutor.h
浏览文件 @
7ee01d6d
...
...
@@ -18,6 +18,7 @@
#include "os.h"
#include "hash.h"
#include "qAggMain.h"
#include "qFill.h"
#include "qResultbuf.h"
#include "qSqlparser.h"
...
...
@@ -27,7 +28,6 @@
#include "tarray.h"
#include "tlockfree.h"
#include "tsdb.h"
#include "tsqlfunction.h"
struct
SColumnFilterElem
;
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
const
char
*
val1
,
const
char
*
val2
,
int16_t
type
);
...
...
src/query/src/qAggMain.c
浏览文件 @
7ee01d6d
...
...
@@ -14,17 +14,17 @@
*/
#include "os.h"
#include "qAst.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "texpr.h"
#include "ttype.h"
#include "qAggMain.h"
#include "qFill.h"
#include "qHistogram.h"
#include "qPercentile.h"
#include "qTsbuf.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "queryLog.h"
#include "tscSubquery.h"
#include "tsqlfunction.h"
#include "ttype.h"
#define GET_INPUT_DATA_LIST(x) (((char *)((x)->aInputElemBuf)) + ((x)->startOffset) * ((x)->inputBytes))
#define GET_INPUT_DATA(x, y) (GET_INPUT_DATA_LIST(x) + (y) * (x)->inputBytes)
...
...
src/query/src/qExecutor.c
浏览文件 @
7ee01d6d
...
...
@@ -20,7 +20,7 @@
#include "exception.h"
#include "hash.h"
#include "
qAst
.h"
#include "
texpr
.h"
#include "qExecutor.h"
#include "qResultbuf.h"
#include "qUtil.h"
...
...
@@ -6798,7 +6798,8 @@ _cleanup_query:
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SExprInfo
*
pExprInfo
=
&
pExprs
[
i
];
if
(
pExprInfo
->
pExpr
!=
NULL
)
{
tExprTreeDestroy
(
&
pExprInfo
->
pExpr
,
NULL
);
tExprTreeDestroy
(
pExprInfo
->
pExpr
,
NULL
);
pExprInfo
->
pExpr
=
NULL
;
}
}
...
...
@@ -6914,7 +6915,7 @@ static void* destroyQueryFuncExpr(SExprInfo* pExprInfo, int32_t numOfExpr) {
for
(
int32_t
i
=
0
;
i
<
numOfExpr
;
++
i
)
{
if
(
pExprInfo
[
i
].
pExpr
!=
NULL
)
{
tExpr
Nod
eDestroy
(
pExprInfo
[
i
].
pExpr
,
NULL
);
tExpr
Tre
eDestroy
(
pExprInfo
[
i
].
pExpr
,
NULL
);
}
}
...
...
src/query/src/qExtbuffer.c
浏览文件 @
7ee01d6d
...
...
@@ -12,13 +12,13 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "qExtbuffer.h"
#include "os.h"
#include "qAggMain.h"
#include "queryLog.h"
#include "taos.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tsqlfunction.h"
#include "tulog.h"
#define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \
...
...
src/query/src/qFill.c
浏览文件 @
7ee01d6d
...
...
@@ -15,9 +15,9 @@
#include "os.h"
#include "qAggMain.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tsqlfunction.h"
#include "ttype.h"
#include "qFill.h"
...
...
src/query/tests/astTest.cpp
浏览文件 @
7ee01d6d
...
...
@@ -3,7 +3,7 @@
#include <cassert>
#include <iostream>
#include "
qAst
.h"
#include "
texpr
.h"
#include "taosmsg.h"
#include "tsdb.h"
#include "tskiplist.h"
...
...
src/query/tests/patternMatchTest.cpp
浏览文件 @
7ee01d6d
...
...
@@ -3,7 +3,7 @@
#include <cassert>
#include <iostream>
#include "
tsqlfunctio
n.h"
#include "
qAggMai
n.h"
#include "tcompare.h"
TEST
(
testCase
,
patternMatchTest
)
{
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
7ee01d6d
...
...
@@ -19,10 +19,10 @@
#include "tcompare.h"
#include "exception.h"
#include "../../query/inc/qAst.h" // todo move to common module
#include "tlosertree.h"
#include "tsdb.h"
#include "tsdbMain.h"
#include "texpr.h"
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
...
@@ -1920,7 +1920,6 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) {
static
void
changeQueryHandleForInterpQuery
(
TsdbQueryHandleT
pHandle
)
{
// filter the queried time stamp in the first place
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
pHandle
;
// pQueryHandle->order = TSDB_ORDER_DESC;
// starts from the buffer in case of descending timestamp order check data blocks
size_t
numOfTables
=
taosArrayGetSize
(
pQueryHandle
->
pTableCheckInfo
);
...
...
@@ -1948,9 +1947,6 @@ static void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) {
info
.
lastKey
=
pQueryHandle
->
window
.
skey
;
taosArrayPush
(
pQueryHandle
->
pTableCheckInfo
,
&
info
);
// update the query time window according to the chosen last timestamp
// pQueryHandle->window = (STimeWindow) {info.lastKey, TSKEY_INITIAL_VAL};
}
static
int
tsdbReadRowsFromCache
(
STableCheckInfo
*
pCheckInfo
,
TSKEY
maxKey
,
int
maxRowsToRead
,
STimeWindow
*
win
,
...
...
@@ -2030,7 +2026,6 @@ static void destroyHelper(void* param) {
return
;
}
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
if
(
pInfo
->
optr
!=
TSDB_RELATION_IN
)
{
tfree
(
pInfo
->
q
);
...
...
@@ -2039,148 +2034,6 @@ static void destroyHelper(void* param) {
free
(
param
);
}
//static bool getNeighborRows(STsdbQueryHandle* pQueryHandle) {
// assert(pQueryHandle->type == TSDB_QUERY_TYPE_EXTERNAL);
//
// SDataBlockInfo blockInfo = {{0}, 0};
//
// pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
// pQueryHandle->order = TSDB_ORDER_DESC;
//
// if (!tsdbNextDataBlock((void*)pQueryHandle)) {
// return false;
// }
//
// tsdbRetrieveDataBlockInfo((void*)pQueryHandle, &blockInfo);
// /*SArray *pDataBlock = */ tsdbRetrieveDataBlock((void*)pQueryHandle, pQueryHandle->defaultLoadColumn);
// if (terrno != TSDB_CODE_SUCCESS) {
// return false;
// }
//
// STimeWindow* win = &pQueryHandle->window;
//
// // the skey == ekey means only one data row is required.
// // the data row of this timestamp is already retrieved, discard other data rows and return.
// if (win->skey == win->ekey) {
// if (pQueryHandle->cur.win.ekey == win->skey) {
// int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle));
// for (int32_t i = 0; i < numOfCols; ++i) {
// SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
// memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1),
// pCol->info.bytes);
// }
//
// pQueryHandle->cur.win = (STimeWindow){win->skey, win->skey};
// pQueryHandle->window = pQueryHandle->cur.win;
// pQueryHandle->cur.rows = 1;
// pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
// return true;
// } else {
// STimeWindow win1 = (STimeWindow){pQueryHandle->window.skey, INT64_MAX};
// STsdbQueryCond cond = {.order = TSDB_ORDER_ASC, .numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle))};
//
// cond.twindow = win1;
//
// cond.colList = calloc(cond.numOfCols, sizeof(SColumnInfo));
// if (cond.colList == NULL) {
// terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
// return false;
// }
//
// for (int32_t i = 0; i < cond.numOfCols; ++i) {
// SColumnInfoData* pColInfoData = taosArrayGet(pQueryHandle->pColumns, i);
// memcpy(&cond.colList[i], &pColInfoData->info, sizeof(SColumnInfo));
// }
//
// STsdbQueryHandle* pSecQueryHandle =
// tsdbQueryTablesImpl(pQueryHandle->pTsdb, &cond, pQueryHandle->qinfo, pQueryHandle->pMemRef);
//
// tfree(cond.colList);
//
// pSecQueryHandle->pTableCheckInfo =
// createCheckInfoFromCheckInfo(pQueryHandle->pTableCheckInfo, pSecQueryHandle->window.skey);
// if (pSecQueryHandle->pTableCheckInfo == NULL) {
// tsdbCleanupQueryHandle(pSecQueryHandle);
// return false;
// }
//
// if (!tsdbNextDataBlock((void*)pSecQueryHandle)) {
// tsdbCleanupQueryHandle(pSecQueryHandle);
// return false;
// }
//
// tsdbRetrieveDataBlockInfo((void*)pSecQueryHandle, &blockInfo);
// tsdbRetrieveDataBlock((void*)pSecQueryHandle, pSecQueryHandle->defaultLoadColumn);
//
// int32_t numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pSecQueryHandle));
// size_t si = taosArrayGetSize(pSecQueryHandle->pTableCheckInfo);
//
// for (int32_t i = 0; i < numOfCols; ++i) {
// SColumnInfoData* pCol = taosArrayGet(pQueryHandle->pColumns, i);
// memcpy((char*)pCol->pData, (char*)pCol->pData + pCol->info.bytes * (pQueryHandle->cur.rows - 1),
// pCol->info.bytes);
//
// SColumnInfoData* pCol1 = taosArrayGet(pSecQueryHandle->pColumns, i);
// assert(pCol->info.colId == pCol1->info.colId);
//
// memcpy((char*)pCol->pData + pCol->info.bytes, pCol1->pData, pCol1->info.bytes);
// }
//
// SColumnInfoData* pTSCol = taosArrayGet(pQueryHandle->pColumns, 0);
//
// // it is ascending order
// pQueryHandle->order = TSDB_ORDER_DESC;
// pQueryHandle->window = pQueryHandle->cur.win;
// pQueryHandle->cur.win = (STimeWindow){((TSKEY*)pTSCol->pData)[0], ((TSKEY*)pTSCol->pData)[1]};
// pQueryHandle->cur.rows = 2;
// pQueryHandle->cur.mixBlock = true;
//
// int32_t step = -1; // one step for ascending order traverse
// for (int32_t j = 0; j < si; ++j) {
// STableCheckInfo* pCheckInfo = (STableCheckInfo*)taosArrayGet(pQueryHandle->pTableCheckInfo, j);
// pCheckInfo->lastKey = pQueryHandle->cur.win.ekey + step;
// }
//
// tsdbCleanupQueryHandle(pSecQueryHandle);
// }
// } else { // go back to normal query
// if (pQueryHandle->cur.win.ekey == win->skey) {
// pQueryHandle->type = TSDB_QUERY_TYPE_ALL;
//
// STsdbQueryCond cond = {.order = TSDB_ORDER_ASC, .numOfCols = (int32_t)(QH_GET_NUM_OF_COLS(pQueryHandle))};
//
// cond.twindow = pQueryHandle->oriWindow;;
//
// cond.colList = calloc(cond.numOfCols, sizeof(SColumnInfo));
// if (cond.colList == NULL) {
// terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
// return false;
// }
//
// STsdbQueryHandle* pSecQueryHandle =
// tsdbQueryTablesImpl(pQueryHandle->pTsdb, &cond, pQueryHandle->qinfo, pQueryHandle->pMemRef);
//
// tfree(cond.colList);
//
// pSecQueryHandle->pTableCheckInfo =
// createCheckInfoFromCheckInfo(pQueryHandle->pTableCheckInfo, pSecQueryHandle->window.skey);
// if (pSecQueryHandle->pTableCheckInfo == NULL) {
// tsdbCleanupQueryHandle(pSecQueryHandle);
// return false;
// }
//
// return true;
// } else {
// // save the pre rows for interpolation query.
// }
// }
//
// // disable it after retrieve data
// pQueryHandle->type = TSDB_QUERY_TYPE_EXTERNAL;
// pQueryHandle->checkFiles = false;
// return true;
//}
// handle data in cache situation
bool
tsdbNextDataBlock
(
TsdbQueryHandleT
*
pHandle
)
{
STsdbQueryHandle
*
pQueryHandle
=
(
STsdbQueryHandle
*
)
pHandle
;
...
...
@@ -2191,16 +2044,7 @@ bool tsdbNextDataBlock(TsdbQueryHandleT* pHandle) {
size_t
numOfTables
=
taosArrayGetSize
(
pQueryHandle
->
pTableCheckInfo
);
assert
(
numOfTables
>
0
);
// if (pQueryHandle->type == TSDB_QUERY_TYPE_EXTERNAL) {
// SMemRef* pMemRef = pQueryHandle->pMemRef;
// tsdbMayTakeMemSnapshot(pQueryHandle);
// bool ret = getNeighborRows(pQueryHandle);
// tsdbMayUnTakeMemSnapshot(pQueryHandle);
//
// // restore the pMemRef
// pQueryHandle->pMemRef = pMemRef;
// return ret;
/*} else*/
if
(
pQueryHandle
->
type
==
TSDB_QUERY_TYPE_LAST
&&
pQueryHandle
->
cachelastrow
)
{
if
(
pQueryHandle
->
type
==
TSDB_QUERY_TYPE_LAST
&&
pQueryHandle
->
cachelastrow
)
{
// the last row is cached in buffer, return it directly.
// here note that the pQueryHandle->window must be the TS_INITIALIZER
int32_t
numOfCols
=
(
int32_t
)(
QH_GET_NUM_OF_COLS
(
pQueryHandle
));
...
...
@@ -2872,7 +2716,7 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr)
};
getTableListfromSkipList
(
pExpr
,
pSTable
->
pIndex
,
pRes
,
&
supp
);
tExprTreeDestroy
(
&
pExpr
,
destroyHelper
);
tExprTreeDestroy
(
pExpr
,
destroyHelper
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2929,10 +2773,10 @@ int32_t tsdbQuerySTableByTagCond(TSDB_REPO_T* tsdb, uint64_t uid, TSKEY skey, co
if
(
expr
==
NULL
)
{
expr
=
exprTreeFromBinary
(
pTagCond
,
len
);
}
else
{
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Nod
eDestroy
,
expr
,
NULL
);
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Tre
eDestroy
,
expr
,
NULL
);
tExprNode
*
tagExpr
=
exprTreeFromBinary
(
pTagCond
,
len
);
if
(
tagExpr
!=
NULL
)
{
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Nod
eDestroy
,
tagExpr
,
NULL
);
CLEANUP_PUSH_VOID_PTR_PTR
(
true
,
tExpr
Tre
eDestroy
,
tagExpr
,
NULL
);
tExprNode
*
tbnameExpr
=
expr
;
expr
=
calloc
(
1
,
sizeof
(
tExprNode
));
if
(
expr
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录