Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0bbe42df
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看板
提交
0bbe42df
编写于
11月 22, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile failure
上级
0cd12fd3
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
92 addition
and
16 deletion
+92
-16
source/libs/index/inc/index_fst.h
source/libs/index/inc/index_fst.h
+7
-1
source/libs/index/inc/index_fst_counting_writer.h
source/libs/index/inc/index_fst_counting_writer.h
+1
-0
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
+4
-1
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+51
-11
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+4
-2
source/libs/index/src/index_fst_node.c
source/libs/index/src/index_fst_node.c
+7
-1
source/libs/index/src/index_fst_registry.c
source/libs/index/src/index_fst_registry.c
+16
-0
未找到文件。
source/libs/index/inc/index_fst.h
浏览文件 @
0bbe42df
...
...
@@ -50,6 +50,7 @@ typedef struct FstUnFinishedNodes {
#define FST_UNFINISHED_NODES_LEN(nodes) taosArrayGetSize(nodes->stack)
FstUnFinishedNodes
*
fstUnFinishedNodesCreate
();
void
fstUnFinishedNodesDestroy
(
FstUnFinishedNodes
*
node
);
void
fstUnFinishedNodesPushEmpty
(
FstUnFinishedNodes
*
nodes
,
bool
isFinal
);
FstBuilderNode
*
fstUnFinishedNodesPopRoot
(
FstUnFinishedNodes
*
nodes
);
FstBuilderNode
*
fstUnFinishedNodesPopFreeze
(
FstUnFinishedNodes
*
nodes
,
CompiledAddr
addr
);
...
...
@@ -58,7 +59,7 @@ void fstUnFinishedNodesSetRootOutput(FstUnFinishedNodes *node, Output out);
void
fstUnFinishedNodesTopLastFreeze
(
FstUnFinishedNodes
*
node
,
CompiledAddr
addr
);
void
fstUnFinishedNodesAddSuffix
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
,
Output
out
);
uint64_t
fstUnFinishedNodesFindCommPrefix
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
);
uint64_t
FstUnFinishedNodesFindCommPreif
xAndSetOutput
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
,
Output
in
,
Output
*
out
);
uint64_t
fstUnFinishedNodesFindCommPrefi
xAndSetOutput
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
,
Output
in
,
Output
*
out
);
typedef
struct
FstBuilder
{
...
...
@@ -122,6 +123,8 @@ typedef struct FstNode {
#define FST_NODE_ADDR(node) node->start
FstNode
*
fstNodeCreate
(
int64_t
version
,
CompiledAddr
addr
,
FstSlice
*
data
);
void
fstNodeDestroy
(
FstNode
*
fstNode
);
FstTransitions
fstNodeTransitionIter
(
FstNode
*
node
);
FstTransitions
*
fstNodeTransitions
(
FstNode
*
node
);
bool
fstNodeGetTransitionAt
(
FstNode
*
node
,
uint64_t
i
,
FstTransition
*
res
);
...
...
@@ -152,6 +155,9 @@ typedef struct FstIndexedValue {
uint64_t
value
;
}
FstIndexedValue
;
FstLastTransition
*
fstLastTransitionCreate
(
uint8_t
inp
,
Output
out
);
void
fstLastTransitionDestroy
(
FstLastTransition
*
trn
);
...
...
source/libs/index/inc/index_fst_counting_writer.h
浏览文件 @
0bbe42df
...
...
@@ -31,6 +31,7 @@ int FstCountingWriterFlush(FstCountingWriter *write);
FstCountingWriter
*
fstCountingWriterCreate
(
void
*
wtr
);
void
fstCountingWriterDestroy
(
FstCountingWriter
*
w
);
#define FST_WRITER_COUNT(writer) (writer->count)
...
...
source/libs/index/inc/index_fst_node.h
浏览文件 @
0bbe42df
...
...
@@ -43,4 +43,6 @@ void fstBuilderNodeCloneFrom(FstBuilderNode *dst, FstBuilderNode *src);
bool
fstBuilderNodeCompileTo
(
FstBuilderNode
*
b
,
FstCountingWriter
*
wrt
,
CompiledAddr
lastAddr
,
CompiledAddr
startAddr
);
void
fstBuilderNodeDestroy
(
FstBuilderNode
*
node
);
#endif
source/libs/index/inc/index_fst_registry.h
浏览文件 @
0bbe42df
...
...
@@ -46,14 +46,17 @@ typedef struct FstRegistryEntry {
// Registry relation function
typedef
struct
FstRegistry
{
SArray
*
table
;
SArray
*
table
;
//<FstRegistryCell>
uint64_t
tableSize
;
// num of rows
uint64_t
mruSize
;
// num of columns
}
FstRegistry
;
//
FstRegistry
*
fstRegistryCreate
(
uint64_t
tableSize
,
uint64_t
mruSize
);
void
fstRegistryDestroy
(
FstRegistry
*
registry
);
FstRegistryEntry
*
fstRegistryGetEntry
(
FstRegistry
*
registry
,
FstBuilderNode
*
bNode
);
void
fstRegistryEntryDestroy
(
FstRegistryEntry
*
entry
);
#endif
source/libs/index/src/index_fst.c
浏览文件 @
0bbe42df
...
...
@@ -24,6 +24,18 @@ FstUnFinishedNodes *fstUnFinishedNodesCreate() {
fstUnFinishedNodesPushEmpty
(
nodes
,
false
);
return
nodes
;
}
void
unFinishedNodeDestroyElem
(
void
*
elem
)
{
FstBuilderNodeUnfinished
*
b
=
(
FstBuilderNodeUnfinished
*
)
elem
;
fstBuilderNodeDestroy
(
b
->
node
);
free
(
b
->
last
);
}
void
fstUnFinishedNodeDestroy
(
FstUnFinishedNodes
*
nodes
)
{
if
(
nodes
==
NULL
)
{
return
;
}
taosArrayDestroyEx
(
nodes
->
stack
,
unFinishedNodeDestroyElem
);
free
(
nodes
);
}
void
fstUnFinishedNodesPushEmpty
(
FstUnFinishedNodes
*
nodes
,
bool
isFinal
)
{
FstBuilderNode
*
node
=
malloc
(
sizeof
(
FstBuilderNode
));
node
->
isFinal
=
isFinal
;
...
...
@@ -76,11 +88,11 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes *nodes, FstSlice bs, Output
assert
(
un
->
last
==
NULL
);
FstLastTransition
*
trn
=
malloc
(
sizeof
(
FstLastTransition
));
trn
->
inp
=
s
->
data
[
s
->
start
];
trn
->
out
=
out
;
un
->
last
=
trn
;
//FstLastTransition *trn = malloc(sizeof(FstLastTransition));
//trn->inp = s->data[s->start];
//trn->out = out;
un
->
last
=
fstLastTransitionCreate
(
s
->
data
[
s
->
start
],
out
);
for
(
uint64_t
i
=
s
->
start
;
i
<=
s
->
end
;
i
++
)
{
FstBuilderNode
*
n
=
malloc
(
sizeof
(
FstBuilderNode
));
...
...
@@ -88,9 +100,10 @@ void fstUnFinishedNodesAddSuffix(FstUnFinishedNodes *nodes, FstSlice bs, Output
n
->
finalOutput
=
0
;
n
->
trans
=
NULL
;
FstLastTransition
*
trn
=
malloc
(
sizeof
(
FstLastTransition
));
trn
->
inp
=
s
->
data
[
i
];
trn
->
out
=
out
;
//FstLastTransition *trn = malloc(sizeof(FstLastTransition));
//trn->inp = s->data[i];
//trn->out = out;
FstLastTransition
*
trn
=
fstLastTransitionCreate
(
s
->
data
[
i
],
out
);
FstBuilderNodeUnfinished
un
=
{.
node
=
n
,
.
last
=
trn
};
taosArrayPush
(
nodes
->
stack
,
&
un
);
...
...
@@ -116,7 +129,7 @@ uint64_t fstUnFinishedNodesFindCommPrefix(FstUnFinishedNodes *node, FstSlice bs)
}
return
count
;
}
uint64_t
F
stUnFinishedNodesFindCommPrefixAndSetOutput
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
,
Output
in
,
Output
*
out
)
{
uint64_t
f
stUnFinishedNodesFindCommPrefixAndSetOutput
(
FstUnFinishedNodes
*
node
,
FstSlice
bs
,
Output
in
,
Output
*
out
)
{
FstSlice
*
s
=
&
bs
;
size_t
lsz
=
(
size_t
)(
s
->
end
-
s
->
start
+
1
);
// data len
...
...
@@ -199,6 +212,10 @@ FstNode *fstNodeCreate(int64_t version, CompiledAddr addr, FstSlice *slice) {
}
return
n
;
}
void
fstNodeDestroy
(
FstNode
*
node
)
{
if
(
node
==
NULL
)
{
return
;
}
free
(
node
);
}
FstTransitions
*
fstNodeTransitions
(
FstNode
*
node
)
{
FstTransitions
*
t
=
malloc
(
sizeof
(
FstTransitions
));
if
(
NULL
==
t
)
{
...
...
@@ -291,6 +308,7 @@ FstBuilder *fstBuilderCreate(void *w, FstType ty) {
void
fstBuilderCheckLastKey
(
FstBuilder
*
b
,
FstSlice
bs
,
bool
ckDupe
)
{
return
;
}
CompiledAddr
fstBuilderCompile
(
FstBuilder
*
b
,
FstBuilderNode
*
bn
)
{
...
...
@@ -302,24 +320,46 @@ CompiledAddr fstBuilderCompile(FstBuilder *b, FstBuilderNode *bn) {
FstRegistryEntry
*
entry
=
fstRegistryGetEntry
(
b
->
registry
,
bn
);
if
(
entry
->
state
==
FOUND
)
{
CompiledAddr
ret
=
entry
->
addr
;
tfree
(
entry
);
fstRegistryEntryDestroy
(
entry
);
return
ret
;
}
CompiledAddr
startAddr
=
(
CompiledAddr
)(
FST_WRITER_COUNT
(
b
->
wrt
));
fstBuilderNodeCompileTo
(
bn
,
b
->
wrt
,
b
->
lastAddr
,
startAddr
);
b
->
lastAddr
=
(
CompiledAddr
)(
FST_WRITER_COUNT
(
b
->
wrt
)
)
-
1
;
b
->
lastAddr
=
(
CompiledAddr
)(
FST_WRITER_COUNT
(
b
->
wrt
)
-
1
)
;
if
(
entry
->
state
==
NOTFOUND
)
{
FST_REGISTRY_CELL_INSERT
(
entry
->
cell
,
b
->
lastAddr
);
}
free
(
entry
);
fstRegistryEntryDestroy
(
entry
);
return
b
->
lastAddr
;
}
FstSlice
fstNodeAsSlice
(
FstNode
*
node
)
{
FstSlice
*
slice
=
&
node
->
data
;
FstSlice
s
=
fstSliceCopy
(
slice
,
slice
->
end
,
slice
->
dLen
-
1
);
return
s
;
}
FstLastTransition
*
fstLastTransitionCreate
(
uint8_t
inp
,
Output
out
)
{
FstLastTransition
*
trn
=
malloc
(
sizeof
(
FstLastTransition
));
if
(
trn
==
NULL
)
{
return
NULL
;
}
trn
->
inp
=
inp
;
trn
->
out
=
out
;
return
trn
;
}
void
fstLastTransitionDestroy
(
FstLastTransition
*
trn
)
{
free
(
trn
);
}
void
fstBuilderNodeUnfinishedLastCompiled
(
FstBuilderNodeUnfinished
*
node
,
CompiledAddr
addr
)
{
return
;
}
void
fstBuilderNodeUnfinishedAddOutputPrefix
(
FstBuilderNodeUnfinished
*
node
,
CompiledAddr
addr
)
{
return
;
}
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
0bbe42df
...
...
@@ -12,15 +12,17 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tutil.h"
#include "index_fst_counting_writer.h"
FstCountingWriter
*
fstCountingWriterCreate
(
void
*
wrt
)
{
FstCountingWriter
*
cw
=
calloc
(
1
,
sizeof
(
FstCountingWriter
));
if
(
cw
==
NULL
)
{
return
NULL
;
}
cw
->
wrt
=
wrt
;
return
cw
;
}
void
F
stCountingWriterDestroy
(
FstCountingWriter
*
cw
)
{
void
f
stCountingWriterDestroy
(
FstCountingWriter
*
cw
)
{
// free wrt object: close fd or free mem
free
(
cw
);
}
...
...
source/libs/index/src/index_fst_node.c
浏览文件 @
0bbe42df
...
...
@@ -21,7 +21,12 @@ FstBuilderNode *fstBuilderNodeDefault() {
bn
->
trans
=
NULL
;
return
bn
;
}
void
fstBuilderNodeDestroy
(
FstBuilderNode
*
node
)
{
if
(
node
==
NULL
)
{
return
;
}
taosArrayDestroy
(
node
->
trans
);
free
(
node
);
}
FstBuilderNode
*
fstBuilderNodeClone
(
FstBuilderNode
*
src
)
{
FstBuilderNode
*
node
=
malloc
(
sizeof
(
FstBuilderNode
));
if
(
node
==
NULL
)
{
return
NULL
;
}
...
...
@@ -74,5 +79,6 @@ bool fstBuilderNodeCompileTo(FstBuilderNode *b, FstCountingWriter *wrt, Compiled
}
}
return
true
;
}
source/libs/index/src/index_fst_registry.c
浏览文件 @
0bbe42df
...
...
@@ -87,6 +87,19 @@ FstRegistry* fstRegistryCreate(uint64_t tableSize, uint64_t mruSize) {
return
registry
;
}
void
fstRegistryDestroy
(
FstRegistry
*
registry
)
{
if
(
registry
==
NULL
)
{
return
;
}
SArray
*
tb
=
registry
->
table
;
size_t
sz
=
taosArrayGetSize
(
tb
);
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
{
FstRegistryCell
*
cell
=
taosArrayGet
(
tb
,
i
);
fstBuilderNodeDestroy
(
cell
->
node
);
}
taosArrayDestroy
(
tb
);
free
(
registry
);
}
FstRegistryEntry
*
fstRegistryGetEntry
(
FstRegistry
*
registry
,
FstBuilderNode
*
bNode
)
{
if
(
taosArrayGetSize
(
registry
->
table
)
<=
0
)
{
return
NULL
;
...
...
@@ -155,5 +168,8 @@ FstRegistryEntry *fstRegistryGetEntry(FstRegistry *registry, FstBuilderNode *bNo
}
return
entry
;
}
void
fstRegistryEntryDestroy
(
FstRegistryEntry
*
entry
)
{
free
(
entry
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录