Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
4d5c9347
M
milvus
项目概览
milvus
/
milvus
9 个月 前同步成功
通知
260
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
4d5c9347
编写于
8月 26, 2020
作者:
C
chen qingxiang
提交者:
GitHub
8月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the data type of crc32c (#3455)
Signed-off-by:
N
godchen0212
<
qingxiang.chen@zilliz.com
>
上级
e814fb5e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
15 deletion
+11
-15
core/src/storage/ExtraFileInfo.cpp
core/src/storage/ExtraFileInfo.cpp
+8
-12
core/src/storage/ExtraFileInfo.h
core/src/storage/ExtraFileInfo.h
+2
-2
core/src/storage/ExtraFileInfoTest.cpp
core/src/storage/ExtraFileInfoTest.cpp
+1
-1
未找到文件。
core/src/storage/ExtraFileInfo.cpp
浏览文件 @
4d5c9347
...
...
@@ -94,7 +94,7 @@ ReadHeaderValue(const storage::FSHandlerPtr& fs_ptr, const std::string& file_pat
return
kv
.
at
(
key
);
}
std
::
uint
8
_t
std
::
uint
32
_t
CalculateSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
,
bool
written
)
{
if
(
!
fs_ptr
->
reader_ptr_
->
Open
(
file_path
.
c_str
()))
{
std
::
string
err_msg
=
"Failed to open file: "
+
file_path
+
", error: "
+
std
::
strerror
(
errno
);
...
...
@@ -108,14 +108,14 @@ CalculateSum(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path,
}
char
*
ch
=
static_cast
<
char
*>
(
malloc
(
size
));
fs_ptr
->
reader_ptr_
->
Read
(
ch
,
size
);
std
::
uint
8
_t
result
=
crc32c
::
Crc32c
(
ch
,
size
);
std
::
uint
32
_t
result
=
crc32c
::
Crc32c
(
ch
,
size
);
fs_ptr
->
reader_ptr_
->
Close
();
free
(
ch
);
return
result
;
}
void
WriteSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
,
in
t
result
,
bool
written
)
{
WriteSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
,
uint32_
t
result
,
bool
written
)
{
if
(
!
fs_ptr
->
writer_ptr_
->
InOpen
(
file_path
.
c_str
()))
{
std
::
string
err_msg
=
"Failed to open file: "
+
file_path
+
", error: "
+
std
::
strerror
(
errno
);
LOG_ENGINE_ERROR_
<<
err_msg
;
...
...
@@ -128,29 +128,25 @@ WriteSum(const storage::FSHandlerPtr& fs_ptr, const std::string& file_path, int
fs_ptr
->
writer_ptr_
->
Seekp
(
0
,
std
::
ios_base
::
end
);
}
std
::
string
sum
=
std
::
to_string
(
result
);
sum
.
resize
(
SUM_SIZE
,
'\0'
);
fs_ptr
->
writer_ptr_
->
Write
(
sum
.
data
(),
SUM_SIZE
);
fs_ptr
->
writer_ptr_
->
Write
(
&
result
,
SUM_SIZE
);
fs_ptr
->
writer_ptr_
->
Close
();
}
bool
CheckSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
)
{
in
t
result
=
CalculateSum
(
fs_ptr
,
file_path
,
true
);
uint32_
t
result
=
CalculateSum
(
fs_ptr
,
file_path
,
true
);
if
(
!
fs_ptr
->
reader_ptr_
->
Open
(
file_path
.
c_str
()))
{
std
::
string
err_msg
=
"Failed to open file: "
+
file_path
+
", error: "
+
std
::
strerror
(
errno
);
LOG_ENGINE_ERROR_
<<
err_msg
;
throw
Exception
(
SERVER_WRITE_ERROR
,
err_msg
);
}
fs_ptr
->
reader_ptr_
->
Seekg
(
-
SUM_SIZE
,
std
::
ios_base
::
end
);
char
*
record
=
static_cast
<
char
*>
(
malloc
(
SUM_SIZE
))
;
fs_ptr
->
reader_ptr_
->
Read
(
record
,
SUM_SIZE
);
uint32_t
record
;
fs_ptr
->
reader_ptr_
->
Read
(
&
record
,
SUM_SIZE
);
fs_ptr
->
reader_ptr_
->
Close
();
auto
sum
=
static_cast
<
uint8_t
>
(
atoi
(
record
));
free
(
record
);
return
sum
==
result
;
return
record
==
result
;
}
bool
...
...
core/src/storage/ExtraFileInfo.h
浏览文件 @
4d5c9347
...
...
@@ -77,9 +77,9 @@ bool
CheckSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
);
void
WriteSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
,
in
t
result
,
bool
written
=
false
);
WriteSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
,
uint32_
t
result
,
bool
written
=
false
);
std
::
uint
8
_t
std
::
uint
32
_t
CalculateSum
(
const
storage
::
FSHandlerPtr
&
fs_ptr
,
const
std
::
string
&
file_path
,
bool
written
=
false
);
std
::
string
...
...
core/src/storage/ExtraFileInfoTest.cpp
浏览文件 @
4d5c9347
...
...
@@ -64,7 +64,7 @@ TEST_F(ExtraFileInfoTest, WriteFileTest) {
ASSERT_TRUE
(
WriteHeaderValue
(
fs_ptr
,
file_path
,
"github"
,
"github"
));
ASSERT_EQ
(
ReadHeaderValue
(
fs_ptr
,
file_path
,
"github"
),
"github"
);
result_sum
=
CalculateSum
(
fs_ptr
,
file_path
);
result_sum
=
CalculateSum
(
fs_ptr
,
file_path
,
true
);
WriteSum
(
fs_ptr
,
file_path
,
result_sum
,
true
);
ASSERT_TRUE
(
CheckMagic
(
fs_ptr
,
file_path
));
ASSERT_TRUE
(
CheckSum
(
fs_ptr
,
file_path
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录