Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
26a98602
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看板
提交
26a98602
编写于
12月 15, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix search bug
上级
e5bc959f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
3 deletion
+60
-3
source/libs/index/inc/index_fst.h
source/libs/index/inc/index_fst.h
+4
-0
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+4
-0
source/libs/index/test/indexTests.cpp
source/libs/index/test/indexTests.cpp
+52
-3
未找到文件。
source/libs/index/inc/index_fst.h
浏览文件 @
26a98602
...
@@ -30,6 +30,7 @@ extern "C" {
...
@@ -30,6 +30,7 @@ extern "C" {
typedef
struct
Fst
Fst
;
typedef
struct
Fst
Fst
;
typedef
struct
FstNode
FstNode
;
typedef
struct
FstNode
FstNode
;
typedef
struct
StreamWithState
StreamWithState
;
typedef
enum
{
Included
,
Excluded
,
Unbounded
}
FstBound
;
typedef
enum
{
Included
,
Excluded
,
Unbounded
}
FstBound
;
...
@@ -283,6 +284,9 @@ Output fstEmptyFinalOutput(Fst *fst, bool *null);
...
@@ -283,6 +284,9 @@ Output fstEmptyFinalOutput(Fst *fst, bool *null);
FstStreamBuilder
*
fstSearch
(
Fst
*
fst
,
AutomationCtx
*
ctx
);
FstStreamBuilder
*
fstSearch
(
Fst
*
fst
,
AutomationCtx
*
ctx
);
FstStreamWithStateBuilder
*
fstSearchWithState
(
Fst
*
fst
,
AutomationCtx
*
ctx
);
FstStreamWithStateBuilder
*
fstSearchWithState
(
Fst
*
fst
,
AutomationCtx
*
ctx
);
// into stream to expand later
StreamWithState
*
streamBuilderIntoStream
(
FstStreamBuilder
*
sb
);
bool
fstVerify
(
Fst
*
fst
);
bool
fstVerify
(
Fst
*
fst
);
...
...
source/libs/index/src/index_fst.c
浏览文件 @
26a98602
...
@@ -1094,6 +1094,10 @@ bool fstGet(Fst *fst, FstSlice *b, Output *out) {
...
@@ -1094,6 +1094,10 @@ bool fstGet(Fst *fst, FstSlice *b, Output *out) {
FstStreamBuilder
*
fstSearch
(
Fst
*
fst
,
AutomationCtx
*
ctx
)
{
FstStreamBuilder
*
fstSearch
(
Fst
*
fst
,
AutomationCtx
*
ctx
)
{
return
fstStreamBuilderCreate
(
fst
,
ctx
);
return
fstStreamBuilderCreate
(
fst
,
ctx
);
}
}
StreamWithState
*
streamBuilderIntoStream
(
FstStreamBuilder
*
sb
)
{
if
(
sb
==
NULL
)
{
return
NULL
;
}
return
streamWithStateCreate
(
sb
->
fst
,
sb
->
aut
,
sb
->
min
,
sb
->
max
);
}
FstStreamWithStateBuilder
*
fstSearchWithState
(
Fst
*
fst
,
AutomationCtx
*
ctx
)
{
FstStreamWithStateBuilder
*
fstSearchWithState
(
Fst
*
fst
,
AutomationCtx
*
ctx
)
{
return
fstStreamBuilderCreate
(
fst
,
ctx
);
return
fstStreamBuilderCreate
(
fst
,
ctx
);
}
}
...
...
source/libs/index/test/indexTests.cpp
浏览文件 @
26a98602
...
@@ -59,9 +59,22 @@ class FstReadMemory {
...
@@ -59,9 +59,22 @@ class FstReadMemory {
return
ok
;
return
ok
;
}
}
// add later
// add later
bool
Search
(
const
std
::
string
&
key
,
std
::
vector
<
uint64_t
>
&
result
)
{
bool
Search
(
AutomationCtx
*
ctx
,
std
::
vector
<
uint64_t
>
&
result
)
{
FstStreamBuilder
*
sb
=
fstSearch
(
_fst
,
ctx
);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
result
.
push_back
((
uint64_t
)(
rt
->
out
.
out
));
}
return
true
;
return
true
;
}
}
bool
SearchWithTimeCostUs
(
AutomationCtx
*
ctx
,
std
::
vector
<
uint64_t
>
&
result
)
{
int64_t
s
=
taosGetTimestampUs
();
bool
ok
=
this
->
Search
(
ctx
,
result
);
int64_t
e
=
taosGetTimestampUs
();
return
ok
;
}
~
FstReadMemory
()
{
~
FstReadMemory
()
{
fstCountingWriterDestroy
(
_w
);
fstCountingWriterDestroy
(
_w
);
...
@@ -186,11 +199,43 @@ void checkFstPerf() {
...
@@ -186,11 +199,43 @@ void checkFstPerf() {
printf
(
"success to init fst read"
);
printf
(
"success to init fst read"
);
}
}
Performance_fstReadRecords
(
m
);
Performance_fstReadRecords
(
m
);
delete
m
;
delete
m
;
}
}
void
checkFstPrefixSearch
()
{
FstWriter
*
fw
=
new
FstWriter
;
int64_t
s
=
taosGetTimestampUs
();
int
count
=
2
;
std
::
string
key
(
"ab"
);
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
key
[
1
]
=
key
[
1
]
+
i
;
fw
->
Put
(
key
,
i
);
}
int64_t
e
=
taosGetTimestampUs
();
std
::
cout
<<
"insert data count : "
<<
count
<<
"elapas time: "
<<
e
-
s
<<
std
::
endl
;
delete
fw
;
FstReadMemory
*
m
=
new
FstReadMemory
(
1024
*
64
);
if
(
m
->
init
()
==
false
)
{
std
::
cout
<<
"init readMemory failed"
<<
std
::
endl
;
delete
m
;
return
;
}
// prefix search
std
::
vector
<
uint64_t
>
result
;
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
"ab"
,
AUTOMATION_PREFIX
);
m
->
Search
(
ctx
,
result
);
assert
(
result
.
size
()
==
count
);
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++
)
{
assert
(
result
[
i
]
==
i
);
// check result
}
free
(
ctx
);
delete
m
;
}
void
validateFst
()
{
void
validateFst
()
{
int
val
=
100
;
int
val
=
100
;
int
count
=
100
;
int
count
=
100
;
...
@@ -209,6 +254,8 @@ void validateFst() {
...
@@ -209,6 +254,8 @@ void validateFst() {
FstReadMemory
*
m
=
new
FstReadMemory
(
1024
*
64
);
FstReadMemory
*
m
=
new
FstReadMemory
(
1024
*
64
);
if
(
m
->
init
()
==
false
)
{
if
(
m
->
init
()
==
false
)
{
std
::
cout
<<
"init readMemory failed"
<<
std
::
endl
;
std
::
cout
<<
"init readMemory failed"
<<
std
::
endl
;
delete
m
;
return
;
}
}
{
{
...
@@ -230,10 +277,12 @@ void validateFst() {
...
@@ -230,10 +277,12 @@ void validateFst() {
}
}
}
}
delete
m
;
delete
m
;
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
checkFstPerf
();
checkFstPerf
();
//checkFstPrefixSearch();
return
1
;
return
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录