Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a915647d
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看板
提交
a915647d
编写于
3月 30, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add fuzzy search
上级
0c8271e0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
3 deletion
+60
-3
source/libs/index/inc/indexFstDfa.h
source/libs/index/inc/indexFstDfa.h
+2
-0
source/libs/index/src/indexFstDfa.c
source/libs/index/src/indexFstDfa.c
+58
-3
未找到文件。
source/libs/index/inc/indexFstDfa.h
浏览文件 @
a915647d
...
...
@@ -44,6 +44,8 @@ typedef struct FstDfaBuilder {
FstDfaBuilder
*
dfaBuilderCreate
(
SArray
*
insts
);
void
dfaBuilderDestroy
(
FstDfaBuilder
*
builder
);
FstDfa
*
dfaBuilderBuild
(
FstDfaBuilder
*
builder
);
bool
dfaBuilderRunState
(
FstDfaBuilder
*
builder
,
FstSparseSet
*
cur
,
FstSparseSet
*
next
,
uint32_t
state
,
uint8_t
bytes
,
...
...
source/libs/index/src/indexFstDfa.c
浏览文件 @
a915647d
...
...
@@ -16,6 +16,8 @@
#include "indexFstDfa.h"
#include "thash.h"
const
static
uint32_t
STATE_LIMIT
=
1000
;
static
int
dfaInstsEqual
(
const
void
*
a
,
const
void
*
b
,
size_t
size
)
{
SArray
*
ar
=
(
SArray
*
)
a
;
SArray
*
br
=
(
SArray
*
)
b
;
...
...
@@ -48,6 +50,18 @@ FstDfaBuilder *dfaBuilderCreate(SArray *insts) {
taosHashSetEqualFp
(
builder
->
cache
,
dfaInstsEqual
);
return
builder
;
}
void
dfaBuilderDestroy
(
FstDfaBuilder
*
builder
)
{
if
(
builder
==
NULL
)
{
return
;
}
void
*
pIter
=
builder
->
cache
!=
NULL
?
taosHashIterate
(
builder
->
cache
,
NULL
)
:
NULL
;
while
(
pIter
)
{
SArray
**
key
=
pIter
;
taosArrayDestroy
(
*
key
);
pIter
=
taosHashIterate
(
builder
->
cache
,
pIter
);
}
taosHashCleanup
(
builder
->
cache
);
}
FstDfa
*
dfaBuilderBuild
(
FstDfaBuilder
*
builder
)
{
uint32_t
sz
=
taosArrayGetSize
(
builder
->
dfa
->
insts
);
...
...
@@ -55,12 +69,53 @@ FstDfa *dfaBuilderBuild(FstDfaBuilder *builder) {
FstSparseSet
*
nxt
=
sparSetCreate
(
sz
);
dfaAdd
(
builder
->
dfa
,
cur
,
0
);
SArray
*
states
=
taosArrayInit
(
0
,
sizeof
(
uint32_t
));
uint32_t
result
;
if
(
dfaBuilderCachedState
(
builder
,
cur
,
&
result
))
{
taosArrayPush
(
states
,
&
result
);
}
SHashObj
*
seen
=
taosHashInit
(
12
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
while
(
taosArrayGetSize
(
states
)
!=
0
)
{
result
=
*
(
uint32_t
*
)
taosArrayPop
(
states
);
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
uint32_t
ns
,
dummpy
=
0
;
if
(
dfaBuilderRunState
(
builder
,
cur
,
nxt
,
result
,
i
,
&
ns
))
{
if
(
taosHashGet
(
seen
,
&
ns
,
sizeof
(
ns
))
==
NULL
)
{
taosHashPut
(
seen
,
&
ns
,
sizeof
(
ns
),
&
dummpy
,
sizeof
(
dummpy
));
taosArrayPush
(
states
,
&
ns
);
}
}
if
(
taosArrayGetSize
(
builder
->
dfa
->
states
)
>
STATE_LIMIT
)
{
// Too many state;
//
}
}
}
taosArrayDestroy
(
states
);
taosHashCleanup
(
seen
);
return
builder
->
dfa
;
}
bool
dfaBuilderRunState
(
FstDfaBuilder
*
builder
,
FstSparseSet
*
cur
,
FstSparseSet
*
next
,
uint32_t
state
,
uint8_t
byte
s
,
bool
dfaBuilderRunState
(
FstDfaBuilder
*
builder
,
FstSparseSet
*
cur
,
FstSparseSet
*
next
,
uint32_t
state
,
uint8_t
byte
,
uint32_t
*
result
)
{
// impl run state
return
true
;
sparSetClear
(
cur
);
State
*
t
=
taosArrayGet
(
builder
->
dfa
->
states
,
state
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
t
->
insts
);
i
++
)
{
uint32_t
ip
=
*
(
int32_t
*
)
taosArrayGet
(
t
->
insts
,
i
);
sparSetAdd
(
cur
,
ip
);
}
dfaRun
(
builder
->
dfa
,
cur
,
next
,
byte
);
t
=
taosArrayGet
(
builder
->
dfa
->
states
,
state
);
uint32_t
nxtState
;
if
(
dfaBuilderCachedState
(
builder
,
next
,
&
nxtState
))
{
t
->
next
[
byte
]
=
nxtState
;
*
result
=
nxtState
;
return
true
;
}
return
false
;
}
bool
dfaBuilderCachedState
(
FstDfaBuilder
*
builder
,
FstSparseSet
*
set
,
uint32_t
*
result
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录