Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6a6f31c4
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
6a6f31c4
编写于
3月 02, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support json
上级
4be79789
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
121 addition
and
2 deletion
+121
-2
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+11
-2
source/libs/index/test/CMakeLists.txt
source/libs/index/test/CMakeLists.txt
+18
-0
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+92
-0
未找到文件。
source/libs/index/src/index_cache.c
浏览文件 @
6a6f31c4
...
@@ -222,7 +222,7 @@ static char* indexCachePackJsonData(SIndexTerm* itm) {
...
@@ -222,7 +222,7 @@ static char* indexCachePackJsonData(SIndexTerm* itm) {
char
*
buf
=
(
char
*
)
calloc
(
1
,
sz
);
char
*
buf
=
(
char
*
)
calloc
(
1
,
sz
);
char
*
p
=
buf
;
char
*
p
=
buf
;
memcpy
(
p
,
itm
->
col
Val
,
itm
->
nColName
);
memcpy
(
p
,
itm
->
col
Name
,
itm
->
nColName
);
p
+=
itm
->
nColName
;
p
+=
itm
->
nColName
;
memcpy
(
p
,
&
JSON_VALUE_DELIM
,
sizeof
(
JSON_VALUE_DELIM
));
memcpy
(
p
,
&
JSON_VALUE_DELIM
,
sizeof
(
JSON_VALUE_DELIM
));
...
@@ -329,13 +329,22 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV
...
@@ -329,13 +329,22 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV
SIndexTerm
*
term
=
query
->
term
;
SIndexTerm
*
term
=
query
->
term
;
EIndexQueryType
qtype
=
query
->
qType
;
EIndexQueryType
qtype
=
query
->
qType
;
CacheTerm
ct
=
{.
colVal
=
term
->
colVal
,
.
version
=
atomic_load_32
(
&
pCache
->
version
)};
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
term
->
colVal
;
if
(
hasJson
)
{
p
=
indexCachePackJsonData
(
term
);
}
CacheTerm
ct
=
{.
colVal
=
p
,
.
version
=
atomic_load_32
(
&
pCache
->
version
)};
int
ret
=
indexQueryMem
(
mem
,
&
ct
,
qtype
,
result
,
s
);
int
ret
=
indexQueryMem
(
mem
,
&
ct
,
qtype
,
result
,
s
);
if
(
ret
==
0
&&
*
s
!=
kTypeDeletion
)
{
if
(
ret
==
0
&&
*
s
!=
kTypeDeletion
)
{
// continue search in imm
// continue search in imm
ret
=
indexQueryMem
(
imm
,
&
ct
,
qtype
,
result
,
s
);
ret
=
indexQueryMem
(
imm
,
&
ct
,
qtype
,
result
,
s
);
}
}
if
(
hasJson
)
{
tfree
(
p
);
}
indexMemUnRef
(
mem
);
indexMemUnRef
(
mem
);
indexMemUnRef
(
imm
);
indexMemUnRef
(
imm
);
...
...
source/libs/index/test/CMakeLists.txt
浏览文件 @
6a6f31c4
...
@@ -2,6 +2,7 @@ add_executable(indexTest "")
...
@@ -2,6 +2,7 @@ add_executable(indexTest "")
add_executable
(
fstTest
""
)
add_executable
(
fstTest
""
)
add_executable
(
fstUT
""
)
add_executable
(
fstUT
""
)
add_executable
(
UtilUT
""
)
add_executable
(
UtilUT
""
)
add_executable
(
jsonUT
""
)
target_sources
(
indexTest
target_sources
(
indexTest
PRIVATE
PRIVATE
...
@@ -21,6 +22,10 @@ target_sources(UtilUT
...
@@ -21,6 +22,10 @@ target_sources(UtilUT
"utilUT.cc"
"utilUT.cc"
)
)
target_sources
(
jsonUT
PRIVATE
"jsonUT.cc"
)
target_include_directories
(
indexTest
target_include_directories
(
indexTest
PUBLIC
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
...
@@ -43,6 +48,12 @@ target_include_directories ( UtilUT
...
@@ -43,6 +48,12 @@ target_include_directories ( UtilUT
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
jsonUT
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
indexTest
target_link_libraries
(
indexTest
os
os
util
util
...
@@ -73,6 +84,13 @@ target_link_libraries (UtilUT
...
@@ -73,6 +84,13 @@ target_link_libraries (UtilUT
index
index
)
)
target_link_libraries
(
jsonUT
os
util
common
gtest_main
index
)
#add_test(
#add_test(
# NAME index_test
# NAME index_test
...
...
source/libs/index/test/jsonUT.cc
0 → 100644
浏览文件 @
6a6f31c4
#include <gtest/gtest.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include "index.h"
#include "indexInt.h"
#include "index_cache.h"
#include "index_fst.h"
#include "index_fst_counting_writer.h"
#include "index_fst_util.h"
#include "index_tfile.h"
#include "index_util.h"
#include "tglobal.h"
#include "tskiplist.h"
#include "tutil.h"
static
std
::
string
dir
=
"/tmp/json"
;
class
JsonEnv
:
public
::
testing
::
Test
{
protected:
virtual
void
SetUp
()
{
taosRemoveDir
(
dir
.
c_str
());
opts
=
indexOptsCreate
();
int
ret
=
tIndexJsonOpen
(
opts
,
dir
.
c_str
(),
&
index
);
assert
(
ret
==
0
);
}
virtual
void
TearDown
()
{
tIndexJsonClose
(
index
);
indexOptsDestroy
(
opts
);
}
SIndexJsonOpts
*
opts
;
SIndexJson
*
index
;
};
TEST_F
(
JsonEnv
,
testWrite
)
{
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"ab1"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"123"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"ab"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_TERM
);
tIndexJsonSearch
(
index
,
mq
,
result
);
assert
(
100
==
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
// SIndexTermQuery query = {.term = term, .qType = QUERY_TERM};
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录