Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d6647dd6
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看板
提交
d6647dd6
编写于
4月 27, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-186] add select on tags support
上级
b93fbf7c
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
231 addition
and
224 deletion
+231
-224
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+1
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+2
-2
src/inc/tsdb.h
src/inc/tsdb.h
+4
-13
src/query/inc/queryExecutor.h
src/query/inc/queryExecutor.h
+12
-15
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+1
-1
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+187
-144
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+4
-4
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+18
-37
src/util/inc/tutil.h
src/util/inc/tutil.h
+0
-5
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
d6647dd6
...
...
@@ -102,7 +102,7 @@ typedef struct SColumnIndex {
typedef
struct
SFieldSupInfo
{
bool
visible
;
S
ArithExprInfo
*
pArithExprInfo
;
S
ExprInfo
*
pArithExprInfo
;
SSqlExpr
*
pSqlExpr
;
}
SFieldSupInfo
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
d6647dd6
...
...
@@ -1207,7 +1207,7 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
slot
);
if
(
pInfo
->
pSqlExpr
==
NULL
)
{
S
ArithExprInfo
*
pFuncExpr
=
calloc
(
1
,
sizeof
(
SArith
ExprInfo
));
S
ExprInfo
*
pFuncExpr
=
calloc
(
1
,
sizeof
(
S
ExprInfo
));
pInfo
->
pArithExprInfo
=
pFuncExpr
;
// arithmetic expression always return result in the format of double float
...
...
src/client/src/tscSql.c
浏览文件 @
d6647dd6
...
...
@@ -437,7 +437,7 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
static
UNUSED_FUNC
char
*
getArithemicInputSrc
(
void
*
param
,
const
char
*
name
,
int32_t
colId
)
{
// SArithmeticSupport *pSupport = (SArithmeticSupport *)param;
// S
Arith
ExprInfo * pExpr = pSupport->pArithExpr;
// SExprInfo * pExpr = pSupport->pArithExpr;
// int32_t index = -1;
// for (int32_t i = 0; i < pExpr->numOfCols; ++i) {
...
...
src/inc/taosmsg.h
浏览文件 @
d6647dd6
...
...
@@ -380,13 +380,13 @@ typedef struct SSqlFuncMsg {
}
arg
[
3
];
}
SSqlFuncMsg
;
typedef
struct
S
Arith
ExprInfo
{
typedef
struct
SExprInfo
{
SSqlFuncMsg
base
;
struct
tExprNode
*
pExpr
;
int16_t
bytes
;
int16_t
type
;
int16_t
interResBytes
;
}
S
Arith
ExprInfo
;
}
SExprInfo
;
typedef
struct
SColumnFilterInfo
{
int16_t
lowerRelOptr
;
...
...
src/inc/tsdb.h
浏览文件 @
d6647dd6
...
...
@@ -97,8 +97,8 @@ int tsdbTableSetName(STableCfg *config, char *name, bool dup);
int
tsdbTableSetSName
(
STableCfg
*
config
,
char
*
sname
,
bool
dup
);
void
tsdbClearTableCfg
(
STableCfg
*
config
);
int32_t
tsdbGetTableTagVal
(
TsdbRepoT
*
repo
,
STableId
id
,
int32_t
col
,
int16_t
*
type
,
int16_t
*
bytes
,
char
**
val
);
int32_t
tsdbTableGetName
(
TsdbRepoT
*
repo
,
STableId
id
,
char
**
name
);
int32_t
tsdbGetTableTagVal
(
TsdbRepoT
*
repo
,
STableId
*
id
,
int32_t
col
,
int16_t
*
type
,
int16_t
*
bytes
,
char
**
val
);
int32_t
tsdbTableGetName
(
TsdbRepoT
*
repo
,
STableId
*
id
,
char
**
name
);
int
tsdbCreateTable
(
TsdbRepoT
*
repo
,
STableCfg
*
pCfg
);
int
tsdbDropTable
(
TsdbRepoT
*
pRepo
,
STableId
tableId
);
...
...
@@ -150,21 +150,12 @@ typedef struct STsdbQueryCond {
SColumnInfo
*
colList
;
}
STsdbQueryCond
;
typedef
struct
SBlockInfo
{
STimeWindow
window
;
int32_t
numOfRows
;
int32_t
numOfCols
;
STableId
tableId
;
}
SBlockInfo
;
typedef
struct
SDataBlockInfo
{
STimeWindow
window
;
int32_t
rows
;
int32_t
numOfCols
;
int64_t
uid
;
int32_t
s
id
;
int32_t
t
id
;
}
SDataBlockInfo
;
typedef
struct
{
...
...
@@ -279,7 +270,7 @@ SArray *tsdbGetTableList(TsdbQueryHandleT *pQueryHandle);
* @param pTagCond. tag query condition
*
*/
int32_t
tsdbQuery
ByTags
Cond
(
int32_t
tsdbQuery
STableByTag
Cond
(
TsdbRepoT
*
tsdb
,
int64_t
uid
,
const
char
*
pTagCond
,
...
...
src/query/inc/queryExecutor.h
浏览文件 @
d6647dd6
...
...
@@ -96,24 +96,20 @@ typedef struct SSingleColumnFilterInfo {
void
*
pData
;
}
SSingleColumnFilterInfo
;
typedef
struct
STableQueryInfo
{
int64_t
lastKey
;
STimeWindow
win
;
typedef
struct
STableQueryInfo
{
// todo merge with the STableQueryInfo struct
int32_t
tableIndex
;
int32_t
groupIdx
;
// group id in table list
TSKEY
lastKey
;
int32_t
numOfRes
;
int16_t
queryRangeSet
;
// denote if the query range is set, only available for interval query
int64_t
tag
;
STimeWindow
win
;
STSCursor
cur
;
int32_t
tid
;
// for retrieve the page id list
STableId
id
;
// for retrieve the page id list
SWindowResInfo
windowResInfo
;
}
STableQueryInfo
;
typedef
struct
STableDataInfo
{
// todo merge with the STableQueryInfo struct
int32_t
tableIndex
;
int32_t
groupIdx
;
// group id in table list
STableQueryInfo
*
pTableQInfo
;
}
STableDataInfo
;
typedef
struct
SQuery
{
int16_t
numOfCols
;
int16_t
numOfTags
;
...
...
@@ -130,7 +126,7 @@ typedef struct SQuery {
SLimitVal
limit
;
int32_t
rowSize
;
SSqlGroupbyExpr
*
pGroupbyExpr
;
S
ArithExprInfo
*
pSelectExpr
;
S
ExprInfo
*
pSelectExpr
;
SColumnInfo
*
colList
;
SColumnInfo
*
tagColList
;
int32_t
numOfFilterCols
;
...
...
@@ -170,14 +166,15 @@ typedef struct SQInfo {
TSKEY
startTime
;
TSKEY
elapsedTime
;
int32_t
pointsInterpo
;
int32_t
code
;
// error code to returned to client
int32_t
code
;
// error code to returned to client
sem_t
dataReady
;
void
*
tsdb
;
STableGroupInfo
groupInfo
;
// table id list
STableGroupInfo
tableIdGroupInfo
;
// table id list < only includes the STableId list>
STableGroupInfo
groupInfo
;
//
SQueryRuntimeEnv
runtimeEnv
;
int32_t
groupIndex
;
int32_t
offset
;
/* offset in group result set of subgroup */
int32_t
offset
;
// offset in group result set of subgroup, todo refactor
T_REF_DECLARE
()
/*
...
...
src/query/inc/tsqlfunction.h
浏览文件 @
d6647dd6
...
...
@@ -114,7 +114,7 @@ enum {
#define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0)
typedef
struct
SArithmeticSupport
{
S
Arith
ExprInfo
*
pArithExpr
;
SExprInfo
*
pArithExpr
;
int32_t
numOfCols
;
SColumnInfo
*
colList
;
int32_t
offset
;
...
...
src/query/src/queryExecutor.c
浏览文件 @
d6647dd6
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbMeta.c
浏览文件 @
d6647dd6
...
...
@@ -225,9 +225,9 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable) {
}
}
int32_t
tsdbGetTableTagVal
(
TsdbRepoT
*
repo
,
STableId
id
,
int32_t
colId
,
int16_t
*
type
,
int16_t
*
bytes
,
char
**
val
)
{
int32_t
tsdbGetTableTagVal
(
TsdbRepoT
*
repo
,
STableId
*
id
,
int32_t
colId
,
int16_t
*
type
,
int16_t
*
bytes
,
char
**
val
)
{
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
repo
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
.
uid
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
STSchema
*
pSchema
=
tsdbGetTableTagSchema
(
pMeta
,
pTable
);
...
...
@@ -251,9 +251,9 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId id, int32_t colId, int16_t*
return
0
;
}
int32_t
tsdbTableGetName
(
TsdbRepoT
*
repo
,
STableId
id
,
char
**
name
)
{
int32_t
tsdbTableGetName
(
TsdbRepoT
*
repo
,
STableId
*
id
,
char
**
name
)
{
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
repo
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
.
uid
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
*
name
=
strndup
(
pTable
->
name
,
TSDB_TABLE_NAME_LEN
);
if
(
*
name
==
NULL
)
{
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
d6647dd6
...
...
@@ -62,13 +62,9 @@ typedef struct STableCheckInfo {
STableId
tableId
;
TSKEY
lastKey
;
STable
*
pTableObj
;
int64_t
offsetInHeaderFile
;
int32_t
start
;
bool
checkFirstFileBlock
;
SCompInfo
*
pCompInfo
;
int32_t
compSize
;
int32_t
numOfBlocks
;
// number of qualified data blocks not the original blocks
SDataCols
*
pDataCols
;
...
...
@@ -159,15 +155,15 @@ TsdbQueryHandleT* tsdbQueryTables(TsdbRepoT* tsdb, STsdbQueryCond* pCond, STable
assert
(
gsize
>
0
);
for
(
int32_t
j
=
0
;
j
<
gsize
;
++
j
)
{
SPair
*
d
=
(
SPair
*
)
taosArrayGet
(
group
,
j
);
assert
(
d
->
first
!=
NULL
);
STableId
*
id
=
(
STableId
*
)
taosArrayGet
(
group
,
j
);
STableCheckInfo
info
=
{
.
lastKey
=
pQueryHandle
->
window
.
skey
,
.
tableId
=
((
STable
*
)
d
->
first
)
->
tableI
d
,
.
pTableObj
=
d
->
first
,
.
tableId
=
*
i
d
,
.
pTableObj
=
tsdbGetTableByUid
(
tsdbGetMeta
(
tsdb
),
id
->
uid
)
,
};
assert
(
info
.
pTableObj
!=
NULL
);
taosArrayPush
(
pQueryHandle
->
pTableCheckInfo
,
&
info
);
}
}
...
...
@@ -357,7 +353,7 @@ static SDataBlockInfo getTrueDataBlockInfo(STableCheckInfo* pCheckInfo, SCompBlo
.
window
=
{.
skey
=
pBlock
->
keyFirst
,
.
ekey
=
pBlock
->
keyLast
},
.
numOfCols
=
pBlock
->
numOfCols
,
.
rows
=
pBlock
->
numOfPoints
,
.
s
id
=
pCheckInfo
->
tableId
.
tid
,
.
t
id
=
pCheckInfo
->
tableId
.
tid
,
.
uid
=
pCheckInfo
->
tableId
.
uid
,
};
...
...
@@ -1058,7 +1054,7 @@ SDataBlockInfo tsdbRetrieveDataBlockInfo(TsdbQueryHandleT* pQueryHandle) {
SDataBlockInfo
blockInfo
=
{
.
uid
=
pTable
->
tableId
.
uid
,
.
s
id
=
pTable
->
tableId
.
tid
,
.
t
id
=
pTable
->
tableId
.
tid
,
.
rows
=
rows
,
.
window
=
{.
skey
=
MIN
(
skey
,
ekey
),
.
ekey
=
MAX
(
skey
,
ekey
)}
};
...
...
@@ -1293,24 +1289,19 @@ int32_t tableGroupComparFn(const void *p1, const void *p2, const void *param) {
}
void
createTableGroupImpl
(
SArray
*
pGroups
,
STable
**
pTables
,
size_t
numOfTables
,
STableGroupSupporter
*
pSupp
,
__ext_compar_fn_t
compareFn
)
{
SArray
*
g
=
taosArrayInit
(
16
,
sizeof
(
SPair
));
SPair
p
=
{.
first
=
pTables
[
0
]};
taosArrayPush
(
g
,
&
p
);
SArray
*
g
=
taosArrayInit
(
16
,
sizeof
(
STableId
));
taosArrayPush
(
g
,
&
pTables
[
0
]
->
tableId
);
for
(
int32_t
i
=
1
;
i
<
numOfTables
;
++
i
)
{
int32_t
ret
=
compareFn
(
&
pTables
[
i
-
1
],
&
pTables
[
i
],
pSupp
);
assert
(
ret
==
0
||
ret
==
-
1
);
if
(
ret
==
0
)
{
SPair
p1
=
{.
first
=
pTables
[
i
]};
taosArrayPush
(
g
,
&
p1
);
taosArrayPush
(
g
,
&
pTables
[
i
]
->
tableId
);
}
else
{
taosArrayPush
(
pGroups
,
&
g
);
// current group is ended, start a new group
g
=
taosArrayInit
(
16
,
POINTER_BYTES
);
SPair
p1
=
{.
first
=
pTables
[
i
]};
taosArrayPush
(
g
,
&
p1
);
taosArrayPush
(
g
,
&
pTables
[
i
]
->
tableId
);
}
}
...
...
@@ -1329,11 +1320,10 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
}
if
(
numOfOrderCols
==
0
||
size
==
1
)
{
// no group by tags clause or only one table
SArray
*
sa
=
taosArrayInit
(
size
,
sizeof
(
S
Pair
));
SArray
*
sa
=
taosArrayInit
(
size
,
sizeof
(
S
TableId
));
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
STable
*
pTable
=
taosArrayGetP
(
pTableList
,
i
);
SPair
p
=
{.
first
=
pTable
};
taosArrayPush
(
sa
,
&
p
);
taosArrayPush
(
sa
,
&
pTable
->
tableId
);
}
taosArrayPush
(
pTableGroup
,
&
sa
);
...
...
@@ -1441,24 +1431,15 @@ static int32_t doQueryTableList(STable* pSTable, SArray* pRes, tExprNode* pExpr)
}
int32_t
tsdbQueryByTagsCond
(
TsdbRepoT
*
tsdb
,
int64_t
uid
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
)
{
int32_t
tsdbQuerySTableByTagCond
(
TsdbRepoT
*
tsdb
,
int64_t
uid
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
)
{
STable
*
pSTable
=
tsdbGetTableByUid
(
tsdbGetMeta
(
tsdb
),
uid
);
if
(
pSTable
==
NULL
)
{
uError
(
"failed to get stable, uid:%"
PRIu64
,
uid
);
return
TSDB_CODE_INVALID_TABLE_ID
;
}
SArray
*
res
=
taosArrayInit
(
8
,
POINTER_BYTES
);
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
STableId
)
);
STSchema
*
pTagSchema
=
tsdbGetTableTagSchema
(
tsdbGetMeta
(
tsdb
),
pSTable
);
// no tags and tbname condition, all child tables of this stable are involved
...
...
@@ -1472,7 +1453,7 @@ int32_t tsdbQueryByTagsCond(
return
ret
;
}
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
tExprNode
*
expr
=
exprTreeFromTableName
(
tbnameCond
);
tExprNode
*
tagExpr
=
exprTreeFromBinary
(
pTagCond
,
len
);
...
...
@@ -1507,9 +1488,9 @@ int32_t tsdbGetOneTableGroup(TsdbRepoT* tsdb, int64_t uid, STableGroupInfo* pGro
pGroupInfo
->
numOfTables
=
1
;
pGroupInfo
->
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
group
=
taosArrayInit
(
1
,
POINTER_BYTES
);
SArray
*
group
=
taosArrayInit
(
1
,
sizeof
(
STableId
)
);
taosArrayPush
(
group
,
&
pTable
);
taosArrayPush
(
group
,
&
pTable
->
tableId
);
taosArrayPush
(
pGroupInfo
->
pGroupList
,
&
group
);
return
TSDB_CODE_SUCCESS
;
...
...
src/util/inc/tutil.h
浏览文件 @
d6647dd6
...
...
@@ -107,11 +107,6 @@ extern "C" {
#define POW2(x) ((x) * (x))
typedef
struct
SPair
{
void
*
first
;
void
*
sec
;
}
SPair
;
int32_t
strdequote
(
char
*
src
);
void
strtrim
(
char
*
src
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录