Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0f682ca2
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0f682ca2
编写于
12月 03, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor builder struct
上级
5f0fd023
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
39 addition
and
10 deletion
+39
-10
source/libs/index/inc/index_fst_node.h
source/libs/index/inc/index_fst_node.h
+1
-0
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+0
-1
source/libs/index/src/index_fst_node.c
source/libs/index/src/index_fst_node.c
+28
-4
source/libs/index/src/index_fst_registry.c
source/libs/index/src/index_fst_registry.c
+4
-4
source/libs/index/test/indexTests.cpp
source/libs/index/test/indexTests.cpp
+6
-1
未找到文件。
source/libs/index/inc/index_fst_node.h
浏览文件 @
0f682ca2
...
...
@@ -46,6 +46,7 @@ FstBuilderNode *fstBuilderNodeClone(FstBuilderNode *src);
void
fstBuilderNodeCloneFrom
(
FstBuilderNode
*
dst
,
FstBuilderNode
*
src
);
//bool fstBuilderNodeCompileTo(FstBuilderNode *b, FstCountingWriter *wrt, CompiledAddr lastAddr, CompiledAddr startAddr);
bool
fstBuilderNodeEqual
(
FstBuilderNode
*
n1
,
FstBuilderNode
*
n2
);
void
fstBuilderNodeDestroy
(
FstBuilderNode
*
node
);
...
...
source/libs/index/src/index_fst.c
浏览文件 @
0f682ca2
...
...
@@ -167,7 +167,6 @@ uint64_t fstUnFinishedNodesFindCommPrefixAndSetOutput(FstUnFinishedNodes *node,
}
if
(
addPrefix
!=
0
)
{
fstBuilderNodeUnfinishedAddOutputPrefix
(
un
,
addPrefix
);
}
}
return
i
;
...
...
source/libs/index/src/index_fst_node.c
浏览文件 @
0f682ca2
...
...
@@ -18,7 +18,7 @@ FstBuilderNode *fstBuilderNodeDefault() {
FstBuilderNode
*
bn
=
malloc
(
sizeof
(
FstBuilderNode
));
bn
->
isFinal
=
false
;
bn
->
finalOutput
=
0
;
bn
->
trans
=
NULL
;
bn
->
trans
=
taosArrayInit
(
16
,
sizeof
(
FstTransition
))
;
return
bn
;
}
void
fstBuilderNodeDestroy
(
FstBuilderNode
*
node
)
{
...
...
@@ -27,6 +27,25 @@ void fstBuilderNodeDestroy(FstBuilderNode *node) {
taosArrayDestroy
(
node
->
trans
);
free
(
node
);
}
bool
fstBuilderNodeEqual
(
FstBuilderNode
*
n1
,
FstBuilderNode
*
n2
)
{
if
(
n1
==
n2
)
{
return
true
;
}
if
(
n1
->
isFinal
!=
n2
->
isFinal
||
n1
->
finalOutput
!=
n2
->
finalOutput
||
taosArrayGetSize
(
n1
->
trans
)
!=
taosArrayGetSize
(
n2
->
trans
))
{
return
false
;
}
size_t
sz
=
taosArrayGetSize
(
n1
->
trans
);
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstTransition
*
t1
=
taosArrayGet
(
n1
->
trans
,
i
);
FstTransition
*
t2
=
taosArrayGet
(
n2
->
trans
,
i
);
if
(
t1
->
inp
!=
t2
->
inp
||
t1
->
out
!=
t2
->
out
||
t1
->
addr
!=
t2
->
addr
)
{
return
false
;
}
}
return
true
;
}
FstBuilderNode
*
fstBuilderNodeClone
(
FstBuilderNode
*
src
)
{
FstBuilderNode
*
node
=
malloc
(
sizeof
(
FstBuilderNode
));
if
(
node
==
NULL
)
{
return
NULL
;
}
...
...
@@ -53,12 +72,17 @@ void fstBuilderNodeCloneFrom(FstBuilderNode *dst, FstBuilderNode *src) {
dst
->
isFinal
=
src
->
isFinal
;
dst
->
finalOutput
=
src
->
finalOutput
;
// avoid mem leak
//
release free
avoid mem leak
taosArrayDestroy
(
dst
->
trans
);
dst
->
trans
=
src
->
trans
;
src
->
trans
=
NULL
;
size_t
sz
=
taosArrayGetSize
(
src
->
trans
);
dst
->
trans
=
taosArrayInit
(
sz
,
sizeof
(
FstTransition
));
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstTransition
*
trn
=
taosArrayGet
(
src
->
trans
,
i
);
taosArrayPush
(
dst
->
trans
,
trn
);
}
}
//bool fstBuilderNodeCompileTo(FstBuilderNode *b, FstCountingWriter *wrt, CompiledAddr lastAddr, CompiledAddr startAddr) {
//size_t sz = taosArrayGetSize(b->trans);
...
...
source/libs/index/src/index_fst_registry.c
浏览文件 @
0f682ca2
...
...
@@ -112,7 +112,7 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
if
(
end
-
start
==
1
)
{
FstRegistryCell
*
cell
=
taosArrayGet
(
registry
->
table
,
start
);
//cell->isNode &&
if
(
cell
->
addr
!=
NONE_ADDRESS
&&
cell
->
node
==
bNode
)
{
if
(
cell
->
addr
!=
NONE_ADDRESS
&&
fstBuilderNodeEqual
(
cell
->
node
,
bNode
)
)
{
entry
->
state
=
FOUND
;
entry
->
addr
=
cell
->
addr
;
return
entry
;
...
...
@@ -123,13 +123,13 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
}
}
else
if
(
end
-
start
==
2
)
{
FstRegistryCell
*
cell1
=
taosArrayGet
(
registry
->
table
,
start
);
if
(
cell1
->
addr
!=
NONE_ADDRESS
&&
cell1
->
node
==
bNode
)
{
if
(
cell1
->
addr
!=
NONE_ADDRESS
&&
fstBuilderNodeEqual
(
cell1
->
node
,
bNode
)
)
{
entry
->
state
=
FOUND
;
entry
->
addr
=
cell1
->
addr
;
return
entry
;
}
FstRegistryCell
*
cell2
=
taosArrayGet
(
registry
->
table
,
start
+
1
);
if
(
cell2
->
addr
!=
NONE_ADDRESS
&&
cell2
->
node
==
bNode
)
{
if
(
cell2
->
addr
!=
NONE_ADDRESS
&&
fstBuilderNodeEqual
(
cell2
->
node
,
bNode
)
)
{
entry
->
state
=
FOUND
;
entry
->
addr
=
cell2
->
addr
;
// must swap here
...
...
@@ -147,7 +147,7 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
uint32_t
i
=
start
;
for
(;
i
<
end
;
i
++
)
{
FstRegistryCell
*
cell
=
(
FstRegistryCell
*
)
taosArrayGet
(
registry
->
table
,
i
);
if
(
cell
->
addr
!=
NONE_ADDRESS
&&
cell
->
node
==
bNode
)
{
if
(
cell
->
addr
!=
NONE_ADDRESS
&&
fstBuilderNodeEqual
(
cell
->
node
,
bNode
)
)
{
entry
->
state
=
FOUND
;
entry
->
addr
=
cell
->
addr
;
fstRegistryCellPromote
(
registry
->
table
,
i
,
start
);
...
...
source/libs/index/test/indexTests.cpp
浏览文件 @
0f682ca2
...
...
@@ -63,11 +63,16 @@
//}
int
main
(
int
argc
,
char
**
argv
)
{
std
::
string
str
(
"
Hello world
"
);
std
::
string
str
(
"
abc
"
);
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)
str
.
c_str
(),
str
.
size
());
Output
val
=
10
;
std
::
string
str1
(
"bcd"
);
FstSlice
key1
=
fstSliceCreate
((
uint8_t
*
)
str1
.
c_str
(),
str1
.
size
());
Output
val2
=
10
;
FstBuilder
*
b
=
fstBuilderCreate
(
NULL
,
1
);
fstBuilderInsert
(
b
,
key
,
val
);
fstBuilderInsert
(
b
,
key1
,
val2
);
fstBuilderFinish
(
b
);
fstBuilderDestroy
(
b
);
fstSliceDestroy
(
&
key
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录