Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
278fc0f6
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看板
未验证
提交
278fc0f6
编写于
12月 04, 2021
作者:
dengyihao
提交者:
GitHub
12月 04, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8930 from taosdata/origin/3.0/fst
refactor builder struct
上级
19427a9b
d0844e5d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
27 deletion
+39
-27
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+17
-14
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+4
-1
source/libs/index/src/index_fst_node.c
source/libs/index/src/index_fst_node.c
+13
-7
source/libs/index/test/indexTests.cpp
source/libs/index/test/indexTests.cpp
+5
-5
未找到文件。
source/libs/index/src/index_fst.c
浏览文件 @
278fc0f6
...
...
@@ -62,7 +62,7 @@ FstBuilderNode *fstUnFinishedNodesPopRoot(FstUnFinishedNodes *nodes) {
assert
(
taosArrayGetSize
(
nodes
->
stack
)
==
1
);
FstBuilderNodeUnfinished
*
un
=
taosArrayPop
(
nodes
->
stack
);
assert
(
un
->
last
==
NULL
);
//
assert(un->last == NULL);
return
un
->
node
;
}
...
...
@@ -70,6 +70,7 @@ FstBuilderNode *fstUnFinishedNodesPopFreeze(FstUnFinishedNodes *nodes, CompiledA
FstBuilderNodeUnfinished
*
un
=
taosArrayPop
(
nodes
->
stack
);
fstBuilderNodeUnfinishedLastCompiled
(
un
,
addr
);
free
(
un
->
last
);
// TODO add func FstLastTransitionFree()
un
->
last
=
NULL
;
return
un
->
node
;
}
...
...
@@ -99,8 +100,6 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes *nodes, FstSlice bs, Output
FstBuilderNodeUnfinished
*
un
=
taosArrayGet
(
nodes
->
stack
,
sz
);
assert
(
un
->
last
==
NULL
);
//FstLastTransition *trn = malloc(sizeof(FstLastTransition));
//trn->inp = s->data[s->start];
//trn->out = out;
...
...
@@ -108,7 +107,7 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes *nodes, FstSlice bs, Output
uint8_t
*
data
=
fstSliceData
(
s
,
&
len
);
un
->
last
=
fstLastTransitionCreate
(
data
[
0
],
out
);
for
(
uint64_t
i
=
0
;
i
<
len
;
i
++
)
{
for
(
uint64_t
i
=
1
;
i
<
len
;
i
++
)
{
FstBuilderNode
*
n
=
malloc
(
sizeof
(
FstBuilderNode
));
n
->
isFinal
=
false
;
n
->
finalOutput
=
0
;
...
...
@@ -117,7 +116,7 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes *nodes, FstSlice bs, Output
//FstLastTransition *trn = malloc(sizeof(FstLastTransition));
//trn->inp = s->data[i];
//trn->out = out;
FstLastTransition
*
trn
=
fstLastTransitionCreate
(
data
[
i
],
out
);
FstLastTransition
*
trn
=
fstLastTransitionCreate
(
data
[
i
],
0
);
FstBuilderNodeUnfinished
un
=
{.
node
=
n
,
.
last
=
trn
};
taosArrayPush
(
nodes
->
stack
,
&
un
);
...
...
@@ -131,8 +130,8 @@ uint64_t fstUnFinishedNodesFindCommPrefix(FstUnFinishedNodes *node, FstSlice bs)
size_t
ssz
=
taosArrayGetSize
(
node
->
stack
);
// stack size
uint64_t
count
=
0
;
int32_t
lsz
;
// data len
uint8_t
*
data
=
fstSliceData
(
s
,
&
lsz
);
int32_t
lsz
;
// data len
uint8_t
*
data
=
fstSliceData
(
s
,
&
lsz
);
for
(
size_t
i
=
0
;
i
<
ssz
&&
i
<
lsz
;
i
++
)
{
FstBuilderNodeUnfinished
*
un
=
taosArrayGet
(
node
->
stack
,
i
);
if
(
un
->
last
->
inp
==
data
[
i
])
{
...
...
@@ -854,7 +853,7 @@ void fstBuilderCompileFrom(FstBuilder *b, uint64_t istate) {
}
else
{
n
=
fstUnFinishedNodesPopFreeze
(
b
->
unfinished
,
addr
);
}
addr
=
fstBuilderCompile
(
b
,
n
);
addr
=
fstBuilderCompile
(
b
,
n
);
assert
(
addr
!=
NONE_ADDRESS
);
//fstBuilderNodeDestroy(n);
}
...
...
@@ -890,22 +889,26 @@ void* fstBuilderInsertInner(FstBuilder *b) {
FstBuilderNode
*
rootNode
=
fstUnFinishedNodesPopRoot
(
b
->
unfinished
);
CompiledAddr
rootAddr
=
fstBuilderCompile
(
b
,
rootNode
);
uint8_t
buf64
[
8
]
=
{
0
};
char
buf64
[
8
]
=
{
0
};
taosEncodeFixedU64
((
void
**
)
&
buf64
,
b
->
len
);
void
*
pBuf64
=
buf64
;
taosEncodeFixedU64
(
&
pBuf64
,
b
->
len
);
fstCountingWriterWrite
(
b
->
wrt
,
buf64
,
sizeof
(
buf64
));
taosEncodeFixedU64
((
void
**
)
&
buf64
,
rootAddr
);
pBuf64
=
buf64
;
taosEncodeFixedU64
(
&
pBuf64
,
rootAddr
);
fstCountingWriterWrite
(
b
->
wrt
,
buf64
,
sizeof
(
buf64
));
uint8_t
buf32
[
4
]
=
{
0
};
char
buf32
[
4
]
=
{
0
};
void
*
pBuf32
=
buf32
;
uint32_t
sum
=
fstCountingWriterMaskedCheckSum
(
b
->
wrt
);
taosEncodeFixedU32
(
(
void
**
)
&
b
uf32
,
sum
);
taosEncodeFixedU32
(
&
pB
uf32
,
sum
);
fstCountingWriterWrite
(
b
->
wrt
,
buf32
,
sizeof
(
buf32
));
fstCountingWriterFlush
(
b
->
wrt
);
//fstCountingWriterDestroy(b->wrt);
//b->wrt = NULL;
return
b
->
wrt
;
}
void
fstBuilderFinish
(
FstBuilder
*
b
)
{
fstBuilderInsertInner
(
b
);
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
278fc0f6
...
...
@@ -52,9 +52,12 @@ WriterCtx* writerCtxCreate(WriterType type) {
WriterCtx
*
ctx
=
calloc
(
1
,
sizeof
(
WriterCtx
));
if
(
ctx
==
NULL
)
{
return
NULL
;
}
ctx
->
type
=
=
type
;
ctx
->
type
=
type
;
if
(
ctx
->
type
==
TFile
)
{
ctx
->
fd
=
tfOpenCreateWriteAppend
(
tmpFile
);
if
(
ctx
->
fd
<
0
)
{
}
}
else
if
(
ctx
->
type
==
TMemory
)
{
ctx
->
mem
=
calloc
(
1
,
DefaultMem
*
sizeof
(
uint8_t
));
}
...
...
source/libs/index/src/index_fst_node.c
浏览文件 @
278fc0f6
...
...
@@ -30,20 +30,26 @@ void fstBuilderNodeDestroy(FstBuilderNode *node) {
bool
fstBuilderNodeEqual
(
FstBuilderNode
*
n1
,
FstBuilderNode
*
n2
)
{
if
(
n1
==
n2
)
{
return
true
;
}
if
(
n1
==
NULL
||
n2
==
NULL
)
{
return
false
;
}
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
++
)
{
if
(
n1
->
isFinal
!=
n2
->
isFinal
||
n1
->
finalOutput
!=
n2
->
finalOutput
)
{
return
false
;
}
size_t
s1
=
n1
->
trans
?
taosArrayGetSize
(
n1
->
trans
)
:
0
;
size_t
s2
=
n2
->
trans
?
taosArrayGetSize
(
n2
->
trans
)
:
0
;
if
(
s1
!=
s2
)
{
return
false
;
}
for
(
size_t
i
=
0
;
i
<
s1
;
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
)
{
...
...
source/libs/index/test/indexTests.cpp
浏览文件 @
278fc0f6
...
...
@@ -65,14 +65,14 @@
int
main
(
int
argc
,
char
**
argv
)
{
std
::
string
str
(
"abc"
);
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)
str
.
c_str
(),
str
.
size
());
Output
val
=
1
0
;
Output
val
=
1
;
std
::
string
str1
(
"bcd"
);
FstSlice
key1
=
fstSliceCreate
((
uint8_t
*
)
str1
.
c_str
(),
str1
.
size
());
Output
val2
=
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
);
//
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录