Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7e1f68f8
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看板
提交
7e1f68f8
编写于
12月 06, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor builder struct
上级
d0844e5d
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
54 addition
and
10 deletion
+54
-10
source/libs/index/inc/index_fst_util.h
source/libs/index/inc/index_fst_util.h
+22
-0
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+6
-4
source/libs/index/src/index_fst_util.c
source/libs/index/src/index_fst_util.c
+13
-0
source/libs/index/test/indexTests.cpp
source/libs/index/test/indexTests.cpp
+13
-6
未找到文件。
source/libs/index/inc/index_fst_util.h
浏览文件 @
7e1f68f8
...
@@ -93,6 +93,28 @@ uint8_t *fstSliceData(FstSlice *s, int32_t *sz);
...
@@ -93,6 +93,28 @@ uint8_t *fstSliceData(FstSlice *s, int32_t *sz);
#define FST_SLICE_LEN(s) (s->end - s->start + 1)
#define FST_SLICE_LEN(s) (s->end - s->start + 1)
//// stack
//
//typedef (*StackFreeElemFn)(void *elem);
//
//typedef struct FstStack {
// void *first;
// void *end;
// size_t elemSize;
// size_t nElem;
// StackFreeElemFn fn;
//} FstStack;
//
//
//FstStack* fstStackCreate(size_t elemSize, stackFreeElem);
//void *fstStackPush(FstStack *s, void *elem);
//void *fstStackTop(FstStack *s);
//size_t fstStackLen(FstStack *s);
//void fstStackDestory(FstStack *);
//
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/index/src/index_fst.c
浏览文件 @
7e1f68f8
...
@@ -40,6 +40,7 @@ void unFinishedNodeDestroyElem(void* elem) {
...
@@ -40,6 +40,7 @@ void unFinishedNodeDestroyElem(void* elem) {
FstBuilderNodeUnfinished
*
b
=
(
FstBuilderNodeUnfinished
*
)
elem
;
FstBuilderNodeUnfinished
*
b
=
(
FstBuilderNodeUnfinished
*
)
elem
;
fstBuilderNodeDestroy
(
b
->
node
);
fstBuilderNodeDestroy
(
b
->
node
);
free
(
b
->
last
);
free
(
b
->
last
);
b
->
last
=
NULL
;
}
}
void
fstUnFinishedNodesDestroy
(
FstUnFinishedNodes
*
nodes
)
{
void
fstUnFinishedNodesDestroy
(
FstUnFinishedNodes
*
nodes
)
{
if
(
nodes
==
NULL
)
{
return
;
}
if
(
nodes
==
NULL
)
{
return
;
}
...
@@ -62,15 +63,15 @@ FstBuilderNode *fstUnFinishedNodesPopRoot(FstUnFinishedNodes *nodes) {
...
@@ -62,15 +63,15 @@ FstBuilderNode *fstUnFinishedNodesPopRoot(FstUnFinishedNodes *nodes) {
assert
(
taosArrayGetSize
(
nodes
->
stack
)
==
1
);
assert
(
taosArrayGetSize
(
nodes
->
stack
)
==
1
);
FstBuilderNodeUnfinished
*
un
=
taosArrayPop
(
nodes
->
stack
);
FstBuilderNodeUnfinished
*
un
=
taosArrayPop
(
nodes
->
stack
);
//
assert(un->last == NULL);
assert
(
un
->
last
==
NULL
);
return
un
->
node
;
return
un
->
node
;
}
}
FstBuilderNode
*
fstUnFinishedNodesPopFreeze
(
FstUnFinishedNodes
*
nodes
,
CompiledAddr
addr
)
{
FstBuilderNode
*
fstUnFinishedNodesPopFreeze
(
FstUnFinishedNodes
*
nodes
,
CompiledAddr
addr
)
{
FstBuilderNodeUnfinished
*
un
=
taosArrayPop
(
nodes
->
stack
);
FstBuilderNodeUnfinished
*
un
=
taosArrayPop
(
nodes
->
stack
);
fstBuilderNodeUnfinishedLastCompiled
(
un
,
addr
);
fstBuilderNodeUnfinishedLastCompiled
(
un
,
addr
);
free
(
un
->
last
);
// TODO add func FstLastTransitionFree()
//
free(un->last); // TODO add func FstLastTransitionFree()
un
->
last
=
NULL
;
//
un->last = NULL;
return
un
->
node
;
return
un
->
node
;
}
}
...
@@ -937,9 +938,10 @@ void fstLastTransitionDestroy(FstLastTransition *trn) {
...
@@ -937,9 +938,10 @@ void fstLastTransitionDestroy(FstLastTransition *trn) {
void
fstBuilderNodeUnfinishedLastCompiled
(
FstBuilderNodeUnfinished
*
unNode
,
CompiledAddr
addr
)
{
void
fstBuilderNodeUnfinishedLastCompiled
(
FstBuilderNodeUnfinished
*
unNode
,
CompiledAddr
addr
)
{
FstLastTransition
*
trn
=
unNode
->
last
;
FstLastTransition
*
trn
=
unNode
->
last
;
if
(
trn
==
NULL
)
{
return
;
}
if
(
trn
==
NULL
)
{
return
;
}
FstTransition
t
=
{.
inp
=
trn
->
inp
,
.
out
=
trn
->
out
,
.
addr
=
addr
};
FstTransition
t
=
{.
inp
=
trn
->
inp
,
.
out
=
trn
->
out
,
.
addr
=
addr
};
taosArrayPush
(
unNode
->
node
->
trans
,
&
t
);
taosArrayPush
(
unNode
->
node
->
trans
,
&
t
);
fstLastTransitionDestroy
(
trn
);
unNode
->
last
=
NULL
;
return
;
return
;
}
}
...
...
source/libs/index/src/index_fst_util.c
浏览文件 @
7e1f68f8
...
@@ -174,5 +174,18 @@ int fstSliceCompare(FstSlice *a, FstSlice *b) {
...
@@ -174,5 +174,18 @@ int fstSliceCompare(FstSlice *a, FstSlice *b) {
else
{
return
0
;
}
else
{
return
0
;
}
}
}
//FstStack* fstStackCreate(size_t elemSize, StackFreeElem freeFn) {
// FstStack *s = calloc(1, sizeof(FstStack));
// if (s == NULL) { return NULL; }
// s->
// s->freeFn
//
//}
//void *fstStackPush(FstStack *s, void *elem);
//void *fstStackTop(FstStack *s);
//size_t fstStackLen(FstStack *s);
//void *fstStackGetAt(FstStack *s, size_t i);
//void fstStackDestory(FstStack *);
source/libs/index/test/indexTests.cpp
浏览文件 @
7e1f68f8
...
@@ -63,19 +63,26 @@
...
@@ -63,19 +63,26 @@
//}
//}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
FstBuilder
*
b
=
fstBuilderCreate
(
NULL
,
1
);
{
std
::
string
str
(
"abc"
);
std
::
string
str
(
"abc"
);
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)
str
.
c_str
(),
str
.
size
());
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)
str
.
c_str
(),
str
.
size
());
Output
val
=
1
;
Output
val
=
1
;
fstBuilderInsert
(
b
,
key
,
val
);
}
//std::string str1("bcd");
//std::string str1("bcd");
//FstSlice key1 = fstSliceCreate((uint8_t *)str1.c_str(), str1.size());
//FstSlice key1 = fstSliceCreate((uint8_t *)str1.c_str(), str1.size());
//Output val2 = 10;
//Output val2 = 10;
FstBuilder
*
b
=
fstBuilderCreate
(
NULL
,
1
);
{
std
::
string
str
(
"bcd"
);
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)
str
.
c_str
(),
str
.
size
());
Output
val
=
1
;
fstBuilderInsert
(
b
,
key
,
val
);
fstBuilderInsert
(
b
,
key
,
val
);
}
//fstBuilderInsert(b, key1, val2);
//fstBuilderInsert(b, key1, val2);
fstBuilderFinish
(
b
);
fstBuilderFinish
(
b
);
fstBuilderDestroy
(
b
);
fstBuilderDestroy
(
b
);
fstSliceDestroy
(
&
key
);
return
1
;
return
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录