Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
30d49687
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看板
提交
30d49687
编写于
3月 28, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update index query
上级
3f234959
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
72 addition
and
14 deletion
+72
-14
source/libs/index/inc/index_fst.h
source/libs/index/inc/index_fst.h
+7
-7
source/libs/index/src/index_fst.c
source/libs/index/src/index_fst.c
+2
-3
source/libs/index/test/fstTest.cc
source/libs/index/test/fstTest.cc
+63
-4
未找到文件。
source/libs/index/inc/index_fst.h
浏览文件 @
30d49687
...
...
@@ -21,9 +21,9 @@ extern "C" {
#endif
#include "indexInt.h"
#include "index_fst_node.h"
#include "index_fst_automation.h"
#include "index_fst_counting_writer.h"
#include "index_fst_node.h"
#include "index_fst_registry.h"
#include "index_fst_util.h"
...
...
@@ -257,9 +257,9 @@ typedef struct FstMeta {
}
FstMeta
;
typedef
struct
Fst
{
FstMeta
*
meta
;
FstSlice
*
data
;
//
FstNode
*
root
;
//
FstMeta
*
meta
;
FstSlice
*
data
;
//
FstNode
*
root
;
//
TdThreadMutex
mtx
;
}
Fst
;
...
...
@@ -325,10 +325,10 @@ StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallb
FstStreamBuilder
*
fstStreamBuilderCreate
(
Fst
*
fst
,
AutomationCtx
*
aut
);
void
fstStreamBuilderDestroy
(
FstStreamBuilder
*
b
);
// set up bound range
// refator, simple code by marco
FstStreamBuilder
*
fstStreamBuilderRange
(
FstStreamBuilder
*
b
,
FstSlice
*
val
,
RangeType
type
);
// set up bound range
// refator later: to simple code by marco
void
fstStreamBuilderSetRange
(
FstStreamBuilder
*
b
,
FstSlice
*
val
,
RangeType
type
);
#ifdef __cplusplus
}
...
...
source/libs/index/src/index_fst.c
浏览文件 @
30d49687
...
...
@@ -1425,9 +1425,9 @@ void fstStreamBuilderDestroy(FstStreamBuilder* b) {
taosMemoryFreeClear
(
b
->
max
);
taosMemoryFree
(
b
);
}
FstStreamBuilder
*
fstStreamBuilder
Range
(
FstStreamBuilder
*
b
,
FstSlice
*
val
,
RangeType
type
)
{
void
fstStreamBuilderSet
Range
(
FstStreamBuilder
*
b
,
FstSlice
*
val
,
RangeType
type
)
{
if
(
b
==
NULL
)
{
return
NULL
;
return
;
}
if
(
type
==
GE
)
{
b
->
min
->
type
=
Included
;
...
...
@@ -1446,5 +1446,4 @@ FstStreamBuilder* fstStreamBuilderRange(FstStreamBuilder* b, FstSlice* val, Rang
fstSliceDestroy
(
&
(
b
->
max
->
data
));
b
->
max
->
data
=
fstSliceDeepCopy
(
val
,
0
,
FST_SLICE_LEN
(
val
)
-
1
);
}
return
b
;
}
source/libs/index/test/fstTest.cc
浏览文件 @
30d49687
...
...
@@ -96,12 +96,36 @@ class FstReadMemory {
char
*
ch
=
(
char
*
)
fstSliceData
(
s
,
&
sz
);
std
::
string
key
(
ch
,
sz
);
printf
(
"key: %s, val: %"
PRIu64
"
\n
"
,
key
.
c_str
(),
(
uint64_t
)(
rt
->
out
.
out
));
swsResultDestroy
(
rt
);
result
.
push_back
(
rt
->
out
.
out
);
swsResultDestroy
(
rt
);
}
for
(
size_t
i
=
0
;
i
<
result
.
size
();
i
++
)
{
return
true
;
}
bool
SearchRange
(
AutomationCtx
*
ctx
,
const
std
::
string
&
low
,
const
std
::
string
&
high
,
std
::
vector
<
uint64_t
>&
result
)
{
FstStreamBuilder
*
sb
=
fstSearch
(
_fst
,
ctx
);
FstSlice
l
=
fstSliceCreate
((
uint8_t
*
)
low
.
c_str
(),
low
.
size
());
FstSlice
h
=
fstSliceCreate
((
uint8_t
*
)
high
.
c_str
(),
high
.
size
());
// range [low, high);
fstStreamBuilderSetRange
(
sb
,
&
l
,
GE
);
fstStreamBuilderSetRange
(
sb
,
&
h
,
LT
);
fstSliceDestroy
(
&
l
);
fstSliceDestroy
(
&
h
);
StreamWithState
*
st
=
streamBuilderIntoStream
(
sb
);
StreamWithStateResult
*
rt
=
NULL
;
while
((
rt
=
streamWithStateNextWith
(
st
,
NULL
))
!=
NULL
)
{
// result.push_back((uint64_t)(rt->out.out));
FstSlice
*
s
=
&
rt
->
data
;
int32_t
sz
=
0
;
char
*
ch
=
(
char
*
)
fstSliceData
(
s
,
&
sz
);
std
::
string
key
(
ch
,
sz
);
printf
(
"key: %s, val: %"
PRIu64
"
\n
"
,
key
.
c_str
(),
(
uint64_t
)(
rt
->
out
.
out
));
result
.
push_back
(
rt
->
out
.
out
);
swsResultDestroy
(
rt
);
}
std
::
cout
<<
std
::
endl
;
return
true
;
}
bool
SearchWithTimeCostUs
(
AutomationCtx
*
ctx
,
std
::
vector
<
uint64_t
>&
result
)
{
...
...
@@ -322,6 +346,40 @@ void checkFstCheckIteratorPrefix() {
}
delete
m
;
}
void
checkFstCheckIteratorRange
()
{
FstWriter
*
fw
=
new
FstWriter
;
int64_t
s
=
taosGetTimestampUs
();
int
count
=
2
;
// Performance_fstWriteRecords(fw);
int64_t
e
=
taosGetTimestampUs
();
std
::
cout
<<
"insert data count : "
<<
count
<<
"elapas time: "
<<
e
-
s
<<
std
::
endl
;
fw
->
Put
(
"a"
,
1
);
fw
->
Put
(
"b"
,
2
);
fw
->
Put
(
"c"
,
3
);
fw
->
Put
(
"d"
,
4
);
fw
->
Put
(
"e"
,
5
);
delete
fw
;
FstReadMemory
*
m
=
new
FstReadMemory
(
1024
*
64
);
if
(
m
->
init
()
==
false
)
{
std
::
cout
<<
"init readMemory failed"
<<
std
::
endl
;
delete
m
;
return
;
}
{
// prefix search
std
::
vector
<
uint64_t
>
result
;
AutomationCtx
*
ctx
=
automCtxCreate
((
void
*
)
"he"
,
AUTOMATION_ALWAYS
);
// [b, e)
m
->
SearchRange
(
ctx
,
"b"
,
"e"
,
result
);
// assert(result.size() == 1);
taosMemoryFree
(
ctx
);
}
}
void
fst_get
(
Fst
*
fst
)
{
for
(
int
i
=
0
;
i
<
10000
;
i
++
)
{
...
...
@@ -386,7 +444,8 @@ int main(int argc, char* argv[]) {
// iterTFileReader(argv[1], argv[2], argv[3], argv[4]);
//}
// checkFstCheckIterator();
checkFstCheckIteratorPrefix
();
// checkFstCheckIteratorPrefix();
checkFstCheckIteratorRange
();
// checkFstLongTerm();
// checkFstPrefixSearch();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录