Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b9ebda67
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看板
提交
b9ebda67
编写于
2月 23, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/qnode
上级
aa556cb4
80b8ca72
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
28 deletion
+36
-28
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+35
-28
source/libs/index/test/fstUT.cc
source/libs/index/test/fstUT.cc
+1
-0
未找到文件。
source/libs/index/src/index_tfile.c
浏览文件 @
b9ebda67
...
@@ -598,25 +598,23 @@ static int tfileReaderLoadHeader(TFileReader* reader) {
...
@@ -598,25 +598,23 @@ static int tfileReaderLoadHeader(TFileReader* reader) {
return
0
;
return
0
;
}
}
static
int
tfileReaderLoadFst
(
TFileReader
*
reader
)
{
static
int
tfileReaderLoadFst
(
TFileReader
*
reader
)
{
// current load fst into memory, refactor it later
WriterCtx
*
ctx
=
reader
->
ctx
;
static
int
FST_MAX_SIZE
=
64
*
1024
*
1024
;
int
size
=
ctx
->
size
(
ctx
)
;
char
*
buf
=
calloc
(
1
,
sizeof
(
char
)
*
FST_MAX_SIZE
);
// current load fst into memory, refactor it later
int
fstSize
=
size
-
reader
->
header
.
fstOffset
-
sizeof
(
tfileMagicNumber
);
char
*
buf
=
calloc
(
1
,
fstSize
);
if
(
buf
==
NULL
)
{
if
(
buf
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
WriterCtx
*
ctx
=
reader
->
ctx
;
int
size
=
ctx
->
size
(
ctx
);
int64_t
ts
=
taosGetTimestampUs
();
int64_t
ts
=
taosGetTimestampUs
();
int32_t
nread
=
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
buf
,
fstSize
,
reader
->
header
.
fstOffset
);
ctx
->
readFrom
(
ctx
,
buf
,
size
-
reader
->
header
.
fstOffset
-
sizeof
(
tfileMagicNumber
),
reader
->
header
.
fstOffset
);
int64_t
cost
=
taosGetTimestampUs
()
-
ts
;
int64_t
cost
=
taosGetTimestampUs
()
-
ts
;
indexInfo
(
"nread = %d, and fst offset=%d, filename: %s, size: %d, time cost: %"
PRId64
"us"
,
nread
,
indexInfo
(
"nread = %d, and fst offset=%d,
size: %d,
filename: %s, size: %d, time cost: %"
PRId64
"us"
,
nread
,
reader
->
header
.
fstOffset
,
ctx
->
file
.
buf
,
ctx
->
file
.
size
,
cost
);
reader
->
header
.
fstOffset
,
fstSize
,
ctx
->
file
.
buf
,
ctx
->
file
.
size
,
cost
);
// we assuse fst size less than FST_MAX_SIZE
// we assuse fst size less than FST_MAX_SIZE
assert
(
nread
>
0
&&
nread
<
FST_MAX_SIZE
);
assert
(
nread
>
0
&&
nread
<
=
fstSize
);
FstSlice
st
=
fstSliceCreate
((
uint8_t
*
)
buf
,
nread
);
FstSlice
st
=
fstSliceCreate
((
uint8_t
*
)
buf
,
nread
);
reader
->
fst
=
fstCreate
(
&
st
);
reader
->
fst
=
fstCreate
(
&
st
);
...
@@ -626,25 +624,35 @@ static int tfileReaderLoadFst(TFileReader* reader) {
...
@@ -626,25 +624,35 @@ static int tfileReaderLoadFst(TFileReader* reader) {
return
reader
->
fst
!=
NULL
?
0
:
-
1
;
return
reader
->
fst
!=
NULL
?
0
:
-
1
;
}
}
static
int
tfileReaderLoadTableIds
(
TFileReader
*
reader
,
int32_t
offset
,
SArray
*
result
)
{
static
int
tfileReaderLoadTableIds
(
TFileReader
*
reader
,
int32_t
offset
,
SArray
*
result
)
{
int32_t
nid
;
// TODO(yihao): opt later
WriterCtx
*
ctx
=
reader
->
ctx
;
WriterCtx
*
ctx
=
reader
->
ctx
;
char
block
[
1024
]
=
{
0
};
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
block
,
sizeof
(
block
),
offset
);
assert
(
nread
>=
sizeof
(
uint32_t
));
char
*
p
=
block
;
int32_t
nid
=
*
(
int32_t
*
)
p
;
p
+=
sizeof
(
nid
);
while
(
nid
>
0
)
{
int32_t
left
=
block
+
sizeof
(
block
)
-
p
;
if
(
left
>=
sizeof
(
uint64_t
))
{
taosArrayPush
(
result
,
(
uint64_t
*
)
p
);
p
+=
sizeof
(
uint64_t
);
}
else
{
char
buf
[
sizeof
(
uint64_t
)]
=
{
0
};
memcpy
(
buf
,
p
,
left
);
int32_t
nread
=
ctx
->
readFrom
(
ctx
,
(
char
*
)
&
nid
,
sizeof
(
nid
),
offset
);
memset
(
block
,
0
,
sizeof
(
block
));
assert
(
sizeof
(
nid
)
==
nread
);
offset
+=
sizeof
(
block
);
nread
=
ctx
->
readFrom
(
ctx
,
block
,
sizeof
(
block
),
offset
);
int32_t
total
=
sizeof
(
uint64_t
)
*
nid
;
memcpy
(
buf
+
left
,
block
,
sizeof
(
uint64_t
)
-
left
);
char
*
buf
=
calloc
(
1
,
total
);
if
(
buf
==
NULL
)
{
return
-
1
;
}
nread
=
ctx
->
readFrom
(
ctx
,
buf
,
total
,
offset
+
sizeof
(
nid
));
assert
(
total
==
nread
);
for
(
int32_t
i
=
0
;
i
<
nid
;
i
++
)
{
taosArrayPush
(
result
,
(
uint64_t
*
)
buf
);
taosArrayPush
(
result
,
(
uint64_t
*
)
buf
+
i
);
p
=
block
+
sizeof
(
uint64_t
)
-
left
;
}
nid
-=
1
;
}
}
free
(
buf
);
return
0
;
return
0
;
}
}
static
int
tfileReaderVerify
(
TFileReader
*
reader
)
{
static
int
tfileReaderVerify
(
TFileReader
*
reader
)
{
...
@@ -686,11 +694,10 @@ void tfileReaderUnRef(TFileReader* reader) {
...
@@ -686,11 +694,10 @@ void tfileReaderUnRef(TFileReader* reader) {
}
}
static
SArray
*
tfileGetFileList
(
const
char
*
path
)
{
static
SArray
*
tfileGetFileList
(
const
char
*
path
)
{
SArray
*
files
=
taosArrayInit
(
4
,
sizeof
(
void
*
));
char
buf
[
128
]
=
{
0
};
char
buf
[
128
]
=
{
0
};
uint64_t
suid
;
uint64_t
suid
;
uint32_t
version
;
uint32_t
version
;
SArray
*
files
=
taosArrayInit
(
4
,
sizeof
(
void
*
));
DIR
*
dir
=
opendir
(
path
);
DIR
*
dir
=
opendir
(
path
);
if
(
NULL
==
dir
)
{
if
(
NULL
==
dir
)
{
...
...
source/libs/index/test/fstUT.cc
浏览文件 @
b9ebda67
...
@@ -230,3 +230,4 @@ TEST_F(FstEnv, writeNormal) {
...
@@ -230,3 +230,4 @@ TEST_F(FstEnv, writeNormal) {
assert
(
fst
->
Get
(
"aa"
,
&
val
)
==
true
);
assert
(
fst
->
Get
(
"aa"
,
&
val
)
==
true
);
assert
(
val
==
0
);
assert
(
val
==
0
);
}
}
TEST_F
(
FstEnv
,
writeExcpet
)
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录