Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
01846142
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看板
提交
01846142
编写于
5月 11, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs in tags filter query
上级
f1d26db0
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
84 addition
and
80 deletion
+84
-80
cmake/platform.inc
cmake/platform.inc
+1
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+6
-8
src/query/inc/qast.h
src/query/inc/qast.h
+2
-2
src/query/src/qast.c
src/query/src/qast.c
+13
-13
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+31
-38
src/query/src/queryFilterFunc.c
src/query/src/queryFilterFunc.c
+10
-10
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+1
-1
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+2
-2
src/util/src/tcompare.c
src/util/src/tcompare.c
+14
-3
tests/script/general/tag/create.sim
tests/script/general/tag/create.sim
+4
-2
未找到文件。
cmake/platform.inc
浏览文件 @
01846142
...
@@ -62,7 +62,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
...
@@ -62,7 +62,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
8
)
IF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
8
)
SET
(
TD_LINUX_64
TRUE
)
SET
(
TD_LINUX_64
TRUE
)
SET
(
TD_OS_DIR
$
{
TD_COMMUNITY_DIR
}
/
src
/
os
/
linux
)
SET
(
TD_OS_DIR
$
{
TD_COMMUNITY_DIR
}
/
src
/
os
/
linux
)
ADD_DEFINITIONS
(
-
D_M_X64
)
ADD_DEFINITIONS
(
-
D_M_X64
-
D_DEBUG_VIEW
)
MESSAGE
(
STATUS
"The current platform is Linux 64-bit"
)
MESSAGE
(
STATUS
"The current platform is Linux 64-bit"
)
ELSEIF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
4
)
ELSEIF
(
$
{
CMAKE_SIZEOF_VOID_P
}
MATCHES
4
)
IF
(
TD_ARM
)
IF
(
TD_ARM
)
...
...
src/client/src/tscUtil.c
浏览文件 @
01846142
...
@@ -1144,23 +1144,21 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
...
@@ -1144,23 +1144,21 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
}
}
SColumnFilterInfo
*
tscFilterInfoClone
(
const
SColumnFilterInfo
*
src
,
int32_t
numOfFilters
)
{
SColumnFilterInfo
*
tscFilterInfoClone
(
const
SColumnFilterInfo
*
src
,
int32_t
numOfFilters
)
{
SColumnFilterInfo
*
pFilter
=
NULL
;
if
(
numOfFilters
==
0
)
{
if
(
numOfFilters
>
0
)
{
pFilter
=
calloc
(
1
,
numOfFilters
*
sizeof
(
SColumnFilterInfo
));
}
else
{
assert
(
src
==
NULL
);
assert
(
src
==
NULL
);
return
NULL
;
return
NULL
;
}
}
SColumnFilterInfo
*
pFilter
=
calloc
(
1
,
numOfFilters
*
sizeof
(
SColumnFilterInfo
));
memcpy
(
pFilter
,
src
,
sizeof
(
SColumnFilterInfo
)
*
numOfFilters
);
memcpy
(
pFilter
,
src
,
sizeof
(
SColumnFilterInfo
)
*
numOfFilters
);
for
(
int32_t
j
=
0
;
j
<
numOfFilters
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfFilters
;
++
j
)
{
if
(
pFilter
[
j
].
filterstr
)
{
if
(
pFilter
[
j
].
filterstr
)
{
size_t
len
=
(
size_t
)
pFilter
[
j
].
len
+
1
;
size_t
len
=
(
size_t
)
pFilter
[
j
].
len
+
1
;
pFilter
[
j
].
pz
=
(
int64_t
)
calloc
(
1
,
len
);
char
*
pTmp
=
calloc
(
1
,
len
);
pFilter
[
j
].
pz
=
(
int64_t
)
pTmp
;
memcpy
((
char
*
)
pFilter
[
j
].
pz
,
(
char
*
)
src
->
pz
,
(
size_t
)
len
);
memcpy
((
char
*
)
pFilter
[
j
].
pz
,
(
char
*
)
src
[
j
].
pz
,
(
size_t
)
len
);
}
}
}
}
...
...
src/query/inc/qast.h
浏览文件 @
01846142
...
@@ -50,11 +50,11 @@ typedef struct tQueryInfo {
...
@@ -50,11 +50,11 @@ typedef struct tQueryInfo {
SSchema
sch
;
// schema of tags
SSchema
sch
;
// schema of tags
char
*
q
;
char
*
q
;
__compar_fn_t
compare
;
// filter function
__compar_fn_t
compare
;
// filter function
void
*
param
;
// STSchema
,
void
*
param
;
// STSchema
}
tQueryInfo
;
}
tQueryInfo
;
typedef
struct
SExprTraverseSupp
{
typedef
struct
SExprTraverseSupp
{
__result_filter_fn_t
fp
;
__result_filter_fn_t
nodeFilterFn
;
__do_filter_suppl_fn_t
setupInfoFn
;
__do_filter_suppl_fn_t
setupInfoFn
;
void
*
pExtInfo
;
void
*
pExtInfo
;
}
SExprTraverseSupp
;
}
SExprTraverseSupp
;
...
...
src/query/src/qast.c
浏览文件 @
01846142
...
@@ -760,7 +760,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *p
...
@@ -760,7 +760,7 @@ static bool filterItem(tExprNode *pExpr, const void *pItem, SExprTraverseSupp *p
assert
(
pLeft
->
nodeType
==
TSQL_NODE_COL
&&
pRight
->
nodeType
==
TSQL_NODE_VALUE
);
assert
(
pLeft
->
nodeType
==
TSQL_NODE_COL
&&
pRight
->
nodeType
==
TSQL_NODE_VALUE
);
param
->
setupInfoFn
(
pExpr
,
param
->
pExtInfo
);
param
->
setupInfoFn
(
pExpr
,
param
->
pExtInfo
);
return
param
->
fp
(
pItem
,
pExpr
->
_node
.
info
);
return
param
->
nodeFilterFn
(
pItem
,
pExpr
->
_node
.
info
);
}
}
/**
/**
...
@@ -801,33 +801,33 @@ static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSki
...
@@ -801,33 +801,33 @@ static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSki
tSkipListDestroyIter
(
iter
);
tSkipListDestroyIter
(
iter
);
}
}
static
void
tQueryIndexlessColumn
(
SSkipList
*
pSkipList
,
tQueryInfo
*
pQueryInfo
,
SArray
*
res
ult
)
{
static
void
tQueryIndexlessColumn
(
SSkipList
*
pSkipList
,
tQueryInfo
*
pQueryInfo
,
SArray
*
res
,
__result_filter_fn_t
filterFp
)
{
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pSkipList
);
SSkipListIterator
*
iter
=
tSkipListCreateIter
(
pSkipList
);
while
(
tSkipListIterNext
(
iter
))
{
while
(
tSkipListIterNext
(
iter
))
{
bool
addToResult
=
false
;
bool
addToResult
=
false
;
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
SSkipListNode
*
pNode
=
tSkipListIterGet
(
iter
);
char
*
pTable
=
SL_GET_NODE_DATA
(
pNode
);
char
*
pData
=
SL_GET_NODE_DATA
(
pNode
);
//todo refactor:
//
todo refactor:
tstr
*
name
=
((
STableIndexElem
*
)
pTable
)
->
pTable
->
name
;
tstr
*
name
=
((
STableIndexElem
*
)
pData
)
->
pTable
->
name
;
// char* name = NULL;
// char* name = NULL;
//
tsdbGetTableName(tsdb
, pTable, &name);
//
tsdbGetTableName(pQueryInfo->
, pTable, &name);
// todo speed up by using hash
// todo speed up by using hash
if
(
pQueryInfo
->
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pQueryInfo
->
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
pQueryInfo
->
optr
==
TSDB_RELATION_IN
)
{
if
(
pQueryInfo
->
optr
==
TSDB_RELATION_IN
)
{
addToResult
=
pQueryInfo
->
compare
(
name
,
pQueryInfo
->
q
);
addToResult
=
pQueryInfo
->
compare
(
name
,
pQueryInfo
->
q
);
}
else
if
(
pQueryInfo
->
optr
==
TSDB_RELATION_LIKE
)
{
}
else
if
(
pQueryInfo
->
optr
==
TSDB_RELATION_LIKE
)
{
addToResult
=
!
pQueryInfo
->
compare
(
name
,
pQueryInfo
->
q
);
addToResult
=
!
pQueryInfo
->
compare
(
name
,
pQueryInfo
->
q
);
}
}
}
else
{
}
else
{
// TODO: other columns
addToResult
=
filterFp
(
pNode
,
pQueryInfo
);
}
}
if
(
addToResult
)
{
if
(
addToResult
)
{
taosArrayPush
(
res
ult
,
pTable
);
taosArrayPush
(
res
,
pData
);
}
}
}
}
...
@@ -851,7 +851,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
...
@@ -851,7 +851,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
param
->
setupInfoFn
(
pExpr
,
param
->
pExtInfo
);
param
->
setupInfoFn
(
pExpr
,
param
->
pExtInfo
);
if
(
pSkipList
==
NULL
)
{
if
(
pSkipList
==
NULL
)
{
tArrayTraverse
(
pExpr
,
param
->
fp
,
result
);
tArrayTraverse
(
pExpr
,
param
->
nodeFilterFn
,
result
);
return
;
return
;
}
}
...
@@ -859,7 +859,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
...
@@ -859,7 +859,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
if
(
pQueryInfo
->
colIndex
==
0
&&
pQueryInfo
->
optr
!=
TSDB_RELATION_LIKE
)
{
if
(
pQueryInfo
->
colIndex
==
0
&&
pQueryInfo
->
optr
!=
TSDB_RELATION_LIKE
)
{
tQueryIndexColumn
(
pSkipList
,
pQueryInfo
,
result
);
tQueryIndexColumn
(
pSkipList
,
pQueryInfo
,
result
);
}
else
{
}
else
{
tQueryIndexlessColumn
(
pSkipList
,
pQueryInfo
,
result
);
tQueryIndexlessColumn
(
pSkipList
,
pQueryInfo
,
result
,
param
->
nodeFilterFn
);
}
}
return
;
return
;
...
...
src/query/src/queryExecutor.c
浏览文件 @
01846142
...
@@ -2641,26 +2641,21 @@ static UNUSED_FUNC void printBinaryData(int32_t functionId, char *data, int32_t
...
@@ -2641,26 +2641,21 @@ static UNUSED_FUNC void printBinaryData(int32_t functionId, char *data, int32_t
}
}
}
}
void
UNUSED_FUNC
displayInterResult
(
SData
**
pdata
,
SQuery
*
pQuery
,
int32_t
numOfRows
)
{
void
UNUSED_FUNC
displayInterResult
(
SData
**
pdata
,
SQuery
RuntimeEnv
*
pRuntimeEnv
,
int32_t
numOfRows
)
{
#if 0
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
int32_t
numOfCols
=
pQuery
->
numOfOutput
;
int32_t
numOfCols
=
pQuery
->
numOfOutput
;
printf
(
"super table query intermediate result, total:%d
\n
"
,
numOfRows
);
printf
(
"super table query intermediate result, total:%d
\n
"
,
numOfRows
);
SQInfo * pQInfo = (SQInfo *)(GET_QINFO_ADDR(pQuery));
SMeterObj *pMeterObj = pQInfo->pObj;
for
(
int32_t
j
=
0
;
j
<
numOfRows
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfRows
;
++
j
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
switch
(
pQuery
->
pSelectExpr
[
i
].
type
)
{
switch
(
pQuery
->
pSelectExpr
[
i
].
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
{
case
TSDB_DATA_TYPE_BINARY
:
{
int32_t colIndex = pQuery->pSelectExpr[i].base.colInfo.colIndex;
// int32_t colIndex = pQuery->pSelectExpr[i].base.colInfo.colIndex;
int32_t type = 0;
int32_t
type
=
pQuery
->
pSelectExpr
[
i
].
type
;
// } else {
if (TSDB_COL_IS_TAG(pQuery->pSelectExpr[i].base.colInfo.flag)) {
// type = pMeterObj->schema[colIndex].type;
type = pQuery->pSelectExpr[i].type;
// }
} else {
type = pMeterObj->schema[colIndex].type;
}
printBinaryData
(
pQuery
->
pSelectExpr
[
i
].
base
.
functionId
,
pdata
[
i
]
->
data
+
pQuery
->
pSelectExpr
[
i
].
bytes
*
j
,
printBinaryData
(
pQuery
->
pSelectExpr
[
i
].
base
.
functionId
,
pdata
[
i
]
->
data
+
pQuery
->
pSelectExpr
[
i
].
bytes
*
j
,
type
);
type
);
break
;
break
;
...
@@ -2682,7 +2677,6 @@ void UNUSED_FUNC displayInterResult(SData **pdata, SQuery *pQuery, int32_t numOf
...
@@ -2682,7 +2677,6 @@ void UNUSED_FUNC displayInterResult(SData **pdata, SQuery *pQuery, int32_t numOf
}
}
printf
(
"
\n
"
);
printf
(
"
\n
"
);
}
}
#endif
}
}
typedef
struct
SCompSupporter
{
typedef
struct
SCompSupporter
{
...
@@ -2950,7 +2944,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
...
@@ -2950,7 +2944,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
int64_t
endt
=
taosGetTimestampMs
();
int64_t
endt
=
taosGetTimestampMs
();
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
displayInterResult
(
pQuery
->
sdata
,
p
Query
,
pQuery
->
sdata
[
0
]
->
num
);
displayInterResult
(
pQuery
->
sdata
,
p
RuntimeEnv
,
pQuery
->
sdata
[
0
]
->
num
);
#endif
#endif
qTrace
(
"QInfo:%p result merge completed, elapsed time:%"
PRId64
" ms"
,
GET_QINFO_ADDR
(
pQuery
),
endt
-
startt
);
qTrace
(
"QInfo:%p result merge completed, elapsed time:%"
PRId64
" ms"
,
GET_QINFO_ADDR
(
pQuery
),
endt
-
startt
);
...
@@ -3588,7 +3582,8 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
...
@@ -3588,7 +3582,8 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
if
(
pTableQueryInfo
->
queryRangeSet
)
{
if
(
pTableQueryInfo
->
queryRangeSet
)
{
pTableQueryInfo
->
lastKey
=
key
;
pTableQueryInfo
->
lastKey
=
key
;
}
else
{
}
else
{
pQuery
->
window
.
skey
=
key
;
// pQuery->window.skey = key;
pTableQueryInfo
->
win
.
skey
=
key
;
STimeWindow
win
=
{.
skey
=
key
,
.
ekey
=
pQuery
->
window
.
ekey
};
STimeWindow
win
=
{.
skey
=
key
,
.
ekey
=
pQuery
->
window
.
ekey
};
// for too small query range, no data in this interval.
// for too small query range, no data in this interval.
...
@@ -3608,7 +3603,7 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
...
@@ -3608,7 +3603,7 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
SWindowResInfo
*
pWindowResInfo
=
&
pTableQueryInfo
->
windowResInfo
;
SWindowResInfo
*
pWindowResInfo
=
&
pTableQueryInfo
->
windowResInfo
;
getAlignQueryTimeWindow
(
pQuery
,
win
.
skey
,
win
.
skey
,
win
.
ekey
,
&
skey1
,
&
ekey1
,
&
w
);
getAlignQueryTimeWindow
(
pQuery
,
win
.
skey
,
win
.
skey
,
win
.
ekey
,
&
skey1
,
&
ekey1
,
&
w
);
pWindowResInfo
->
startTime
=
p
Query
->
window
.
skey
;
// windowSKey may be 0 in case of 1970 timestamp
pWindowResInfo
->
startTime
=
p
TableQueryInfo
->
win
.
skey
;
// windowSKey may be 0 in case of 1970 timestamp
if
(
pWindowResInfo
->
prevSKey
==
0
)
{
if
(
pWindowResInfo
->
prevSKey
==
0
)
{
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
...
@@ -3620,8 +3615,8 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
...
@@ -3620,8 +3615,8 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
}
}
pTableQueryInfo
->
queryRangeSet
=
1
;
pTableQueryInfo
->
queryRangeSet
=
1
;
pTableQueryInfo
->
lastKey
=
p
Query
->
window
.
skey
;
pTableQueryInfo
->
lastKey
=
p
TableQueryInfo
->
win
.
skey
;
pTableQueryInfo
->
win
.
skey
=
p
Query
->
window
.
skey
;
pTableQueryInfo
->
win
.
skey
=
p
TableQueryInfo
->
win
.
skey
;
}
}
}
}
...
@@ -3726,7 +3721,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
...
@@ -3726,7 +3721,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResult *result, int32_t orde
qTrace
(
"QInfo:%p copy data to query buf completed"
,
pQInfo
);
qTrace
(
"QInfo:%p copy data to query buf completed"
,
pQInfo
);
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
displayInterResult
(
pQuery
->
sdata
,
p
Query
,
numOfResult
);
displayInterResult
(
pQuery
->
sdata
,
p
RuntimeEnv
,
numOfResult
);
#endif
#endif
return
numOfResult
;
return
numOfResult
;
}
}
...
@@ -4766,7 +4761,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
...
@@ -4766,7 +4761,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
copyResToQueryResultBuf
(
pQInfo
,
pQuery
);
copyResToQueryResultBuf
(
pQInfo
,
pQuery
);
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
displayInterResult
(
pQuery
->
sdata
,
p
Query
,
pQuery
->
sdata
[
0
]
->
num
);
displayInterResult
(
pQuery
->
sdata
,
p
RuntimeEnv
,
pQuery
->
sdata
[
0
]
->
num
);
#endif
#endif
}
else
{
}
else
{
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
copyFromWindowResToSData
(
pQInfo
,
pRuntimeEnv
->
windowResInfo
.
pResult
);
...
@@ -4819,7 +4814,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
...
@@ -4819,7 +4814,7 @@ static void multiTableQueryProcess(SQInfo *pQInfo) {
copyResToQueryResultBuf
(
pQInfo
,
pQuery
);
copyResToQueryResultBuf
(
pQInfo
,
pQuery
);
#ifdef _DEBUG_VIEW
#ifdef _DEBUG_VIEW
displayInterResult
(
pQuery
->
sdata
,
p
Query
,
pQuery
->
sdata
[
0
]
->
num
);
displayInterResult
(
pQuery
->
sdata
,
p
RuntimeEnv
,
pQuery
->
sdata
[
0
]
->
num
);
#endif
#endif
}
}
}
else
{
// not a interval query
}
else
{
// not a interval query
...
@@ -5276,26 +5271,26 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
...
@@ -5276,26 +5271,26 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
}
}
for
(
int32_t
f
=
0
;
f
<
numOfFilters
;
++
f
)
{
for
(
int32_t
f
=
0
;
f
<
numOfFilters
;
++
f
)
{
SColumnFilterInfo
*
pFilter
Info
=
(
SColumnFilterInfo
*
)
pMsg
;
SColumnFilterInfo
*
pFilter
Msg
=
(
SColumnFilterInfo
*
)
pMsg
;
SColumnFilterInfo
*
pDestFilterInfo
=
&
pColInfo
->
filters
[
f
];
SColumnFilterInfo
*
pColFilter
=
&
pColInfo
->
filters
[
f
];
p
DestFilterInfo
->
filterstr
=
htons
(
pFilterInfo
->
filterstr
);
p
ColFilter
->
filterstr
=
htons
(
pFilterMsg
->
filterstr
);
pMsg
+=
sizeof
(
SColumnFilterInfo
);
pMsg
+=
sizeof
(
SColumnFilterInfo
);
if
(
p
DestFilterInfo
->
filterstr
)
{
if
(
p
ColFilter
->
filterstr
)
{
p
DestFilterInfo
->
len
=
htobe64
(
pFilterInfo
->
len
);
p
ColFilter
->
len
=
htobe64
(
pFilterMsg
->
len
);
p
DestFilterInfo
->
pz
=
(
int64_t
)
calloc
(
1
,
pDestFilterInfo
->
len
);
p
ColFilter
->
pz
=
(
int64_t
)
calloc
(
1
,
pColFilter
->
len
);
memcpy
((
void
*
)
p
DestFilterInfo
->
pz
,
pMsg
,
pDestFilterInfo
->
len
);
memcpy
((
void
*
)
p
ColFilter
->
pz
,
pMsg
,
pColFilter
->
len
);
pMsg
+=
(
p
DestFilterInfo
->
len
);
pMsg
+=
(
p
ColFilter
->
len
+
1
);
}
else
{
}
else
{
p
DestFilterInfo
->
lowerBndi
=
htobe64
(
pFilterInfo
->
lowerBndi
);
p
ColFilter
->
lowerBndi
=
htobe64
(
pFilterMsg
->
lowerBndi
);
p
DestFilterInfo
->
upperBndi
=
htobe64
(
pFilterInfo
->
upperBndi
);
p
ColFilter
->
upperBndi
=
htobe64
(
pFilterMsg
->
upperBndi
);
}
}
p
DestFilterInfo
->
lowerRelOptr
=
htons
(
pFilterInfo
->
lowerRelOptr
);
p
ColFilter
->
lowerRelOptr
=
htons
(
pFilterMsg
->
lowerRelOptr
);
p
DestFilterInfo
->
upperRelOptr
=
htons
(
pFilterInfo
->
upperRelOptr
);
p
ColFilter
->
upperRelOptr
=
htons
(
pFilterMsg
->
upperRelOptr
);
}
}
}
}
...
@@ -5692,9 +5687,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
...
@@ -5692,9 +5687,7 @@ static SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGrou
for
(
int16_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int16_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
pQuery
->
colList
[
i
]
=
pQueryMsg
->
colList
[
i
];
pQuery
->
colList
[
i
]
=
pQueryMsg
->
colList
[
i
];
pQuery
->
colList
[
i
].
filters
=
tscFilterInfoClone
(
pQueryMsg
->
colList
[
i
].
filters
,
pQuery
->
colList
[
i
].
numOfFilters
);
SColumnInfo
*
pColInfo
=
&
pQuery
->
colList
[
i
];
pColInfo
->
filters
=
tscFilterInfoClone
(
pQueryMsg
->
colList
[
i
].
filters
,
pColInfo
->
numOfFilters
);
}
}
pQuery
->
tagColList
=
pTagCols
;
pQuery
->
tagColList
=
pTagCols
;
...
...
src/query/src/queryFilterFunc.c
浏览文件 @
01846142
...
@@ -183,33 +183,33 @@ bool equal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
...
@@ -183,33 +183,33 @@ bool equal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
bool
equal_str
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
bool
equal_str
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
// query condition string is greater than the max length of string, not qualified data
// query condition string is greater than the max length of string, not qualified data
if
(
pFilter
->
filterInfo
.
len
>
pFilter
->
bytes
)
{
if
(
pFilter
->
filterInfo
.
len
!=
varDataLen
(
minval
)
)
{
return
false
;
return
false
;
}
}
return
strncmp
((
char
*
)
pFilter
->
filterInfo
.
pz
,
minval
,
pFilter
->
bytes
)
==
0
;
return
strncmp
((
char
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
)
)
==
0
;
}
}
bool
equal_nchar
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
bool
equal_nchar
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
// query condition string is greater than the max length of string, not qualified data
// query condition string is greater than the max length of string, not qualified data
if
(
pFilter
->
filterInfo
.
len
>
pFilter
->
bytes
)
{
if
(
pFilter
->
filterInfo
.
len
!=
varDataLen
(
minval
)
)
{
return
false
;
return
false
;
}
}
return
wcsncmp
((
wchar_t
*
)
pFilter
->
filterInfo
.
pz
,
(
wchar_t
*
)
minval
,
pFilter
->
bytes
/
TSDB_NCHAR_SIZE
)
==
0
;
return
wcsncmp
((
wchar_t
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
)
/
TSDB_NCHAR_SIZE
)
==
0
;
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
bool
like_str
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
bool
like_str
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
return
patternMatch
((
char
*
)
pFilter
->
filterInfo
.
pz
,
minval
,
pFilter
->
bytes
,
&
info
)
==
TSDB_PATTERN_MATCH
;
return
patternMatch
((
char
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
)
,
&
info
)
==
TSDB_PATTERN_MATCH
;
}
}
bool
like_nchar
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
bool
like_nchar
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
SPatternCompareInfo
info
=
PATTERN_COMPARE_INFO_INITIALIZER
;
return
WCSPatternMatch
((
wchar_t
*
)
pFilter
->
filterInfo
.
pz
,
(
wchar_t
*
)
minval
,
pFilter
->
bytes
/
TSDB_NCHAR_SIZE
,
&
info
)
==
TSDB_PATTERN_MATCH
;
return
WCSPatternMatch
((
wchar_t
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
)
/
TSDB_NCHAR_SIZE
,
&
info
)
==
TSDB_PATTERN_MATCH
;
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
...
@@ -270,11 +270,11 @@ bool nequal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
...
@@ -270,11 +270,11 @@ bool nequal_dd(SColumnFilterElem *pFilter, char *minval, char *maxval) {
}
}
bool
nequal_str
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
bool
nequal_str
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
if
(
pFilter
->
filterInfo
.
len
>
pFilter
->
bytes
)
{
if
(
pFilter
->
filterInfo
.
len
!=
varDataLen
(
minval
)
)
{
return
true
;
return
true
;
}
}
return
strncmp
((
char
*
)
pFilter
->
filterInfo
.
pz
,
minval
,
pFilter
->
bytes
)
!=
0
;
return
strncmp
((
char
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
)
)
!=
0
;
}
}
bool
nequal_nchar
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
bool
nequal_nchar
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
)
{
...
@@ -282,7 +282,7 @@ bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) {
...
@@ -282,7 +282,7 @@ bool nequal_nchar(SColumnFilterElem *pFilter, char* minval, char *maxval) {
return
true
;
return
true
;
}
}
return
wcsncmp
((
wchar_t
*
)
pFilter
->
filterInfo
.
pz
,
(
wchar_t
*
)
minval
,
pFilter
->
bytes
/
TSDB_NCHAR_SIZE
)
!=
0
;
return
wcsncmp
((
wchar_t
*
)
pFilter
->
filterInfo
.
pz
,
varDataVal
(
minval
),
varDataLen
(
minval
)
/
TSDB_NCHAR_SIZE
)
!=
0
;
}
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
01846142
...
@@ -234,7 +234,6 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable) {
...
@@ -234,7 +234,6 @@ STSchema * tsdbGetTableTagSchema(STsdbMeta *pMeta, STable *pTable) {
}
}
}
}
// todo refactor table name definition
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
);
STsdbMeta
*
pMeta
=
tsdbGetMeta
(
repo
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
STable
*
pTable
=
tsdbGetTableByUid
(
pMeta
,
id
->
uid
);
...
@@ -242,6 +241,7 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t
...
@@ -242,6 +241,7 @@ int32_t tsdbGetTableTagVal(TsdbRepoT* repo, STableId* id, int32_t colId, int16_t
STSchema
*
pSchema
=
tsdbGetTableTagSchema
(
pMeta
,
pTable
);
STSchema
*
pSchema
=
tsdbGetTableTagSchema
(
pMeta
,
pTable
);
STColumn
*
pCol
=
NULL
;
STColumn
*
pCol
=
NULL
;
// todo binary search
for
(
int32_t
col
=
0
;
col
<
schemaNCols
(
pSchema
);
++
col
)
{
for
(
int32_t
col
=
0
;
col
<
schemaNCols
(
pSchema
);
++
col
)
{
STColumn
*
p
=
schemaColAt
(
pSchema
,
col
);
STColumn
*
p
=
schemaColAt
(
pSchema
,
col
);
if
(
p
->
colId
==
colId
)
{
if
(
p
->
colId
==
colId
)
{
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
01846142
...
@@ -1432,7 +1432,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
...
@@ -1432,7 +1432,7 @@ SArray* createTableGroup(SArray* pTableList, STSchema* pTagSchema, SColIndex* pC
return
pTableGroup
;
return
pTableGroup
;
}
}
bool
tSkipListNodeFilterCallback
(
const
void
*
pNode
,
void
*
param
)
{
bool
indexedNodeFilterFp
(
const
void
*
pNode
,
void
*
param
)
{
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
tQueryInfo
*
pInfo
=
(
tQueryInfo
*
)
param
;
STableIndexElem
*
elem
=
(
STableIndexElem
*
)(
SL_GET_NODE_DATA
((
SSkipListNode
*
)
pNode
));
STableIndexElem
*
elem
=
(
STableIndexElem
*
)(
SL_GET_NODE_DATA
((
SSkipListNode
*
)
pNode
));
...
@@ -1497,7 +1497,7 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
...
@@ -1497,7 +1497,7 @@ bool tSkipListNodeFilterCallback(const void* pNode, void* param) {
static
int32_t
doQueryTableList
(
STable
*
pSTable
,
SArray
*
pRes
,
tExprNode
*
pExpr
)
{
static
int32_t
doQueryTableList
(
STable
*
pSTable
,
SArray
*
pRes
,
tExprNode
*
pExpr
)
{
// query according to the expression tree
// query according to the expression tree
SExprTraverseSupp
supp
=
{
SExprTraverseSupp
supp
=
{
.
fp
=
(
__result_filter_fn_t
)
tSkipListNodeFilterCallback
,
.
nodeFilterFn
=
(
__result_filter_fn_t
)
indexedNodeFilterFp
,
.
setupInfoFn
=
filterPrepare
,
.
setupInfoFn
=
filterPrepare
,
.
pExtInfo
=
pSTable
->
tagSchema
,
.
pExtInfo
=
pSTable
->
tagSchema
,
};
};
...
...
src/util/src/tcompare.c
浏览文件 @
01846142
...
@@ -51,12 +51,21 @@ int32_t compareDoubleIntVal(const void *pLeft, const void *pRight) {
...
@@ -51,12 +51,21 @@ int32_t compareDoubleIntVal(const void *pLeft, const void *pRight) {
}
}
}
}
int32_t
compareFloatVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
float
ret
=
GET_FLOAT_VAL
(
pLeft
)
-
GET_FLOAT_VAL
(
pRight
);
if
(
fabs
(
ret
)
<
FLT_EPSILON
)
{
return
0
;
}
else
{
return
ret
>
0
?
1
:
-
1
;
}
}
int32_t
compareDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareDoubleVal
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
double
ret
=
GET_DOUBLE_VAL
(
pLeft
)
-
GET_DOUBLE_VAL
(
pRight
);
double
ret
=
GET_DOUBLE_VAL
(
pLeft
)
-
GET_DOUBLE_VAL
(
pRight
);
if
(
fabs
(
ret
)
<
FLT_EPSILON
)
{
if
(
fabs
(
ret
)
<
FLT_EPSILON
)
{
return
0
;
return
0
;
}
else
{
}
else
{
return
ret
>
0
?
1
:
-
1
;
return
ret
>
0
?
1
:
-
1
;
}
}
}
}
...
@@ -175,7 +184,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
...
@@ -175,7 +184,7 @@ int WCSPatternMatch(const wchar_t *patterStr, const wchar_t *str, size_t size, c
wchar_t
accept
[
3
]
=
{
towupper
(
c
),
towlower
(
c
),
0
};
wchar_t
accept
[
3
]
=
{
towupper
(
c
),
towlower
(
c
),
0
};
while
(
1
)
{
while
(
1
)
{
size_t
n
=
wcsspn
(
str
,
accept
);
size_t
n
=
wcs
c
spn
(
str
,
accept
);
str
+=
n
;
str
+=
n
;
if
(
str
[
0
]
==
0
||
(
n
>=
size
-
1
))
{
if
(
str
[
0
]
==
0
||
(
n
>=
size
-
1
))
{
...
@@ -257,7 +266,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
...
@@ -257,7 +266,7 @@ __compar_fn_t getComparFunc(int32_t type, int32_t optr) {
}
}
case
TSDB_DATA_TYPE_FLOAT
:
{
case
TSDB_DATA_TYPE_FLOAT
:
{
comparFn
=
compare
Double
Val
;
break
;
comparFn
=
compare
Float
Val
;
break
;
}
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
case
TSDB_DATA_TYPE_DOUBLE
:
{
...
@@ -313,6 +322,8 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) {
...
@@ -313,6 +322,8 @@ __compar_fn_t getKeyComparFunc(int32_t keyType) {
comparFn
=
compareInt64Val
;
comparFn
=
compareInt64Val
;
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
comparFn
=
compareFloatVal
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
comparFn
=
compareDoubleVal
;
comparFn
=
compareDoubleVal
;
break
;
break
;
...
...
tests/script/general/tag/create.sim
浏览文件 @
01846142
...
@@ -134,7 +134,8 @@ if $data01 != 1 then
...
@@ -134,7 +134,8 @@ if $data01 != 1 then
return -1
return -1
endi
endi
sql select * from $mt where tgcol = 0
sql select * from $mt where tgcol = 0
if $rows != 0 then
if $rows != 0 then
print expect 0, actual: $rows
return -1
return -1
endi
endi
...
@@ -184,7 +185,8 @@ sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool)
...
@@ -184,7 +185,8 @@ sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol bool, tgcol2 bool)
sql create table $tb using $mt tags( 1, 2 )
sql create table $tb using $mt tags( 1, 2 )
sql insert into $tb values(now, 1)
sql insert into $tb values(now, 1)
sql select * from $mt where tgcol2 = 2
sql select * from $mt where tgcol2 = 2
if $rows != 1 then
if $rows != 1 then
print expect 1, actual: $rows
return -1
return -1
endi
endi
if $data01 != 1 then
if $data01 != 1 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录