Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2aaa43a4
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看板
未验证
提交
2aaa43a4
编写于
12月 14, 2021
作者:
dengyihao
提交者:
GitHub
12月 14, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9082 from taosdata/feature/fst
update search framework
上级
f7ee9ced
6f3c49ee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
80 addition
and
9 deletion
+80
-9
source/libs/index/inc/index_fst_automation.h
source/libs/index/inc/index_fst_automation.h
+13
-2
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+16
-6
source/libs/index/src/index_fst_automation.c
source/libs/index/src/index_fst_automation.c
+51
-1
未找到文件。
source/libs/index/inc/index_fst_automation.h
浏览文件 @
2aaa43a4
...
...
@@ -20,6 +20,8 @@ extern "C" {
#endif
#include "index_fst_util.h"
typedef
struct
AutomationCtx
AutomationCtx
;
typedef
enum
AutomationType
{
...
...
@@ -42,14 +44,23 @@ typedef struct AutomationCtx {
}
AutomationCtx
;
typedef
enum
ValueType
{
FST_INT
,
FST_CHAR
,
FST_ARRAY
}
ValueType
;
typedef
enum
StartWithStateKind
{
Done
,
Running
}
StartWithStateKind
;
typedef
struct
StartWithStateValue
{
StartWithStateKind
kind
;
void
*
value
;
ValueType
type
;
union
{
int
val
;
char
*
ptr
;
SArray
*
arr
;
// add more type
}
;
}
StartWithStateValue
;
StartWithStateValue
*
startWithStateValueDump
(
StartWithStateValue
*
sv
);
typedef
struct
AutomationFunc
{
void
*
(
*
start
)(
AutomationCtx
*
ctx
)
;
bool
(
*
isMatch
)(
AutomationCtx
*
ctx
,
void
*
);
...
...
source/libs/index/src/index_fst.c
浏览文件 @
2aaa43a4
...
...
@@ -1322,6 +1322,7 @@ StreamWithStateResult *streamWithStateNextWith(StreamWithState *sws, StreamCallb
return
swsResultCreate
(
&
s
,
output
,
callback
(
start
));
}
}
SArray
*
nodes
=
taosArrayInit
(
8
,
sizeof
(
FstNode
*
));
while
(
taosArrayGetSize
(
sws
->
stack
)
>
0
)
{
StreamState
*
p
=
(
StreamState
*
)
taosArrayPop
(
sws
->
stack
);
if
(
p
->
trans
>=
FST_NODE_LEN
(
p
->
node
)
||
automFuncs
[
aut
->
type
].
canMatch
(
aut
,
p
->
autState
))
{
...
...
@@ -1337,8 +1338,8 @@ StreamWithStateResult *streamWithStateNextWith(StreamWithState *sws, StreamCallb
void
*
nextState
=
automFuncs
[
aut
->
type
].
accept
(
aut
,
p
->
autState
,
trn
.
inp
);
void
*
tState
=
callback
(
nextState
);
bool
isMatch
=
automFuncs
[
aut
->
type
].
isMatch
(
aut
,
nextState
);
//bool isMatch = sws->aut->isMatch(nextState);
FstNode
*
nextNode
=
fstGetNode
(
sws
->
fst
,
trn
.
addr
);
taosArrayPush
(
nodes
,
&
nextNode
);
taosArrayPush
(
sws
->
inp
,
&
(
trn
.
inp
));
if
(
FST_NODE_IS_FINAL
(
nextNode
))
{
...
...
@@ -1354,26 +1355,35 @@ StreamWithStateResult *streamWithStateNextWith(StreamWithState *sws, StreamCallb
StreamState
s2
=
{.
node
=
nextNode
,
.
trans
=
0
,
.
out
=
{.
null
=
false
,
.
out
=
out
},
.
autState
=
nextState
};
taosArrayPush
(
sws
->
stack
,
&
s2
);
uint8_t
*
buf
=
(
uint8_t
*
)
malloc
(
taosArrayGetSize
(
sws
->
inp
)
*
sizeof
(
uint8_t
));
for
(
uint32_t
i
=
0
;
i
<
taosArrayGetSize
(
sws
->
inp
);
i
++
)
{
uint8_t
*
t
=
(
uint8_t
*
)
taosArrayGet
(
sws
->
inp
,
i
);
buf
[
i
]
=
*
t
;
size_t
isz
=
taosArrayGetSize
(
sws
->
inp
);
uint8_t
*
buf
=
(
uint8_t
*
)
malloc
(
isz
*
sizeof
(
uint8_t
));
for
(
uint32_t
i
=
0
;
i
<
isz
;
i
++
)
{
buf
[
i
]
=
*
(
uint8_t
*
)
taosArrayGet
(
sws
->
inp
,
i
);
}
FstSlice
slice
=
fstSliceCreate
(
buf
,
taosArrayGetSize
(
sws
->
inp
));
if
(
fstBoundWithDataExceededBy
(
sws
->
endAt
,
&
slice
))
{
taosArrayDestroyEx
(
sws
->
stack
,
streamStateDestroy
);
sws
->
stack
=
(
SArray
*
)
taosArrayInit
(
256
,
sizeof
(
StreamState
));
free
(
buf
);
fstSliceDestroy
(
&
slice
);
return
NULL
;
}
if
(
FST_NODE_IS_FINAL
(
nextNode
)
&&
isMatch
)
{
FstOutput
fOutput
=
{.
null
=
false
,
.
out
=
out
+
FST_NODE_FINAL_OUTPUT
(
nextNode
)};
StreamWithStateResult
*
result
=
swsResultCreate
(
&
slice
,
fOutput
,
tState
);
StreamWithStateResult
*
result
=
swsResultCreate
(
&
slice
,
fOutput
,
tState
);
free
(
buf
);
fstSliceDestroy
(
&
slice
);
return
result
;
}
free
(
buf
);
fstSliceDestroy
(
&
slice
);
}
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
nodes
);
i
++
)
{
FstNode
**
node
=
(
FstNode
**
)
taosArrayGet
(
nodes
,
i
);
fstNodeDestroy
(
*
node
);
}
taosArrayDestroy
(
nodes
);
return
NULL
;
}
...
...
source/libs/index/src/index_fst_automation.c
浏览文件 @
2aaa43a4
...
...
@@ -16,9 +16,59 @@
#include "index_fst_automation.h"
StartWithStateValue
*
startWithStateValueCreate
(
StartWithStateKind
kind
,
ValueType
ty
,
void
*
val
)
{
StartWithStateValue
*
nsv
=
calloc
(
1
,
sizeof
(
StartWithStateValue
));
if
(
nsv
==
NULL
)
{
return
NULL
;
}
nsv
->
kind
=
kind
;
nsv
->
type
=
ty
;
if
(
ty
==
FST_INT
)
{
nsv
->
val
=
*
(
int
*
)
val
;
}
else
if
(
ty
==
FST_CHAR
)
{
size_t
len
=
strlen
((
char
*
)
val
);
nsv
->
ptr
=
(
char
*
)
calloc
(
1
,
len
+
1
);
memcpy
(
nsv
->
ptr
,
val
,
len
);
}
else
if
(
ty
==
FST_ARRAY
)
{
//TODO,
//nsv->arr = taosArrayFromList()
}
return
nsv
;
}
void
startWithStateValueDestroy
(
StartWithStateValue
*
sv
)
{
if
(
sv
==
NULL
)
{
return
;
}
if
(
sv
->
type
==
FST_INT
)
{
//
}
else
if
(
sv
->
type
==
FST_CHAR
)
{
free
(
sv
->
ptr
);
}
else
if
(
sv
->
type
==
FST_ARRAY
)
{
taosArrayDestroy
(
sv
->
arr
);
}
free
(
sv
);
}
StartWithStateValue
*
startWithStateValueDump
(
StartWithStateValue
*
sv
)
{
StartWithStateValue
*
nsv
=
calloc
(
1
,
sizeof
(
StartWithStateValue
));
if
(
nsv
==
NULL
)
{
return
NULL
;
}
nsv
->
kind
=
sv
->
kind
;
nsv
->
type
=
sv
->
type
;
if
(
nsv
->
type
==
FST_INT
)
{
nsv
->
val
=
sv
->
val
;
}
else
if
(
nsv
->
type
==
FST_CHAR
)
{
size_t
len
=
strlen
(
sv
->
ptr
);
nsv
->
ptr
=
(
char
*
)
calloc
(
1
,
len
+
1
);
memcpy
(
nsv
->
ptr
,
sv
->
ptr
,
len
);
}
else
if
(
nsv
->
type
==
FST_ARRAY
)
{
}
return
nsv
;
}
// prefix query, impl later
static
void
*
prefixStart
(
AutomationCtx
*
ctx
)
{
StartWithStateValue
*
data
=
(
StartWithStateValue
*
)(
ctx
->
data
);
return
data
;
};
static
bool
prefixIsMatch
(
AutomationCtx
*
ctx
,
void
*
data
)
{
...
...
@@ -86,7 +136,7 @@ AutomationCtx* automCtxCreate(void *data, AutomationType type) {
if
(
type
==
AUTOMATION_PREFIX
)
{
StartWithStateValue
*
swsv
=
(
StartWithStateValue
*
)
calloc
(
1
,
sizeof
(
StartWithStateValue
));
swsv
->
kind
=
Done
;
swsv
->
value
=
NULL
;
//
swsv->value = NULL;
ctx
->
data
=
(
void
*
)
swsv
;
}
else
if
(
type
==
AUTMMATION_MATCH
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录