Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
36b10f26
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看板
“178183e4ae4f1f2e7e8bb1b405bd30464357fbd9”上不存在“docs/examples/c/telnet_line_example.c”
提交
36b10f26
编写于
9月 27, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-6129<feature> add tag-> where logic
上级
3da78052
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
145 addition
and
57 deletion
+145
-57
src/client/CMakeLists.txt
src/client/CMakeLists.txt
+1
-0
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+4
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+1
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+60
-8
src/common/inc/tvariant.h
src/common/inc/tvariant.h
+2
-0
src/common/src/tvariant.c
src/common/src/tvariant.c
+30
-1
src/inc/taoserror.h
src/inc/taoserror.h
+2
-1
src/inc/tsdb.h
src/inc/tsdb.h
+1
-0
src/query/inc/qFilter.h
src/query/inc/qFilter.h
+2
-1
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+0
-1
src/query/src/qFilter.c
src/query/src/qFilter.c
+25
-10
src/query/src/qUtil.c
src/query/src/qUtil.c
+1
-1
src/tsdb/CMakeLists.txt
src/tsdb/CMakeLists.txt
+1
-0
src/tsdb/inc/tsdbMeta.h
src/tsdb/inc/tsdbMeta.h
+1
-1
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+3
-3
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+11
-29
未找到文件。
src/client/CMakeLists.txt
浏览文件 @
36b10f26
...
@@ -3,6 +3,7 @@ PROJECT(TDengine)
...
@@ -3,6 +3,7 @@ PROJECT(TDengine)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
jni
)
INCLUDE_DIRECTORIES
(
jni
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/tsdb/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/zlib-1.2.11/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/zlib-1.2.11/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/plugins/http/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/plugins/http/inc
)
...
...
src/client/inc/tscUtil.h
浏览文件 @
36b10f26
...
@@ -29,6 +29,7 @@ extern "C" {
...
@@ -29,6 +29,7 @@ extern "C" {
#include "tsched.h"
#include "tsched.h"
#include "tsclient.h"
#include "tsclient.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tsdbMeta.h"
#define UTIL_TABLE_IS_SUPER_TABLE(metaInfo) \
#define UTIL_TABLE_IS_SUPER_TABLE(metaInfo) \
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_SUPER_TABLE))
(((metaInfo)->pTableMeta != NULL) && ((metaInfo)->pTableMeta->tableType == TSDB_SUPER_TABLE))
...
@@ -379,6 +380,9 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
...
@@ -379,6 +380,9 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
char
*
parseTagDatatoJson
(
void
*
p
);
char
*
parseTagDatatoJson
(
void
*
p
);
void
findTagValue
(
void
*
data
,
char
*
key
,
int32_t
keyLen
,
char
*
out
,
int16_t
len
);
void
findTagValue
(
void
*
data
,
char
*
key
,
int32_t
keyLen
,
char
*
out
,
int16_t
len
);
int8_t
jsonType2DbType
(
double
data
,
int
jsonType
);
void
*
getJsonTagValue
(
STable
*
pTable
,
char
*
key
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/client/src/tscSQLParser.c
浏览文件 @
36b10f26
...
@@ -5110,7 +5110,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
...
@@ -5110,7 +5110,7 @@ static int32_t getTagQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SCondE
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
SArray
*
colList
=
taosArrayInit
(
10
,
sizeof
(
SColIndex
));
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
pQueryInfo
,
colList
,
NULL
);
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
p
,
p1
,
pQueryInfo
,
colList
,
NULL
);
//if (ret == TSDB_CODE_SUCCESS) {
//if (ret == TSDB_CODE_SUCCESS) {
// ret = filterInitFromTree(p, &pQueryInfo->tagFilter, (int32_t)taosArrayGetSize(colList));
// ret = filterInitFromTree(p, &pQueryInfo->tagFilter, (int32_t)taosArrayGetSize(colList)
, NULL
);
//}
//}
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
SBufferWriter
bw
=
tbufInitWriter
(
NULL
,
false
);
...
...
src/client/src/tscUtil.c
浏览文件 @
36b10f26
...
@@ -73,7 +73,6 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le
...
@@ -73,7 +73,6 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
if
(
bufSize
<
0
)
{
if
(
bufSize
<
0
)
{
tscError
(
"invalid buf size"
);
tscError
(
"invalid buf size"
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
...
@@ -5271,10 +5270,11 @@ char* parseTagDatatoJson(void *p){
...
@@ -5271,10 +5270,11 @@ char* parseTagDatatoJson(void *p){
}
else
{
// json value
}
else
{
// json value
char
tagJsonValue
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
tagJsonValue
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
*
realData
=
POINTER_SHIFT
(
val
,
CHAR_BYTES
);
char
*
realData
=
POINTER_SHIFT
(
val
,
CHAR_BYTES
);
if
(
*
(
char
*
)
val
==
cJSON_String
){
char
type
=
*
(
char
*
)
val
;
if
(
JSON_TYPE_BINARY
){
if
(
IS_VAR_DATA_TYPE
(
type
)){
if
(
type
==
TSDB_DATA_TYPE_BINARY
){
strncpy
(
tagJsonValue
,
varDataVal
(
realData
),
varDataLen
(
realData
));
strncpy
(
tagJsonValue
,
varDataVal
(
realData
),
varDataLen
(
realData
));
}
else
if
(
JSON
_TYPE_NCHAR
)
{
}
else
if
(
type
==
TSDB_DATA
_TYPE_NCHAR
)
{
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
tagJsonValue
);
int32_t
length
=
taosUcs4ToMbs
(
varDataVal
(
realData
),
varDataLen
(
realData
),
tagJsonValue
);
if
(
length
==
0
)
{
if
(
length
==
0
)
{
tscError
(
"charset:%s to %s. val:%s convert json value failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
tscError
(
"charset:%s to %s. val:%s convert json value failed."
,
DEFAULT_UNICODE_ENCODEC
,
tsCharset
,
...
@@ -5288,7 +5288,7 @@ char* parseTagDatatoJson(void *p){
...
@@ -5288,7 +5288,7 @@ char* parseTagDatatoJson(void *p){
goto
end
;
goto
end
;
}
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
if
(
*
(
char
*
)
val
==
cJSON_Number
){
}
else
if
(
type
==
TSDB_DATA_TYPE_DOUBLE
){
double
jsonVd
=
*
(
double
*
)(
realData
);
double
jsonVd
=
*
(
double
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateNumber
(
jsonVd
);
cJSON
*
value
=
cJSON_CreateNumber
(
jsonVd
);
if
(
value
==
NULL
)
if
(
value
==
NULL
)
...
@@ -5296,7 +5296,16 @@ char* parseTagDatatoJson(void *p){
...
@@ -5296,7 +5296,16 @@ char* parseTagDatatoJson(void *p){
goto
end
;
goto
end
;
}
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
{
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
){
int64_t
jsonVd
=
*
(
int64_t
*
)(
realData
);
cJSON
*
value
=
cJSON_CreateNumber
(
jsonVd
);
if
(
value
==
NULL
)
{
goto
end
;
}
cJSON_AddItemToObject
(
json
,
tagJsonKey
,
value
);
}
else
{
tscError
(
"unsupportted json value"
);
tscError
(
"unsupportted json value"
);
}
}
}
}
...
@@ -5355,7 +5364,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
...
@@ -5355,7 +5364,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
memset
(
tagVal
,
0
,
TSDB_MAX_TAGS_LEN
);
memset
(
tagVal
,
0
,
TSDB_MAX_TAGS_LEN
);
if
(
item
->
type
==
cJSON_String
){
// add json value format: type|data
if
(
item
->
type
==
cJSON_String
){
// add json value format: type|data
outLen
=
0
;
outLen
=
0
;
*
tagVal
=
item
->
type
;
// type
*
tagVal
=
jsonType2DbType
(
0
,
item
->
type
)
;
// type
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
);
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
);
if
(
JSON_TYPE_BINARY
){
if
(
JSON_TYPE_BINARY
){
strncpy
(
tagVal
,
item
->
valuestring
,
strlen
(
item
->
valuestring
));
strncpy
(
tagVal
,
item
->
valuestring
,
strlen
(
item
->
valuestring
));
...
@@ -5372,7 +5381,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
...
@@ -5372,7 +5381,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
varDataSetLen
(
tagData
,
outLen
);
varDataSetLen
(
tagData
,
outLen
);
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_NCHAR
,
tagVal
,
true
);
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_NCHAR
,
tagVal
,
true
);
}
else
if
(
item
->
type
==
cJSON_Number
){
}
else
if
(
item
->
type
==
cJSON_Number
){
*
tagVal
=
item
->
type
;
// type
*
tagVal
=
jsonType2DbType
(
item
->
valuedouble
,
item
->
type
)
;
// type
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
);
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
);
*
((
double
*
)
tagData
)
=
item
->
valuedouble
;
*
((
double
*
)
tagData
)
=
item
->
valuedouble
;
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_BIGINT
,
tagVal
,
true
);
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_BIGINT
,
tagVal
,
true
);
...
@@ -5386,3 +5395,46 @@ end:
...
@@ -5386,3 +5395,46 @@ end:
cJSON_Delete
(
root
);
cJSON_Delete
(
root
);
return
retCode
;
return
retCode
;
}
}
int8_t
jsonType2DbType
(
double
data
,
int
jsonType
){
switch
(
jsonType
){
case
cJSON_Number
:
if
(
data
-
(
int64_t
)
data
>
0
)
return
TSDB_DATA_TYPE_DOUBLE
;
else
return
TSDB_DATA_TYPE_BIGINT
;
case
cJSON_String
:
if
(
JSON_TYPE_NCHAR
)
return
TSDB_DATA_TYPE_NCHAR
;
else
return
TSDB_DATA_TYPE_BINARY
;
}
return
TSDB_DATA_TYPE_NULL
;
}
void
*
getJsonTagValue
(
STable
*
pTable
,
char
*
key
){
int32_t
outLen
=
0
;
if
(
JSON_TYPE_NCHAR
){
char
tagKey
[
256
]
=
{
0
};
if
(
!
taosMbsToUcs4
(
key
,
strlen
(
key
),
tagKey
,
256
,
&
outLen
))
{
tscError
(
"json key to ucs4 error:%s|%s"
,
strerror
(
errno
),
key
);
return
NULL
;
}
key
=
tagKey
;
}
else
{
outLen
=
strlen
(
key
);
}
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_CHILD_TABLE
){
STable
*
superTable
=
pTable
->
pSuper
;
SArray
**
data
=
(
SArray
**
)
taosHashGet
(
superTable
->
jsonKeyMap
,
key
,
outLen
);
if
(
data
==
NULL
)
return
NULL
;
JsonMapValue
jmvalue
=
{
pTable
,
0
};
JsonMapValue
*
p
=
taosArraySearch
(
*
data
,
&
jmvalue
,
tsdbCompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
return
NULL
;
int16_t
valId
=
p
->
colId
+
1
;
return
POINTER_SHIFT
(
kvRowValues
(
pTable
->
tagVal
),
valId
);
}
else
if
(
TABLE_TYPE
(
pTable
)
==
TSDB_SUPER_TABLE
){
SArray
**
data
=
(
SArray
**
)
taosHashGet
(
pTable
->
jsonKeyMap
,
key
,
outLen
);
if
(
data
==
NULL
)
return
NULL
;
if
(
taosArrayGetSize
(
*
data
)
==
0
)
return
NULL
;
JsonMapValue
*
p
=
taosArrayGet
(
*
data
,
0
);
int16_t
valId
=
p
->
colId
+
1
;
return
POINTER_SHIFT
(
kvRowValues
(((
STable
*
)
p
->
table
)
->
tagVal
),
valId
);
}
return
NULL
;
}
src/common/inc/tvariant.h
浏览文件 @
36b10f26
...
@@ -39,6 +39,8 @@ typedef struct tVariant {
...
@@ -39,6 +39,8 @@ typedef struct tVariant {
bool
tVariantIsValid
(
tVariant
*
pVar
);
bool
tVariantIsValid
(
tVariant
*
pVar
);
bool
tVariantTypeMatch
(
tVariant
*
pVar
,
int8_t
dbType
);
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
);
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
);
void
tVariantCreateFromBinary
(
tVariant
*
pVar
,
const
char
*
pz
,
size_t
len
,
uint32_t
type
);
void
tVariantCreateFromBinary
(
tVariant
*
pVar
,
const
char
*
pz
,
size_t
len
,
uint32_t
type
);
...
...
src/common/src/tvariant.c
浏览文件 @
36b10f26
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "ttype.h"
#include "ttype.h"
#include "tutil.h"
#include "tutil.h"
#include "tvariant.h"
#include "tvariant.h"
#include "tscUtil.h"
#define SET_EXT_INFO(converted, res, minv, maxv, exti) do { \
#define SET_EXT_INFO(converted, res, minv, maxv, exti) do { \
if (converted == NULL || exti == NULL || *converted == false) { break; } \
if (converted == NULL || exti == NULL || *converted == false) { break; } \
...
@@ -212,6 +211,36 @@ bool tVariantIsValid(tVariant *pVar) {
...
@@ -212,6 +211,36 @@ bool tVariantIsValid(tVariant *pVar) {
return
isValidDataType
(
pVar
->
nType
);
return
isValidDataType
(
pVar
->
nType
);
}
}
bool
tVariantTypeMatch
(
tVariant
*
pVar
,
int8_t
dbType
){
switch
(
dbType
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
pVar
->
nType
!=
TSDB_DATA_TYPE_BINARY
&&
pVar
->
nType
!=
TSDB_DATA_TYPE_NCHAR
){
return
false
;
}
break
;
}
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:{
if
(
pVar
->
nType
==
TSDB_DATA_TYPE_BINARY
&&
pVar
->
nType
==
TSDB_DATA_TYPE_NCHAR
){
return
false
;
}
break
;
}
}
return
true
;
}
void
tVariantAssign
(
tVariant
*
pDst
,
const
tVariant
*
pSrc
)
{
void
tVariantAssign
(
tVariant
*
pDst
,
const
tVariant
*
pSrc
)
{
if
(
pSrc
==
NULL
||
pDst
==
NULL
)
return
;
if
(
pSrc
==
NULL
||
pDst
==
NULL
)
return
;
...
...
src/inc/taoserror.h
浏览文件 @
36b10f26
...
@@ -288,7 +288,8 @@ int32_t* taosGetErrno();
...
@@ -288,7 +288,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C) //"File inconsistency in replica")
#define TSDB_CODE_QRY_INCONSISTAN TAOS_DEF_ERROR_CODE(0, 0x070C) //"File inconsistency in replica")
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D) //"invalid time condition")
#define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070D) //"invalid time condition")
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E) //"System error")
#define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070E) //"System error")
#define TSDB_CODE_QRY_JSON_KEY_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x070F) //"json tag key not exist")
#define TSDB_CODE_QRY_JSON_KEY_TYPE_ERROR TAOS_DEF_ERROR_CODE(0, 0x0710) //"json tag key type not match")
// grant
// grant
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) //"License expired")
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800) //"License expired")
...
...
src/inc/tsdb.h
浏览文件 @
36b10f26
...
@@ -418,6 +418,7 @@ int tsdbCompact(STsdbRepo *pRepo);
...
@@ -418,6 +418,7 @@ int tsdbCompact(STsdbRepo *pRepo);
// no problem return true
// no problem return true
bool
tsdbNoProblem
(
STsdbRepo
*
pRepo
);
bool
tsdbNoProblem
(
STsdbRepo
*
pRepo
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
src/query/inc/qFilter.h
浏览文件 @
36b10f26
...
@@ -245,7 +245,8 @@ typedef struct SFilterInfo {
...
@@ -245,7 +245,8 @@ typedef struct SFilterInfo {
uint16_t
blkGroupNum
;
uint16_t
blkGroupNum
;
uint16_t
*
blkUnits
;
uint16_t
*
blkUnits
;
int8_t
*
blkUnitRes
;
int8_t
*
blkUnitRes
;
void
*
pTable
;
SFilterPCtx
pctx
;
SFilterPCtx
pctx
;
}
SFilterInfo
;
}
SFilterInfo
;
...
...
src/query/inc/qUtil.h
浏览文件 @
36b10f26
...
@@ -109,5 +109,4 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo);
...
@@ -109,5 +109,4 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo);
int32_t
mergeIntoGroupResult
(
SGroupResInfo
*
pGroupResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
*
offset
);
int32_t
mergeIntoGroupResult
(
SGroupResInfo
*
pGroupResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
*
offset
);
int32_t
initUdfInfo
(
SUdfInfo
*
pUdfInfo
);
int32_t
initUdfInfo
(
SUdfInfo
*
pUdfInfo
);
#endif // TDENGINE_QUERYUTIL_H
#endif // TDENGINE_QUERYUTIL_H
src/query/src/qFilter.c
浏览文件 @
36b10f26
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "tcompare.h"
#include "tcompare.h"
#include "hash.h"
#include "hash.h"
#include "tscUtil.h"
#include "tscUtil.h"
#include "tsdbMeta.h"
OptrStr
gOptrStr
[]
=
{
OptrStr
gOptrStr
[]
=
{
{
TSDB_RELATION_INVALID
,
"invalid"
},
{
TSDB_RELATION_INVALID
,
"invalid"
},
...
@@ -3174,21 +3175,31 @@ int32_t filterSetJsonColFieldData(SFilterInfo *info, void *param, filer_get_col_
...
@@ -3174,21 +3175,31 @@ int32_t filterSetJsonColFieldData(SFilterInfo *info, void *param, filer_get_col_
}
}
// convert json type for next compare and so on
// convert json type for next compare and so on
void
filterJsonTypeConvert
(
SFilterInfo
*
info
)
{
int
filterJsonTypeConvert
(
SFilterInfo
*
info
)
{
uint8_t
type
=
0
;
if
(
JSON_TYPE_NCHAR
){
type
=
TSDB_DATA_TYPE_NCHAR
;}
else
{
type
=
TSDB_DATA_TYPE_BINARY
;}
for
(
int
i
=
0
;
i
<
info
->
unitNum
;
i
++
){
if
(
info
->
units
[
i
].
compare
.
type
==
TSDB_DATA_TYPE_JSON
){
info
->
units
[
i
].
compare
.
type
=
type
;
}
}
for
(
int
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
i
++
)
{
for
(
int
i
=
0
;
i
<
info
->
fields
[
FLD_TYPE_COLUMN
].
num
;
i
++
)
{
SSchema
*
schema
=
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
].
desc
;
SSchema
*
schema
=
info
->
fields
[
FLD_TYPE_COLUMN
].
fields
[
i
].
desc
;
if
(
schema
->
type
==
TSDB_DATA_TYPE_JSON
){
if
(
schema
->
type
==
TSDB_DATA_TYPE_JSON
){
void
*
data
=
getJsonTagValue
(
info
->
pTable
,
schema
->
name
);
if
(
data
==
NULL
)
return
TSDB_CODE_QRY_JSON_KEY_NOT_EXIST
;
int8_t
type
=
*
(
char
*
)
data
;
assert
(
type
>
TSDB_DATA_TYPE_NULL
&&
type
<
TSDB_DATA_TYPE_JSON
);
schema
->
type
=
type
;
schema
->
type
=
type
;
}
}
}
}
for
(
int
i
=
0
;
i
<
info
->
unitNum
;
i
++
){
if
(
info
->
units
[
i
].
compare
.
type
==
TSDB_DATA_TYPE_JSON
){
SFilterField
*
colLeft
=
FILTER_UNIT_LEFT_FIELD
(
info
,
&
info
->
units
[
i
]);
info
->
units
[
i
].
compare
.
type
=
FILTER_GET_COL_FIELD_TYPE
(
colLeft
);
SFilterField
*
colRight
=
FILTER_UNIT_RIGHT_FIELD
(
info
,
&
info
->
units
[
i
]);
tVariant
*
var
=
colRight
->
desc
;
if
(
!
tVariantTypeMatch
(
var
,
info
->
units
[
i
].
compare
.
type
))
return
TSDB_CODE_QRY_JSON_KEY_TYPE_ERROR
;
}
}
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
void
**
pinfo
,
uint32_t
options
)
{
int32_t
filterInitFromTree
(
tExprNode
*
tree
,
void
**
pinfo
,
uint32_t
options
)
{
...
@@ -3211,7 +3222,11 @@ int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) {
...
@@ -3211,7 +3222,11 @@ int32_t filterInitFromTree(tExprNode* tree, void **pinfo, uint32_t options) {
code
=
filterTreeToGroup
(
tree
,
info
,
group
);
code
=
filterTreeToGroup
(
tree
,
info
,
group
);
ERR_JRET
(
code
);
ERR_JRET
(
code
);
filterJsonTypeConvert
(
info
);
if
(
info
->
pTable
){
code
=
filterJsonTypeConvert
(
info
);
ERR_JRET
(
code
);
}
filterConvertGroupFromArray
(
info
,
group
);
filterConvertGroupFromArray
(
info
,
group
);
...
...
src/query/src/qUtil.c
浏览文件 @
36b10f26
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
#include "tlosertree.h"
#include "tlosertree.h"
#include "queryLog.h"
#include "queryLog.h"
#include "tscompression.h"
#include "tscompression.h"
#include "tsdbMeta.h"
#include "tscUtil.h"
#include "tscUtil.h"
#include "cJSON.h"
typedef
struct
SCompSupporter
{
typedef
struct
SCompSupporter
{
STableQueryInfo
**
pTableQueryInfo
;
STableQueryInfo
**
pTableQueryInfo
;
...
...
src/tsdb/CMakeLists.txt
浏览文件 @
36b10f26
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
...
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8...3.20)
PROJECT
(
TDengine
)
PROJECT
(
TDengine
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/client/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/src/query/inc
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_LIBRARY
(
tsdb
${
SRC
}
)
ADD_LIBRARY
(
tsdb
${
SRC
}
)
...
...
src/tsdb/inc/tsdbMeta.h
浏览文件 @
36b10f26
...
@@ -97,7 +97,7 @@ int16_t tsdbGetLastColumnsIndexByColId(STable* pTable, int16_t colId);
...
@@ -97,7 +97,7 @@ int16_t tsdbGetLastColumnsIndexByColId(STable* pTable, int16_t colId);
int
tsdbUpdateLastColSchema
(
STable
*
pTable
,
STSchema
*
pNewSchema
);
int
tsdbUpdateLastColSchema
(
STable
*
pTable
,
STSchema
*
pNewSchema
);
STSchema
*
tsdbGetTableLatestSchema
(
STable
*
pTable
);
STSchema
*
tsdbGetTableLatestSchema
(
STable
*
pTable
);
void
tsdbFreeLastColumns
(
STable
*
pTable
);
void
tsdbFreeLastColumns
(
STable
*
pTable
);
int
ts
c
CompareJsonMapValue
(
const
void
*
a
,
const
void
*
b
);
int
ts
db
CompareJsonMapValue
(
const
void
*
a
,
const
void
*
b
);
static
FORCE_INLINE
int
tsdbCompareSchemaVersion
(
const
void
*
key1
,
const
void
*
key2
)
{
static
FORCE_INLINE
int
tsdbCompareSchemaVersion
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(
*
(
int16_t
*
)
key1
<
schemaVersion
(
*
(
STSchema
**
)
key2
))
{
if
(
*
(
int16_t
*
)
key1
<
schemaVersion
(
*
(
STSchema
**
)
key2
))
{
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
36b10f26
...
@@ -1141,9 +1141,9 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable, bool refSuper
...
@@ -1141,9 +1141,9 @@ static int tsdbAddTableIntoIndex(STsdbMeta *pMeta, STable *pTable, bool refSuper
}
}
}
}
JsonMapValue
jmvalue
=
{
pTable
,
pColIdx
->
colId
};
JsonMapValue
jmvalue
=
{
pTable
,
pColIdx
->
colId
};
void
*
p
=
taosArraySearch
(
tablistNew
,
&
jmvalue
,
ts
c
CompareJsonMapValue
,
TD_EQ
);
void
*
p
=
taosArraySearch
(
tablistNew
,
&
jmvalue
,
ts
db
CompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
p
=
taosArraySearch
(
tablistNew
,
&
jmvalue
,
ts
c
CompareJsonMapValue
,
TD_GE
);
p
=
taosArraySearch
(
tablistNew
,
&
jmvalue
,
ts
db
CompareJsonMapValue
,
TD_GE
);
if
(
p
==
NULL
){
if
(
p
==
NULL
){
taosArrayPush
(
tablistNew
,
&
jmvalue
);
taosArrayPush
(
tablistNew
,
&
jmvalue
);
}
else
{
}
else
{
...
@@ -1188,7 +1188,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
...
@@ -1188,7 +1188,7 @@ static int tsdbRemoveTableFromIndex(STsdbMeta *pMeta, STable *pTable) {
}
}
JsonMapValue
jmvalue
=
{
pTable
,
pColIdx
->
colId
};
JsonMapValue
jmvalue
=
{
pTable
,
pColIdx
->
colId
};
void
*
p
=
taosArraySearch
(
*
tablist
,
&
jmvalue
,
ts
c
CompareJsonMapValue
,
TD_EQ
);
void
*
p
=
taosArraySearch
(
*
tablist
,
&
jmvalue
,
ts
db
CompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
tsdbError
(
"json tag no tableid error,%d"
,
j
);
tsdbError
(
"json tag no tableid error,%d"
,
j
);
continue
;
continue
;
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
36b10f26
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "tsdbint.h"
#include "tsdbint.h"
#include "texpr.h"
#include "texpr.h"
#include "qFilter.h"
#include "qFilter.h"
#include "tscUtil.h"
#define EXTRA_BYTES 2
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
@@ -2685,7 +2686,7 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
...
@@ -2685,7 +2686,7 @@ static int32_t getAllTableList(STable* pSuperTable, SArray* list) {
SArray
*
tallistOld
=
*
pRecord
;
SArray
*
tallistOld
=
*
pRecord
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tallistOld
);
++
i
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tallistOld
);
++
i
)
{
void
*
p
=
taosArrayGet
(
tallistOld
,
i
);
void
*
p
=
taosArrayGet
(
tallistOld
,
i
);
void
*
pFind
=
taosArraySearch
(
tablist
,
p
,
ts
c
CompareJsonMapValue
,
TD_EQ
);
void
*
pFind
=
taosArraySearch
(
tablist
,
p
,
ts
db
CompareJsonMapValue
,
TD_EQ
);
if
(
pFind
==
NULL
){
if
(
pFind
==
NULL
){
taosArrayPush
(
tablist
,
p
);
taosArrayPush
(
tablist
,
p
);
}
}
...
@@ -3774,9 +3775,11 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
...
@@ -3774,9 +3775,11 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
// TODO: more error handling
// TODO: more error handling
}
END_TRY
}
END_TRY
void
*
filterInfo
=
NULL
;
void
*
filterInfo
=
calloc
(
1
,
sizeof
(
SFilterInfo
));
((
SFilterInfo
*
)
filterInfo
)
->
pTable
=
pTable
;
ret
=
filterInitFromTree
(
expr
,
&
filterInfo
,
0
);
ret
=
filterInitFromTree
(
expr
,
&
filterInfo
,
0
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
filterFreeInfo
(
filterInfo
);
terrno
=
ret
;
terrno
=
ret
;
goto
_error
;
goto
_error
;
}
}
...
@@ -3799,6 +3802,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
...
@@ -3799,6 +3802,7 @@ int32_t tsdbQuerySTableByTagCond(STsdbRepo* tsdb, uint64_t uid, TSKEY skey, cons
return
ret
;
return
ret
;
_error:
_error:
taosArrayDestroy
(
res
);
taosArrayDestroy
(
res
);
return
terrno
;
return
terrno
;
}
}
...
@@ -4064,30 +4068,6 @@ static void queryIndexlessColumn(SSkipList* pSkipList, void* filterInfo, SArray*
...
@@ -4064,30 +4068,6 @@ static void queryIndexlessColumn(SSkipList* pSkipList, void* filterInfo, SArray*
tSkipListDestroyIter
(
iter
);
tSkipListDestroyIter
(
iter
);
}
}
void
*
getJsonTagValue
(
STable
*
pTable
,
char
*
key
){
assert
(
TABLE_TYPE
(
pTable
)
==
TSDB_CHILD_TABLE
);
int32_t
outLen
=
0
;
if
(
JSON_TYPE_NCHAR
){
char
tagKey
[
256
]
=
{
0
};
if
(
!
taosMbsToUcs4
(
key
,
strlen
(
key
),
tagKey
,
256
,
&
outLen
))
{
tsdbError
(
"json key to ucs4 error:%s|%s"
,
strerror
(
errno
),
key
);
return
NULL
;
}
key
=
tagKey
;
}
else
{
outLen
=
strlen
(
key
);
}
STable
*
superTable
=
pTable
->
pSuper
;
SArray
**
data
=
(
SArray
**
)
taosHashGet
(
superTable
->
jsonKeyMap
,
key
,
outLen
);
if
(
data
==
NULL
)
return
NULL
;
JsonMapValue
jmvalue
=
{
pTable
,
0
};
JsonMapValue
*
p
=
taosArraySearch
(
*
data
,
&
jmvalue
,
tscCompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
return
NULL
;
int16_t
valId
=
p
->
colId
+
1
;
return
POINTER_SHIFT
(
kvRowValues
(
pTable
->
tagVal
),
valId
);
}
static
FORCE_INLINE
int32_t
tsdbGetJsonTagDataFromId
(
void
*
param
,
int32_t
id
,
char
*
name
,
void
**
data
)
{
static
FORCE_INLINE
int32_t
tsdbGetJsonTagDataFromId
(
void
*
param
,
int32_t
id
,
char
*
name
,
void
**
data
)
{
JsonMapValue
*
jsonMapV
=
(
JsonMapValue
*
)(
param
);
JsonMapValue
*
jsonMapV
=
(
JsonMapValue
*
)(
param
);
STable
*
pTable
=
(
STable
*
)(
jsonMapV
->
table
);
STable
*
pTable
=
(
STable
*
)(
jsonMapV
->
table
);
...
@@ -4095,7 +4075,9 @@ static FORCE_INLINE int32_t tsdbGetJsonTagDataFromId(void *param, int32_t id, ch
...
@@ -4095,7 +4075,9 @@ static FORCE_INLINE int32_t tsdbGetJsonTagDataFromId(void *param, int32_t id, ch
if
(
id
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
id
==
TSDB_TBNAME_COLUMN_INDEX
)
{
*
data
=
TABLE_NAME
(
pTable
);
*
data
=
TABLE_NAME
(
pTable
);
}
else
{
}
else
{
*
data
=
getJsonTagValue
(
pTable
,
name
);
void
*
jsonData
=
getJsonTagValue
(
pTable
,
name
);
if
(
jsonData
!=
NULL
)
jsonData
+=
CHAR_BYTES
;
// jump type
*
data
=
jsonData
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -4129,9 +4111,9 @@ static void queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){
...
@@ -4129,9 +4111,9 @@ static void queryByJsonTag(STable* pTable, void* filterInfo, SArray* res){
}
else
{
}
else
{
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
*
data
);
j
++
){
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
*
data
);
j
++
){
void
*
element
=
taosArrayGet
(
*
data
,
j
);
void
*
element
=
taosArrayGet
(
*
data
,
j
);
void
*
p
=
taosArraySearch
(
tabList
,
element
,
ts
c
CompareJsonMapValue
,
TD_EQ
);
void
*
p
=
taosArraySearch
(
tabList
,
element
,
ts
db
CompareJsonMapValue
,
TD_EQ
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
p
=
taosArraySearch
(
tabList
,
element
,
ts
c
CompareJsonMapValue
,
TD_GE
);
p
=
taosArraySearch
(
tabList
,
element
,
ts
db
CompareJsonMapValue
,
TD_GE
);
if
(
p
==
NULL
){
if
(
p
==
NULL
){
taosArrayPush
(
tabList
,
tabList
);
taosArrayPush
(
tabList
,
tabList
);
}
else
{
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录