Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6c0842fb
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6c0842fb
编写于
1月 20, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add index test
上级
80a07c38
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
102 addition
and
12 deletion
+102
-12
source/libs/index/test/indexTests.cc
source/libs/index/test/indexTests.cc
+102
-12
未找到文件。
source/libs/index/test/indexTests.cc
浏览文件 @
6c0842fb
...
...
@@ -82,7 +82,9 @@ class FstReadMemory {
bool
init
()
{
char
*
buf
=
(
char
*
)
calloc
(
1
,
sizeof
(
char
)
*
_size
);
int
nRead
=
fstCountingWriterRead
(
_w
,
(
uint8_t
*
)
buf
,
_size
);
if
(
nRead
<=
0
)
{
return
false
;
}
if
(
nRead
<=
0
)
{
return
false
;
}
_size
=
nRead
;
_s
=
fstSliceCreate
((
uint8_t
*
)
buf
,
_size
);
_fst
=
fstCreate
(
&
_s
);
...
...
@@ -108,7 +110,9 @@ class FstReadMemory {
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
result
.
push_back
((
uint64_t
)(
rt
->
out
.
out
));
}
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
result
.
push_back
((
uint64_t
)(
rt
->
out
.
out
));
}
return
true
;
}
bool
SearchWithTimeCostUs
(
AutomationCtx
*
ctx
,
std
::
vector
<
uint64_t
>&
result
)
{
...
...
@@ -184,7 +188,9 @@ void checkFstPerf() {
delete
fw
;
FstReadMemory
*
m
=
new
FstReadMemory
(
1024
*
64
);
if
(
m
->
init
())
{
printf
(
"success to init fst read"
);
}
if
(
m
->
init
())
{
printf
(
"success to init fst read"
);
}
Performance_fstReadRecords
(
m
);
delete
m
;
}
...
...
@@ -348,7 +354,9 @@ class TFileObj {
tfileReaderDestroy
(
reader_
);
reader_
=
NULL
;
}
if
(
writer_
==
NULL
)
{
InitWriter
();
}
if
(
writer_
==
NULL
)
{
InitWriter
();
}
return
tfileWriterPut
(
writer_
,
tv
,
false
);
}
bool
InitWriter
()
{
...
...
@@ -388,8 +396,12 @@ class TFileObj {
return
tfileReaderSearch
(
reader_
,
query
,
result
);
}
~
TFileObj
()
{
if
(
writer_
)
{
tfileWriterDestroy
(
writer_
);
}
if
(
reader_
)
{
tfileReaderDestroy
(
reader_
);
}
if
(
writer_
)
{
tfileWriterDestroy
(
writer_
);
}
if
(
reader_
)
{
tfileReaderDestroy
(
reader_
);
}
}
private:
...
...
@@ -912,7 +924,8 @@ TEST_F(IndexEnv2, testIndex_serarch_cache_and_tfile) {
}
TEST_F
(
IndexEnv2
,
testIndex_MultiWrite_and_MultiRead
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{}
if
(
index
->
Init
(
path
)
!=
0
)
{
}
std
::
thread
threads
[
NUM_OF_THREAD
];
for
(
int
i
=
0
;
i
<
NUM_OF_THREAD
;
i
++
)
{
...
...
@@ -927,14 +940,24 @@ TEST_F(IndexEnv2, testIndex_MultiWrite_and_MultiRead) {
TEST_F
(
IndexEnv2
,
testIndex_restart
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{}
if
(
index
->
Init
(
path
)
!=
0
)
{
}
index
->
SearchOneTarget
(
"tag1"
,
"Hello"
,
10
);
index
->
SearchOneTarget
(
"tag2"
,
"Test"
,
10
);
}
TEST_F
(
IndexEnv2
,
testIndex_restart1
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
index
->
ReadMultiMillonData
(
"tag1"
,
"coding"
);
index
->
SearchOneTarget
(
"tag1"
,
"Hello"
,
10
);
index
->
SearchOneTarget
(
"tag2"
,
"Test"
,
10
);
}
TEST_F
(
IndexEnv2
,
testIndex_read_performance
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{}
if
(
index
->
Init
(
path
)
!=
0
)
{
}
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
12
);
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
15
);
index
->
ReadMultiMillonData
(
"tag1"
,
"Hello"
);
...
...
@@ -943,17 +966,84 @@ TEST_F(IndexEnv2, testIndex_read_performance) {
}
TEST_F
(
IndexEnv2
,
testIndexMultiTag
)
{
std
::
string
path
=
"/tmp/multi_tag"
;
if
(
index
->
Init
(
path
)
!=
0
)
{}
if
(
index
->
Init
(
path
)
!=
0
)
{
}
int64_t
st
=
taosGetTimestampUs
();
int32_t
num
=
1000
*
10000
;
index
->
WriteMultiMillonData
(
"tag1"
,
"xxxxxxxxxxxxxxx"
,
num
);
std
::
cout
<<
"numOfRow: "
<<
num
<<
"
\t
time cost:"
<<
taosGetTimestampUs
()
-
st
<<
std
::
endl
;
// index->WriteMultiMillonData("tag2", "xxxxxxxxxxxxxxxxxxxxxxxxx", 100 * 10000);
}
TEST_F
(
IndexEnv2
,
testLongComVal
)
{
TEST_F
(
IndexEnv2
,
testLongComVal
1
)
{
std
::
string
path
=
"/tmp/long_colVal"
;
if
(
index
->
Init
(
path
)
!=
0
)
{}
if
(
index
->
Init
(
path
)
!=
0
)
{
}
// gen colVal by randstr
std
::
string
randstr
=
"xxxxxxxxxxxxxxxxx"
;
index
->
WriteMultiMillonData
(
"tag1"
,
randstr
,
100
*
10000
);
}
TEST_F
(
IndexEnv2
,
testLongComVal2
)
{
std
::
string
path
=
"/tmp/long_colVal"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
// gen colVal by randstr
std
::
string
randstr
=
"abcccc fdadfafdafda"
;
index
->
WriteMultiMillonData
(
"tag1"
,
randstr
,
100
*
10000
);
}
TEST_F
(
IndexEnv2
,
testLongComVal3
)
{
std
::
string
path
=
"/tmp/long_colVal"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
// gen colVal by randstr
std
::
string
randstr
=
"Yes, coding and coding and coding"
;
index
->
WriteMultiMillonData
(
"tag1"
,
randstr
,
100
*
10000
);
}
TEST_F
(
IndexEnv2
,
testLongComVal4
)
{
std
::
string
path
=
"/tmp/long_colVal"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
// gen colVal by randstr
std
::
string
randstr
=
"111111 bac fdadfa"
;
index
->
WriteMultiMillonData
(
"tag1"
,
randstr
,
100
*
10000
);
}
TEST_F
(
IndexEnv2
,
testIndex_read_performance1
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
12
);
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
15
);
index
->
ReadMultiMillonData
(
"tag1"
,
"Hello"
,
1000
);
std
::
cout
<<
"reader sz: "
<<
index
->
SearchOne
(
"tag1"
,
"Hello"
)
<<
std
::
endl
;
assert
(
3
==
index
->
SearchOne
(
"tag1"
,
"Hello"
));
}
TEST_F
(
IndexEnv2
,
testIndex_read_performance2
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
12
);
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
15
);
index
->
ReadMultiMillonData
(
"tag1"
,
"Hello"
,
1000
*
10
);
std
::
cout
<<
"reader sz: "
<<
index
->
SearchOne
(
"tag1"
,
"Hello"
)
<<
std
::
endl
;
assert
(
3
==
index
->
SearchOne
(
"tag1"
,
"Hello"
));
}
TEST_F
(
IndexEnv2
,
testIndex_read_performance3
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
12
);
index
->
PutOneTarge
(
"tag1"
,
"Hello"
,
15
);
index
->
ReadMultiMillonData
(
"tag1"
,
"Hello"
,
1000
*
100
);
std
::
cout
<<
"reader sz: "
<<
index
->
SearchOne
(
"tag1"
,
"Hello"
)
<<
std
::
endl
;
assert
(
3
==
index
->
SearchOne
(
"tag1"
,
"Hello"
));
}
TEST_F
(
IndexEnv2
,
testIndex_read_performance4
)
{
std
::
string
path
=
"/tmp/cache_and_tfile"
;
if
(
index
->
Init
(
path
)
!=
0
)
{
}
index
->
PutOneTarge
(
"tag10"
,
"Hello"
,
12
);
index
->
PutOneTarge
(
"tag12"
,
"Hello"
,
15
);
index
->
ReadMultiMillonData
(
"tag10"
,
"Hello"
,
1000
*
100
);
std
::
cout
<<
"reader sz: "
<<
index
->
SearchOne
(
"tag1"
,
"Hello"
)
<<
std
::
endl
;
assert
(
3
==
index
->
SearchOne
(
"tag10"
,
"Hello"
));
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录