Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1cffb8fd
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1cffb8fd
编写于
6月 07, 2022
作者:
dengyihao
提交者:
GitHub
6月 07, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13531 from taosdata/enh/suppportIdxJson
enh: support more json filter case
上级
37c822d3
6dcb6cc6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
25 deletion
+35
-25
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+7
-7
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+5
-2
source/libs/index/src/indexComm.c
source/libs/index/src/indexComm.c
+9
-2
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+12
-7
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+1
-6
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-1
未找到文件。
source/libs/index/inc/indexInt.h
浏览文件 @
1cffb8fd
...
...
@@ -35,15 +35,15 @@ extern "C" {
#endif
// clang-format off
#define indexFatal(...) do { if (idxDebugFlag & DEBUG_FATAL) { taosPrintLog("I
NDE
X FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while (0)
#define indexError(...) do { if (idxDebugFlag & DEBUG_ERROR) { taosPrintLog("I
NDE
X ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while (0)
#define indexWarn(...) do { if (idxDebugFlag & DEBUG_WARN) { taosPrintLog("I
NDE
X WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while (0)
#define indexInfo(...) do { if (idxDebugFlag & DEBUG_INFO) { taosPrintLog("I
NDE
X ", DEBUG_INFO, 255, __VA_ARGS__); } } while (0)
#define indexDebug(...) do { if (idxDebugFlag & DEBUG_DEBUG) { taosPrintLog("I
NDEX ", DEBUG_DEBUG, s
DebugFlag, __VA_ARGS__);} } while (0)
#define indexTrace(...) do { if (idxDebugFlag & DEBUG_TRACE) { taosPrintLog("I
NDEX ", DEBUG_TRACE, s
DebugFlag, __VA_ARGS__);} } while (0)
#define indexFatal(...) do { if (idxDebugFlag & DEBUG_FATAL) { taosPrintLog("I
D
X FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while (0)
#define indexError(...) do { if (idxDebugFlag & DEBUG_ERROR) { taosPrintLog("I
D
X ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while (0)
#define indexWarn(...) do { if (idxDebugFlag & DEBUG_WARN) { taosPrintLog("I
D
X WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while (0)
#define indexInfo(...) do { if (idxDebugFlag & DEBUG_INFO) { taosPrintLog("I
D
X ", DEBUG_INFO, 255, __VA_ARGS__); } } while (0)
#define indexDebug(...) do { if (idxDebugFlag & DEBUG_DEBUG) { taosPrintLog("I
DX ", DEBUG_DEBUG, idx
DebugFlag, __VA_ARGS__);} } while (0)
#define indexTrace(...) do { if (idxDebugFlag & DEBUG_TRACE) { taosPrintLog("I
DX", DEBUG_TRACE, idx
DebugFlag, __VA_ARGS__);} } while (0)
// clang-format on
typedef
enum
{
LT
,
LE
,
GT
,
GE
}
RangeType
;
typedef
enum
{
LT
,
LE
,
GT
,
GE
,
CONTAINS
}
RangeType
;
typedef
enum
{
kTypeValue
,
kTypeDeletion
}
STermValueType
;
typedef
struct
SIndexStat
{
...
...
source/libs/index/src/indexCache.c
浏览文件 @
1cffb8fd
...
...
@@ -90,7 +90,7 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTRslt* tr, STe
break
;
}
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
if
(
0
==
strcmp
(
c
->
colVal
,
pCt
->
colVal
))
{
if
(
0
==
strcmp
(
c
->
colVal
,
pCt
->
colVal
)
&&
strlen
(
pCt
->
colVal
)
==
strlen
(
c
->
colVal
)
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
add
,
c
->
uid
)
// taosArrayPush(result, &c->uid);
...
...
@@ -222,7 +222,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
cacheSearchPrefix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
CONTAINS
)
;
}
static
int32_t
cacheSearchSuffix_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -242,6 +242,9 @@ static int32_t cacheSearchGreaterThan_JSON(void* cache, SIndexTerm* term, SIdxTR
static
int32_t
cacheSearchGreaterEqual_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
GE
);
}
static
int32_t
cacheSearchContain_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
cacheSearchCompareFunc_JSON
(
cache
,
term
,
tr
,
s
,
CONTAINS
);
}
static
int32_t
cacheSearchRange_JSON
(
void
*
cache
,
SIndexTerm
*
term
,
SIdxTRslt
*
tr
,
STermValueType
*
s
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/index/src/indexComm.c
浏览文件 @
1cffb8fd
...
...
@@ -97,6 +97,11 @@ static TExeCond tCompareGreaterEqual(void* a, void* b, int8_t type) {
__compar_fn_t
func
=
indexGetCompar
(
type
);
return
tCompare
(
func
,
QUERY_GREATER_EQUAL
,
a
,
b
,
type
);
}
static
TExeCond
tCompareContains
(
void
*
a
,
void
*
b
,
int8_t
type
)
{
__compar_fn_t
func
=
indexGetCompar
(
type
);
return
tCompare
(
func
,
QUERY_TERM
,
a
,
b
,
type
);
}
TExeCond
tCompare
(
__compar_fn_t
func
,
int8_t
cmptype
,
void
*
a
,
void
*
b
,
int8_t
dtype
)
{
if
(
dtype
==
TSDB_DATA_TYPE_BINARY
||
dtype
==
TSDB_DATA_TYPE_NCHAR
||
dtype
==
TSDB_DATA_TYPE_VARBINARY
)
{
return
tDoCompare
(
func
,
cmptype
,
a
,
b
);
...
...
@@ -185,12 +190,14 @@ TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) {
case
QUERY_TERM
:
{
if
(
ret
==
0
)
return
MATCH
;
}
default:
return
BREAK
;
}
return
CONTINUE
;
}
static
TExeCond
(
*
rangeCompare
[])(
void
*
a
,
void
*
b
,
int8_t
type
)
=
{
tCompareLessThan
,
tCompareLessEqual
,
tCompareGreaterThan
,
tCompareGreaterEqual
};
static
TExeCond
(
*
rangeCompare
[])(
void
*
a
,
void
*
b
,
int8_t
type
)
=
{
tCompareLessThan
,
tCompareLessEqual
,
tCompareGreaterThan
,
tCompareGreaterEqual
,
tCompareContains
};
_cache_range_compare
indexGetCompare
(
RangeType
ty
)
{
return
rangeCompare
[
ty
];
}
...
...
source/libs/index/src/indexFilter.c
浏览文件 @
1cffb8fd
...
...
@@ -64,6 +64,8 @@ static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
*
dst
=
QUERY_TERM
;
}
else
if
(
src
==
OP_TYPE_LIKE
||
src
==
OP_TYPE_MATCH
||
src
==
OP_TYPE_NMATCH
)
{
*
dst
=
QUERY_REGEX
;
}
else
if
(
src
==
OP_TYPE_JSON_CONTAINS
)
{
*
dst
=
QUERY_PREFIX
;
}
else
{
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
...
...
@@ -186,6 +188,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
SIF_ERR_RET
(
sifGetValueFromNode
(
node
,
&
param
->
condValue
));
param
->
colId
=
-
1
;
param
->
colValType
=
(
uint8_t
)(
vn
->
node
.
resType
.
type
);
memcpy
(
param
->
colName
,
vn
->
literal
,
strlen
(
vn
->
literal
));
break
;
}
case
QUERY_NODE_COLUMN
:
{
...
...
@@ -237,7 +240,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
indexError
(
"invalid operation node, left: %p, rigth: %p"
,
node
->
pLeft
,
node
->
pRight
);
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
||
node
->
opType
==
OP_TYPE_JSON_CONTAINS
)
{
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
)
{
return
code
;
}
SIFParam
*
paramList
=
taosMemoryCalloc
(
nParam
,
sizeof
(
SIFParam
));
...
...
@@ -420,8 +423,8 @@ static int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output
return
sifDoIndex
(
left
,
right
,
id
,
output
);
}
static
int32_t
sifJsonContains
(
SIFParam
*
left
,
SIFParam
*
right
,
SIFParam
*
output
)
{
// return 0
return
0
;
int
id
=
OP_TYPE_JSON_CONTAINS
;
return
sifDoIndex
(
left
,
right
,
id
,
output
)
;
}
static
int32_t
sifJsonGetValue
(
SIFParam
*
left
,
SIFParam
*
rigth
,
SIFParam
*
output
)
{
// return 0
...
...
@@ -501,9 +504,11 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
int32_t
code
=
0
;
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
nParam
<=
1
)
{
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
output
->
status
=
SFLT_NOT_INDEX
;
return
code
;
// SIF_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
||
node
->
opType
==
OP_TYPE_JSON_CONTAINS
)
{
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
)
{
return
code
;
}
SIFParam
*
params
=
NULL
;
...
...
@@ -617,11 +622,11 @@ EDealRes sifCalcWalker(SNode *node, void *context) {
}
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
node
))
{
indexInfo
(
"node type for index filter, type: %d"
,
nodeType
(
node
));
//
indexInfo("node type for index filter, type: %d", nodeType(node));
return
sifWalkOper
(
node
,
ctx
);
}
indexError
(
"invalid node type for index filter calculating, type:%d"
,
nodeType
(
node
));
//
indexError("invalid node type for index filter calculating, type:%d", nodeType(node));
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
1cffb8fd
...
...
@@ -425,8 +425,7 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tfSearchPrefix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTRslt
*
tr
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
return
tfSearchCompareFunc_JSON
(
reader
,
tem
,
tr
,
CONTAINS
);
}
static
int32_t
tfSearchSuffix_JSON
(
void
*
reader
,
SIndexTerm
*
tem
,
SIdxTRslt
*
tr
)
{
// impl later
...
...
@@ -466,10 +465,6 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
p
,
AUTOMATION_PREFIX
);
FstStreamBuilder
*
sb
=
fstSearch
(((
TFileReader
*
)
reader
)
->
fst
,
ctx
);
// FstSlice h = fstSliceCreate((uint8_t*)p, skip);
// fstStreamBuilderSetRange(sb, &h, ctype);
// fstSliceDestroy(&h);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
1cffb8fd
...
...
@@ -64,7 +64,7 @@ static SKeyword keywordTable[] = {
{
"CONSUMER"
,
TK_CONSUMER
},
{
"COUNT"
,
TK_COUNT
},
{
"CREATE"
,
TK_CREATE
},
{
"CONTAINS"
,
TK_CONTAINS
},
{
"CONTAINS"
,
TK_CONTAINS
},
{
"DATABASE"
,
TK_DATABASE
},
{
"DATABASES"
,
TK_DATABASES
},
{
"DAYS"
,
TK_DAYS
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录