Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
077b89db
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看板
提交
077b89db
编写于
11月 21, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add fst_registry
上级
d56dbb15
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
35 deletion
+42
-35
source/libs/index/inc/index_fst_node.h
source/libs/index/inc/index_fst_node.h
+2
-0
source/libs/index/inc/index_fst_registry.h
source/libs/index/inc/index_fst_registry.h
+5
-5
source/libs/index/src/index_fst_node.c
source/libs/index/src/index_fst_node.c
+11
-0
source/libs/index/src/index_fst_registry.c
source/libs/index/src/index_fst_registry.c
+24
-30
未找到文件。
source/libs/index/inc/index_fst_node.h
浏览文件 @
077b89db
...
...
@@ -33,4 +33,6 @@ typedef struct FstBuilderNode {
FstBuilderNode
*
fstBuilderNodeDefault
();
void
fstBuilderNodeCloneFrom
(
FstBuilderNode
*
dst
,
FstBuilderNode
*
src
);
#endif
source/libs/index/inc/index_fst_registry.h
浏览文件 @
077b89db
...
...
@@ -26,11 +26,11 @@ typedef struct FstRegistryCell {
typedef
struct
FstRegistryCache
{
SArray
*
cells
;
uint32_t
start
;
uint32_t
end
;
}
FstRegistryCache
;
//
typedef struct FstRegistryCache {
//
SArray *cells;
//
uint32_t start;
//
uint32_t end;
//
} FstRegistryCache;
typedef
enum
{
FOUND
,
NOTFOUND
,
REJECTED
}
FstRegistryEntryState
;
...
...
source/libs/index/src/index_fst_node.c
浏览文件 @
077b89db
...
...
@@ -22,3 +22,14 @@ FstBuilderNode *fstBuilderNodeDefault() {
return
bn
;
}
// not destroy src, User's bussiness
void
fstBuilderNodeCloneFrom
(
FstBuilderNode
*
dst
,
FstBuilderNode
*
src
)
{
if
(
dst
==
NULL
||
src
==
NULL
)
{
return
;
}
dst
->
isFinal
=
src
->
isFinal
;
dst
->
finalOutput
=
src
->
finalOutput
;
dst
->
trans
=
src
->
trans
;
src
->
trans
=
NULL
;
}
source/libs/index/src/index_fst_registry.c
浏览文件 @
077b89db
...
...
@@ -16,6 +16,23 @@
#include "index_fst_registry.h"
uint64_t
fstRegistryHash
(
FstRegistry
*
registry
,
FstBuilderNode
*
bNode
)
{
//TODO(yihaoDeng): refactor later
const
uint64_t
FNV_PRIME
=
1099511628211
;
uint64_t
h
=
14695981039346656037u
;
h
=
(
h
^
(
uint64_t
)
bNode
->
isFinal
)
*
FNV_PRIME
;
h
=
(
h
^
(
bNode
)
->
finalOutput
)
*
FNV_PRIME
;
uint32_t
sz
=
(
uint32_t
)
taosArrayGetSize
(
bNode
->
trans
);
for
(
uint32_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstTransition
*
trn
=
taosArrayGet
(
bNode
->
trans
,
i
);
h
=
(
h
^
(
uint64_t
)(
trn
->
inp
))
*
FNV_PRIME
;
h
=
(
h
^
(
uint64_t
)(
trn
->
out
))
*
FNV_PRIME
;
h
=
(
h
^
(
uint64_t
)(
trn
->
addr
))
*
FNV_PRIME
;
}
return
h
%
(
registry
->
tableSize
);
}
static
void
fstRegistryCellSwap
(
SArray
*
arr
,
uint32_t
a
,
uint32_t
b
)
{
size_t
sz
=
taosArrayGetSize
(
arr
);
if
(
a
>=
sz
||
b
>=
sz
)
{
return
;
}
...
...
@@ -46,6 +63,9 @@ static void fstRegistryCellPromote(SArray *arr, uint32_t start, uint32_t end) {
s
-=
1
;
}
}
#define FST_REGISTRY_CELL_IS_EMPTY(cell) (cell->addr == NONE_ADDRESS)
#define FST_REGISTRY_CELL_INSERT(cell, addr) do {cell->addr = addr;} while(0)
FstRegistry
*
fstRegistryCreate
(
uint64_t
tableSize
,
uint64_t
mruSize
)
{
FstRegistry
*
registry
=
malloc
(
sizeof
(
FstRegistry
));
if
(
registry
==
NULL
)
{
return
NULL
;}
...
...
@@ -82,11 +102,8 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
return
entry
;
}
else
{
// clone from bNode, refactor later
cell
->
node
->
isFinal
=
bNode
->
isFinal
;
cell
->
node
->
finalOutput
=
bNode
->
finalOutput
;
cell
->
node
->
trans
=
bNode
->
trans
;
bNode
->
trans
=
NULL
;
//
fstBuilderNodeCloneFrom
(
cell
->
node
,
bNode
);
entry
->
state
=
NOTFOUND
;
entry
->
cell
=
cell
;
// copy or not
}
...
...
@@ -106,10 +123,7 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
return
entry
;
}
//clone from bNode, refactor later
cell1
->
node
->
isFinal
=
bNode
->
isFinal
;
cell1
->
node
->
finalOutput
=
bNode
->
finalOutput
;
cell1
->
node
->
trans
=
bNode
->
trans
;
bNode
->
trans
=
NULL
;
fstBuilderNodeCloneFrom
(
cell2
->
node
,
bNode
);
fstRegistryCellSwap
(
registry
->
table
,
start
,
start
+
1
);
FstRegistryCell
*
cCell
=
taosArrayGet
(
registry
->
table
,
start
);
...
...
@@ -130,10 +144,7 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
uint64_t
last
=
end
-
1
;
FstRegistryCell
*
cell
=
(
FstRegistryCell
*
)
taosArrayGet
(
registry
->
table
,
last
);
//clone from bNode, refactor later
cell
->
node
->
isFinal
=
bNode
->
isFinal
;
cell
->
node
->
finalOutput
=
bNode
->
finalOutput
;
cell
->
node
->
trans
=
bNode
->
trans
;
bNode
->
trans
=
NULL
;
fstBuilderNodeCloneFrom
(
cell
->
node
,
bNode
);
fstRegistryCellPromote
(
registry
->
table
,
last
,
start
);
FstRegistryCell
*
cCell
=
taosArrayGet
(
registry
->
table
,
start
);
...
...
@@ -144,21 +155,4 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
return
entry
;
}
uint64_t
fstRegistryHash
(
FstRegistry
*
registry
,
FstBuilderNode
*
bNode
)
{
//TODO(yihaoDeng): refactor later
const
uint64_t
FNV_PRIME
=
1099511628211
;
uint64_t
h
=
14695981039346656037u
;
h
=
(
h
^
(
uint64_t
)
bNode
->
isFinal
)
*
FNV_PRIME
;
h
=
(
h
^
(
bNode
)
->
finalOutput
)
*
FNV_PRIME
;
uint32_t
sz
=
(
uint32_t
)
taosArrayGetSize
(
bNode
->
trans
);
for
(
uint32_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstTransition
*
trn
=
taosArrayGet
(
bNode
->
trans
,
i
);
h
=
(
h
^
(
uint64_t
)(
trn
->
inp
))
*
FNV_PRIME
;
h
=
(
h
^
(
uint64_t
)(
trn
->
out
))
*
FNV_PRIME
;
h
=
(
h
^
(
uint64_t
)(
trn
->
addr
))
*
FNV_PRIME
;
}
return
h
%
(
registry
->
tableSize
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录