Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9d652bed
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9d652bed
编写于
7月 07, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] refactor code and fix error sim script.
上级
fe91d3d9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
41 addition
and
144 deletion
+41
-144
src/query/inc/qast.h
src/query/inc/qast.h
+3
-10
src/query/src/qast.c
src/query/src/qast.c
+21
-119
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+5
-2
src/util/inc/tlosertree.h
src/util/inc/tlosertree.h
+0
-0
src/util/src/tlosertree.c
src/util/src/tlosertree.c
+3
-3
tests/script/general/parser/join.sim
tests/script/general/parser/join.sim
+9
-10
未找到文件。
src/query/inc/qast.h
浏览文件 @
9d652bed
...
...
@@ -16,16 +16,16 @@
#ifndef TDENGINE_TAST_H
#define TDENGINE_TAST_H
#include <tbuffer.h>
#ifdef __cplusplus
extern
"C"
{
#endif
#include <tskiplist.h>
#include "os.h"
#include "taosmsg.h"
#include "taosdef.h"
#include "tskiplist.h"
#include "tbuffer.h"
#include "tvariant.h"
struct
tExprNode
;
...
...
@@ -75,10 +75,6 @@ typedef struct tExprNode {
};
}
tExprNode
;
void
tSQLBinaryExprFromString
(
tExprNode
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
);
void
tSQLBinaryExprToString
(
tExprNode
*
pExpr
,
char
*
dst
,
int32_t
*
len
);
void
tExprTreeDestroy
(
tExprNode
**
pExprs
,
void
(
*
fp
)(
void
*
));
void
tExprTreeTraverse
(
tExprNode
*
pExpr
,
SSkipList
*
pSkipList
,
SArray
*
result
,
SExprTraverseSupp
*
param
);
...
...
@@ -86,12 +82,9 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
void
tExprTreeCalcTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
cb
)(
void
*
,
const
char
*
,
int32_t
));
// todo refactor: remove it
void
tSQLBinaryExprTrv
(
tExprNode
*
pExprs
,
SArray
*
res
);
uint8_t
getBinaryExprOptr
(
SSQLToken
*
pToken
);
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
tExprNode
*
exprTreeFromBinary
(
const
void
*
data
,
size_t
size
);
...
...
src/query/src/qast.c
浏览文件 @
9d652bed
...
...
@@ -327,104 +327,6 @@ static tExprNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, char *st
}
}
void
tSQLBinaryExprFromString
(
tExprNode
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
)
{
*
pExpr
=
NULL
;
if
(
len
<=
0
||
src
==
NULL
||
pSchema
==
NULL
||
numOfCols
<=
0
)
{
return
;
}
int32_t
pos
=
0
;
*
pExpr
=
createSyntaxTree
(
pSchema
,
numOfCols
,
src
,
&
pos
);
if
(
*
pExpr
!=
NULL
)
{
assert
((
*
pExpr
)
->
nodeType
==
TSQL_NODE_EXPR
);
}
}
int32_t
tSQLBinaryExprToStringImpl
(
tExprNode
*
pNode
,
char
*
dst
,
uint8_t
type
)
{
int32_t
len
=
0
;
if
(
type
==
TSQL_NODE_EXPR
)
{
*
dst
=
'('
;
tSQLBinaryExprToString
(
pNode
,
dst
+
1
,
&
len
);
len
+=
2
;
*
(
dst
+
len
-
1
)
=
')'
;
}
else
if
(
type
==
TSQL_NODE_COL
)
{
len
=
sprintf
(
dst
,
"%s"
,
pNode
->
pSchema
->
name
);
}
else
{
len
=
tVariantToString
(
pNode
->
pVal
,
dst
);
}
return
len
;
}
// TODO REFACTOR WITH SQL PARSER
static
char
*
tSQLOptrToString
(
uint8_t
optr
,
char
*
dst
)
{
switch
(
optr
)
{
case
TSDB_RELATION_LESS
:
{
*
dst
=
'<'
;
dst
+=
1
;
break
;
}
case
TSDB_RELATION_LESS_EQUAL
:
{
*
dst
=
'<'
;
*
(
dst
+
1
)
=
'='
;
dst
+=
2
;
break
;
}
case
TSDB_RELATION_EQUAL
:
{
*
dst
=
'='
;
dst
+=
1
;
break
;
}
case
TSDB_RELATION_GREATER
:
{
*
dst
=
'>'
;
dst
+=
1
;
break
;
}
case
TSDB_RELATION_GREATER_EQUAL
:
{
*
dst
=
'>'
;
*
(
dst
+
1
)
=
'='
;
dst
+=
2
;
break
;
}
case
TSDB_RELATION_NOT_EQUAL
:
{
*
dst
=
'<'
;
*
(
dst
+
1
)
=
'>'
;
dst
+=
2
;
break
;
}
case
TSDB_RELATION_OR
:
{
memcpy
(
dst
,
"or"
,
2
);
dst
+=
2
;
break
;
}
case
TSDB_RELATION_AND
:
{
memcpy
(
dst
,
"and"
,
3
);
dst
+=
3
;
break
;
}
default:
;
}
return
dst
;
}
void
tSQLBinaryExprToString
(
tExprNode
*
pExpr
,
char
*
dst
,
int32_t
*
len
)
{
if
(
pExpr
==
NULL
)
{
*
dst
=
0
;
*
len
=
0
;
return
;
}
int32_t
lhs
=
tSQLBinaryExprToStringImpl
(
pExpr
->
_node
.
pLeft
,
dst
,
pExpr
->
_node
.
pLeft
->
nodeType
);
dst
+=
lhs
;
*
len
=
lhs
;
char
*
start
=
tSQLOptrToString
(
pExpr
->
_node
.
optr
,
dst
);
*
len
+=
(
start
-
dst
);
*
len
+=
tSQLBinaryExprToStringImpl
(
pExpr
->
_node
.
pRight
,
start
,
pExpr
->
_node
.
pRight
->
nodeType
);
}
static
void
UNUSED_FUNC
destroySyntaxTree
(
tExprNode
*
pNode
)
{
tExprNodeDestroy
(
pNode
,
NULL
);
}
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
))
{
...
...
@@ -976,27 +878,27 @@ void tExprTreeCalcTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
free
(
pRightOutput
);
}
void
tSQLBinaryExprTrv
(
tExprNode
*
pExprs
,
SArray
*
res
)
{
if
(
pExprs
==
NULL
)
{
return
;
}
tExprNode
*
pLeft
=
pExprs
->
_node
.
pLeft
;
tExprNode
*
pRight
=
pExprs
->
_node
.
pRight
;
// recursive traverse left child branch
if
(
pLeft
->
nodeType
==
TSQL_NODE_EXPR
)
{
tSQLBinaryExprTrv
(
pLeft
,
res
);
}
else
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
taosArrayPush
(
res
,
&
pLeft
->
pSchema
->
colId
);
}
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
tSQLBinaryExprTrv
(
pRight
,
res
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
taosArrayPush
(
res
,
&
pRight
->
pSchema
->
colId
);
}
}
//
void tSQLBinaryExprTrv(tExprNode *pExprs, SArray* res) {
//
if (pExprs == NULL) {
//
return;
//
}
//
//
tExprNode *pLeft = pExprs->_node.pLeft;
//
tExprNode *pRight = pExprs->_node.pRight;
//
//
// recursive traverse left child branch
//
if (pLeft->nodeType == TSQL_NODE_EXPR) {
//
tSQLBinaryExprTrv(pLeft, res);
//
} else if (pLeft->nodeType == TSQL_NODE_COL) {
//
taosArrayPush(res, &pLeft->pSchema->colId);
//
}
//
//
if (pRight->nodeType == TSQL_NODE_EXPR) {
//
tSQLBinaryExprTrv(pRight, res);
//
} else if (pRight->nodeType == TSQL_NODE_COL) {
//
taosArrayPush(res, &pRight->pSchema->colId);
//
}
//
}
static
void
exprTreeToBinaryImpl
(
SBufferWriter
*
bw
,
tExprNode
*
expr
)
{
tbufWriteUint8
(
bw
,
expr
->
nodeType
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
9d652bed
...
...
@@ -22,7 +22,7 @@
#include "exception.h"
#include "../../../query/inc/qast.h" // todo move to common module
#include "
../../../query/inc/tlosertree.h" // todo move to util module
#include "
tlosertree.h"
#include "tsdb.h"
#include "tsdbMain.h"
...
...
@@ -577,6 +577,8 @@ static SArray* getDefaultLoadColumns(STsdbQueryHandle* pQueryHandle, bool loadTS
static
bool
doLoadFileDataBlock
(
STsdbQueryHandle
*
pQueryHandle
,
SCompBlock
*
pBlock
,
STableCheckInfo
*
pCheckInfo
)
{
STsdbRepo
*
pRepo
=
pQueryHandle
->
pTsdb
;
// TODO refactor
SCompData
*
data
=
calloc
(
1
,
sizeof
(
SCompData
)
+
sizeof
(
SCompCol
)
*
pBlock
->
numOfCols
);
data
->
numOfCols
=
pBlock
->
numOfCols
;
...
...
@@ -606,8 +608,9 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
}
SDataCols
*
pCols
=
pQueryHandle
->
rhelper
.
pDataCols
[
0
];
assert
(
pCols
->
numOfRows
!=
0
);
assert
(
pCols
->
numOfRows
!=
0
&&
pCols
->
numOfRows
<=
pBlock
->
numOfRows
);
pBlock
->
numOfRows
=
pCols
->
numOfRows
;
taosArrayDestroy
(
sa
);
tfree
(
data
);
...
...
src/
query
/inc/tlosertree.h
→
src/
util
/inc/tlosertree.h
浏览文件 @
9d652bed
文件已移动
src/
query
/src/tlosertree.c
→
src/
util
/src/tlosertree.c
浏览文件 @
9d652bed
...
...
@@ -13,10 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tlosertree.h"
#include "os.h"
#include "taosmsg.h"
#include "tlosertree.h"
#include "queryLog.h"
#include "tulog.h"
// set initial value for loser tree
void
tLoserTreeInit
(
SLoserTreeInfo
*
pTree
)
{
...
...
@@ -45,7 +45,7 @@ uint32_t tLoserTreeCreate(SLoserTreeInfo** pTree, int32_t numOfEntries, void* pa
*
pTree
=
(
SLoserTreeInfo
*
)
calloc
(
1
,
sizeof
(
SLoserTreeInfo
)
+
sizeof
(
SLoserTreeNode
)
*
totalEntries
);
if
((
*
pTree
)
==
NULL
)
{
q
Error
(
"allocate memory for loser-tree failed. reason:%s"
,
strerror
(
errno
));
u
Error
(
"allocate memory for loser-tree failed. reason:%s"
,
strerror
(
errno
));
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
tests/script/general/parser/join.sim
浏览文件 @
9d652bed
...
...
@@ -448,15 +448,14 @@ sql insert into um2 using m2 tags(9) values(1000001, 10)(2000000, 20);
sql_error select count(*) from m1,m2 where m1.a=m2.a and m1.ts=m2.ts;
#empty table join test, add for no result join test
create database ux1;
use ux1;
create table m1(ts timestamp, k int) tags(a binary(12), b int);
create table tm0 using m1 tags('abc', 1);
create table m2(ts timestamp, k int) tags(a int, b binary(12));
create table tm2 using m2 tags(2, 'abc');
select count(*) from tm0, tm2 where tm0.ts=tm2.ts;
select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a
drop database ux1;
sql create database ux1;
sql use ux1;
sql create table m1(ts timestamp, k int) tags(a binary(12), b int);
sql create table tm0 using m1 tags('abc', 1);
sql create table m2(ts timestamp, k int) tags(a int, b binary(12));
sql create table tm2 using m2 tags(2, 'abc');
sql select count(*) from tm0, tm2 where tm0.ts=tm2.ts;
sql select count(*) from m1, m2 where m1.ts=m2.ts and m1.b=m2.a
sql drop database ux1;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录