Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e769d0a0
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
e769d0a0
编写于
11月 22, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor builder struct
上级
06fe44ca
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
14 deletion
+33
-14
source/libs/index/inc/index_fst.h
source/libs/index/inc/index_fst.h
+8
-1
source/libs/index/inc/index_fst_util.h
source/libs/index/inc/index_fst_util.h
+3
-3
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+18
-4
source/libs/index/src/index_fst_util.c
source/libs/index/src/index_fst_util.c
+4
-6
未找到文件。
source/libs/index/inc/index_fst.h
浏览文件 @
e769d0a0
...
@@ -36,6 +36,8 @@ typedef struct FstRange {
...
@@ -36,6 +36,8 @@ typedef struct FstRange {
typedef
enum
{
OneTransNext
,
OneTrans
,
AnyTrans
,
EmptyFinal
}
State
;
typedef
enum
{
OneTransNext
,
OneTrans
,
AnyTrans
,
EmptyFinal
}
State
;
typedef
enum
{
Included
,
Excluded
,
Unbounded
}
FstBound
;
typedef
enum
{
Included
,
Excluded
,
Unbounded
}
FstBound
;
typedef
enum
{
Ordered
,
OutOfOrdered
,
DuplicateKey
}
OrderType
;
/*
/*
...
@@ -66,11 +68,16 @@ typedef struct FstBuilder {
...
@@ -66,11 +68,16 @@ typedef struct FstBuilder {
FstCountingWriter
*
wrt
;
// The FST raw data is written directly to `wtr`.
FstCountingWriter
*
wrt
;
// The FST raw data is written directly to `wtr`.
FstUnFinishedNodes
*
unfinished
;
// The stack of unfinished nodes
FstUnFinishedNodes
*
unfinished
;
// The stack of unfinished nodes
FstRegistry
*
registry
;
// A map of finished nodes.
FstRegistry
*
registry
;
// A map of finished nodes.
SArray
*
last
;
// The last word added
FstSlice
last
;
// The last word added
CompiledAddr
lastAddr
;
// The address of the last compiled node
CompiledAddr
lastAddr
;
// The address of the last compiled node
uint64_t
len
;
// num of keys added
uint64_t
len
;
// num of keys added
}
FstBuilder
;
}
FstBuilder
;
FstBuilder
*
fstBuilderCreate
(
void
*
w
,
FstType
ty
);
OrderType
fstBuilderCheckLastKey
(
FstBuilder
*
b
,
FstSlice
bs
,
bool
ckDup
);
CompiledAddr
fstBuilderCompile
(
FstBuilder
*
b
,
FstBuilderNode
*
bn
);
typedef
struct
FstTransitions
{
typedef
struct
FstTransitions
{
FstNode
*
node
;
FstNode
*
node
;
...
...
source/libs/index/inc/index_fst_util.h
浏览文件 @
e769d0a0
...
@@ -70,11 +70,11 @@ CompiledAddr unpackDelta(char *data, uint64_t len, uint64_t nodeAddr);
...
@@ -70,11 +70,11 @@ CompiledAddr unpackDelta(char *data, uint64_t len, uint64_t nodeAddr);
typedef
struct
FstSlice
{
typedef
struct
FstSlice
{
uint8_t
*
data
;
uint8_t
*
data
;
uint64_t
dLen
;
uint64_t
dLen
;
u
int32_t
start
;
int32_t
start
;
u
int32_t
end
;
int32_t
end
;
}
FstSlice
;
}
FstSlice
;
FstSlice
fstSliceCopy
(
FstSlice
*
slice
,
uint32_t
start
,
u
int32_t
end
);
FstSlice
fstSliceCopy
(
FstSlice
*
slice
,
int32_t
start
,
int32_t
end
);
FstSlice
fstSliceCreate
(
uint8_t
*
data
,
uint64_t
dLen
);
FstSlice
fstSliceCreate
(
uint8_t
*
data
,
uint64_t
dLen
);
bool
fstSliceEmpty
(
FstSlice
*
slice
);
bool
fstSliceEmpty
(
FstSlice
*
slice
);
...
...
source/libs/index/src/index_fst.c
浏览文件 @
e769d0a0
...
@@ -300,16 +300,30 @@ FstBuilder *fstBuilderCreate(void *w, FstType ty) {
...
@@ -300,16 +300,30 @@ FstBuilder *fstBuilderCreate(void *w, FstType ty) {
b
->
wrt
=
fstCountingWriterCreate
(
w
);
b
->
wrt
=
fstCountingWriterCreate
(
w
);
b
->
unfinished
=
fstUnFinishedNodesCreate
();
b
->
unfinished
=
fstUnFinishedNodesCreate
();
b
->
registry
=
fstRegistryCreate
(
10000
,
2
)
;
b
->
registry
=
fstRegistryCreate
(
10000
,
2
)
;
b
->
last
=
NULL
;
b
->
last
=
fstSliceCreate
(
NULL
,
0
)
;
b
->
lastAddr
=
NONE_ADDRESS
;
b
->
lastAddr
=
NONE_ADDRESS
;
b
->
len
=
0
;
b
->
len
=
0
;
return
b
;
return
b
;
}
}
bool
fstBuilderCheckLastKey
(
FstBuilder
*
b
,
FstSlice
bs
,
bool
ckDupe
)
{
OrderType
fstBuilderCheckLastKey
(
FstBuilder
*
b
,
FstSlice
bs
,
bool
ckDup
)
{
return
true
;
FstSlice
*
input
=
&
bs
;
if
(
fstSliceEmpty
(
&
b
->
last
))
{
// deep copy or not
b
->
last
=
fstSliceCopy
(
&
bs
,
input
->
start
,
input
->
end
);
}
else
{
int
comp
=
fstSliceCompare
(
&
b
->
last
,
&
bs
);
if
(
comp
==
0
&&
ckDup
)
{
return
DuplicateKey
;
}
else
if
(
comp
==
1
)
{
return
OutOfOrdered
;
}
// deep copy or not
b
->
last
=
fstSliceCopy
(
&
bs
,
input
->
start
,
input
->
end
);
}
return
Ordered
;
}
}
CompiledAddr
fstBuilderCompile
(
FstBuilder
*
b
,
FstBuilderNode
*
bn
)
{
CompiledAddr
fstBuilderCompile
(
FstBuilder
*
b
,
FstBuilderNode
*
bn
)
{
if
(
FST_BUILDER_NODE_IS_FINAL
(
bn
)
if
(
FST_BUILDER_NODE_IS_FINAL
(
bn
)
...
...
source/libs/index/src/index_fst_util.c
浏览文件 @
e769d0a0
...
@@ -94,7 +94,7 @@ FstSlice fstSliceCreate(uint8_t *data, uint64_t dLen) {
...
@@ -94,7 +94,7 @@ FstSlice fstSliceCreate(uint8_t *data, uint64_t dLen) {
FstSlice
slice
=
{.
data
=
data
,
.
dLen
=
dLen
,
.
start
=
0
,
.
end
=
dLen
-
1
};
FstSlice
slice
=
{.
data
=
data
,
.
dLen
=
dLen
,
.
start
=
0
,
.
end
=
dLen
-
1
};
return
slice
;
return
slice
;
}
}
FstSlice
fstSliceCopy
(
FstSlice
*
slice
,
uint32_t
start
,
u
int32_t
end
)
{
FstSlice
fstSliceCopy
(
FstSlice
*
slice
,
int32_t
start
,
int32_t
end
)
{
FstSlice
t
;
FstSlice
t
;
if
(
start
>=
slice
->
dLen
||
end
>=
slice
->
dLen
||
start
>
end
)
{
if
(
start
>=
slice
->
dLen
||
end
>=
slice
->
dLen
||
start
>
end
)
{
t
.
data
=
NULL
;
t
.
data
=
NULL
;
...
@@ -111,12 +111,10 @@ bool fstSliceEmpty(FstSlice *slice) {
...
@@ -111,12 +111,10 @@ bool fstSliceEmpty(FstSlice *slice) {
return
slice
->
data
==
NULL
||
slice
->
dLen
<=
0
;
return
slice
->
data
==
NULL
||
slice
->
dLen
<=
0
;
}
}
int
fstSliceCompare
(
FstSlice
*
a
,
FstSlice
*
b
)
{
int
fstSliceCompare
(
FstSlice
*
a
,
FstSlice
*
b
)
{
u
int32_t
aLen
=
(
a
->
end
-
a
->
start
+
1
);
int32_t
aLen
=
(
a
->
end
-
a
->
start
+
1
);
u
int32_t
bLen
=
(
b
->
end
-
b
->
start
+
1
);
int32_t
bLen
=
(
b
->
end
-
b
->
start
+
1
);
u
int32_t
mLen
=
(
aLen
<
bLen
?
aLen
:
bLen
);
int32_t
mLen
=
(
aLen
<
bLen
?
aLen
:
bLen
);
for
(
int
i
=
0
;
i
<
mLen
;
i
++
)
{
for
(
int
i
=
0
;
i
<
mLen
;
i
++
)
{
uint8_t
x
=
a
->
data
[
i
+
a
->
start
];
uint8_t
x
=
a
->
data
[
i
+
a
->
start
];
uint8_t
y
=
b
->
data
[
i
+
b
->
start
];
uint8_t
y
=
b
->
data
[
i
+
b
->
start
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录