Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9105c19e
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看板
提交
9105c19e
编写于
6月 07, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
差异文件
fix: add json contains
上级
163f8f2e
70e27717
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
33 deletion
+51
-33
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+2
-2
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+23
-13
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+2
-5
source/libs/index/src/indexTfile.c
source/libs/index/src/indexTfile.c
+24
-13
未找到文件。
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
9105c19e
...
...
@@ -61,14 +61,14 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
if
(
tTagToValArray
((
const
STag
*
)
data
,
&
pTagVals
)
!=
0
)
{
return
-
1
;
}
char
key
[
512
]
=
{
0
};
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
int16_t
nCols
=
taosArrayGetSize
(
pTagVals
);
for
(
int
i
=
0
;
i
<
nCols
;
i
++
)
{
STagVal
*
pTagVal
=
(
STagVal
*
)
taosArrayGet
(
pTagVals
,
i
);
char
type
=
pTagVal
->
type
;
sprintf
(
key
,
"%s_%s"
,
tagName
,
pTagVal
->
pKey
);
char
*
key
=
pTagVal
->
pKey
;
int32_t
nKey
=
strlen
(
key
);
SIndexTerm
*
term
=
NULL
;
...
...
source/libs/index/src/indexCache.c
浏览文件 @
9105c19e
...
...
@@ -123,12 +123,11 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt*
if
(
cache
==
NULL
)
{
return
0
;
}
_cache_range_compare
cmpFn
=
indexGetCompare
(
type
);
MemTable
*
mem
=
cache
;
IndexCache
*
pCache
=
mem
->
pCache
;
_cache_range_compare
cmpFn
=
indexGetCompare
(
type
);
CacheTerm
*
pCt
=
taosMemoryCalloc
(
1
,
sizeof
(
CacheTerm
));
pCt
->
colVal
=
term
->
colVal
;
pCt
->
colType
=
term
->
colType
;
...
...
@@ -267,13 +266,20 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
int
skip
=
0
;
char
*
exBuf
=
NULL
;
if
(
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
))
{
if
(
type
==
CONTAINS
)
{
SIndexTerm
tm
=
{.
suid
=
term
->
suid
,
.
operType
=
term
->
operType
,
.
colType
=
term
->
colType
,
.
colName
=
term
->
colVal
,
.
nColName
=
term
->
nColVal
};
exBuf
=
indexPackJsonDataPrefix
(
&
tm
,
&
skip
);
pCt
->
colVal
=
exBuf
;
}
else
{
exBuf
=
indexPackJsonDataPrefix
(
term
,
&
skip
);
pCt
->
colVal
=
exBuf
;
}
char
*
key
=
indexCacheTermGet
(
pCt
);
// SSkipListIterator* iter = tSkipListCreateIter(mem->mem);
SSkipListIterator
*
iter
=
tSkipListCreateIterFromVal
(
mem
->
mem
,
key
,
TSDB_DATA_TYPE_BINARY
,
TSDB_ORDER_ASC
);
while
(
tSkipListIterNext
(
iter
))
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
...
...
@@ -281,14 +287,19 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
break
;
}
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
// printf("json val: %s\n", c->colVal);
if
(
0
!=
strncmp
(
c
->
colVal
,
pCt
->
colVal
,
skip
))
{
break
;
TExeCond
cond
=
CONTINUE
;
if
(
type
==
CONTAINS
)
{
if
(
0
==
strncmp
(
c
->
colVal
,
pCt
->
colVal
,
skip
))
{
cond
=
MATCH
;
}
}
else
{
if
(
0
!=
strncmp
(
c
->
colVal
,
pCt
->
colVal
,
skip
))
{
break
;
}
char
*
p
=
taosMemoryCalloc
(
1
,
strlen
(
c
->
colVal
)
+
1
);
memcpy
(
p
,
c
->
colVal
,
strlen
(
c
->
colVal
));
TExeCond
cond
=
cmpFn
(
p
+
skip
,
term
->
colVal
,
dType
);
}
char
*
p
=
taosMemoryCalloc
(
1
,
strlen
(
c
->
colVal
)
+
1
);
memcpy
(
p
,
c
->
colVal
,
strlen
(
c
->
colVal
));
TExeCond
cond
=
cmpFn
(
p
+
skip
,
term
->
colVal
,
dType
);
if
(
cond
==
MATCH
)
{
if
(
c
->
operaType
==
ADD_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
del
,
tr
->
add
,
c
->
uid
)
...
...
@@ -302,7 +313,6 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
}
else
if
(
cond
==
BREAK
)
{
break
;
}
taosMemoryFree
(
p
);
}
taosMemoryFree
(
pCt
);
...
...
source/libs/index/src/indexFilter.c
浏览文件 @
9105c19e
...
...
@@ -173,10 +173,8 @@ static int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
param
->
colId
=
l
->
colId
;
param
->
colValType
=
l
->
node
.
resType
.
type
;
memcpy
(
param
->
dbName
,
l
->
dbName
,
sizeof
(
l
->
dbName
));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-overflow"
sprintf
(
param
->
colName
,
"%s_%s"
,
l
->
colName
,
r
->
literal
);
#pragma GCC diagnostic pop
memcpy
(
param
->
colName
,
r
->
literal
,
strlen
(
r
->
literal
));
// sprintf(param->colName, "%s_%s", l->colName, r->literal);
param
->
colValType
=
r
->
typeData
;
return
0
;
// memcpy(param->colName, l->colName, sizeof(l->colName));
...
...
@@ -505,7 +503,6 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) {
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
nParam
<=
1
)
{
output
->
status
=
SFLT_NOT_INDEX
;
SIF_ERR_RET
(
code
);
return
code
;
}
if
(
node
->
opType
==
OP_TYPE_JSON_GET_VALUE
)
{
...
...
source/libs/index/src/indexTfile.c
浏览文件 @
9105c19e
...
...
@@ -456,7 +456,17 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
int
ret
=
0
;
int
skip
=
0
;
char
*
p
=
indexPackJsonDataPrefix
(
tem
,
&
skip
);
char
*
p
=
NULL
;
if
(
ctype
==
CONTAINS
)
{
SIndexTerm
tm
=
{.
suid
=
tem
->
suid
,
.
operType
=
tem
->
operType
,
.
colType
=
tem
->
colType
,
.
colName
=
tem
->
colVal
,
.
nColName
=
tem
->
nColVal
};
p
=
indexPackJsonDataPrefix
(
&
tm
,
&
skip
);
}
else
{
p
=
indexPackJsonDataPrefix
(
tem
,
&
skip
);
}
_cache_range_compare
cmpFn
=
indexGetCompare
(
ctype
);
...
...
@@ -470,18 +480,20 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
FstSlice
*
s
=
&
rt
->
data
;
int32_t
sz
=
0
;
char
*
ch
=
(
char
*
)
fstSliceData
(
s
,
&
sz
);
char
*
tmp
=
taosMemoryCalloc
(
1
,
sz
+
1
);
memcpy
(
tmp
,
ch
,
sz
);
if
(
0
!=
strncmp
(
tmp
,
p
,
skip
))
{
swsResultDestroy
(
rt
);
taosMemoryFree
(
tmp
);
break
;
int32_t
sz
=
0
;
char
*
ch
=
(
char
*
)
fstSliceData
(
s
,
&
sz
);
TExeCond
cond
=
CONTINUE
;
if
(
ctype
==
CONTAINS
)
{
if
(
0
!=
strncmp
(
ch
,
p
,
skip
))
{
cond
=
MATCH
;
}
}
else
{
if
(
0
!=
strncmp
(
ch
,
p
,
skip
))
{
swsResultDestroy
(
rt
);
break
;
}
cond
=
cmpFn
(
ch
+
skip
,
tem
->
colVal
,
INDEX_TYPE_GET_TYPE
(
tem
->
colType
));
}
TExeCond
cond
=
cmpFn
(
tmp
+
skip
,
tem
->
colVal
,
INDEX_TYPE_GET_TYPE
(
tem
->
colType
));
if
(
MATCH
==
cond
)
{
tfileReaderLoadTableIds
((
TFileReader
*
)
reader
,
rt
->
out
.
out
,
tr
->
total
);
}
else
if
(
CONTINUE
==
cond
)
{
...
...
@@ -489,7 +501,6 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
swsResultDestroy
(
rt
);
break
;
}
taosMemoryFree
(
tmp
);
swsResultDestroy
(
rt
);
}
streamWithStateDestroy
(
st
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录