Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
d9dd6aa0
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d9dd6aa0
编写于
4月 14, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 14, 2020
浏览文件
操作
浏览文件
下载
差异文件
!277 fix: use correct permissions when opening mindrecord files
Merge pull request !277 from guozhijian/fix_read_with_exact_option
上级
57aee805
ea5da25d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
29 deletion
+36
-29
mindspore/ccsrc/mindrecord/io/shard_index_generator.cc
mindspore/ccsrc/mindrecord/io/shard_index_generator.cc
+4
-0
mindspore/ccsrc/mindrecord/io/shard_reader.cc
mindspore/ccsrc/mindrecord/io/shard_reader.cc
+14
-22
mindspore/ccsrc/mindrecord/io/shard_writer.cc
mindspore/ccsrc/mindrecord/io/shard_writer.cc
+18
-7
未找到文件。
mindspore/ccsrc/mindrecord/io/shard_index_generator.cc
浏览文件 @
d9dd6aa0
...
...
@@ -512,6 +512,10 @@ MSRStatus ShardIndexGenerator::ExecuteTransaction(const int &shard_no, const std
std
::
fstream
in
;
in
.
open
(
common
::
SafeCStr
(
shard_address
),
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
in
.
good
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
return
FAILED
;
}
(
void
)
sqlite3_exec
(
db
.
second
,
"BEGIN TRANSACTION;"
,
nullptr
,
nullptr
,
nullptr
);
for
(
int
raw_page_id
:
raw_page_ids
)
{
auto
sql
=
GenerateRawSQL
(
fields_
);
...
...
mindspore/ccsrc/mindrecord/io/shard_reader.cc
浏览文件 @
d9dd6aa0
...
...
@@ -125,13 +125,10 @@ MSRStatus ShardReader::Open() {
for
(
const
auto
&
file
:
file_paths_
)
{
std
::
shared_ptr
<
std
::
fstream
>
fs
=
std
::
make_shared
<
std
::
fstream
>
();
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
trunc
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
return
FAILED
;
}
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
fs
->
good
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
return
FAILED
;
}
MS_LOG
(
INFO
)
<<
"Open shard file successfully."
;
file_streams_
.
push_back
(
fs
);
...
...
@@ -146,13 +143,10 @@ MSRStatus ShardReader::Open(int n_consumer) {
for
(
const
auto
&
file
:
file_paths_
)
{
for
(
int
j
=
0
;
j
<
n_consumer
;
++
j
)
{
std
::
shared_ptr
<
std
::
fstream
>
fs
=
std
::
make_shared
<
std
::
fstream
>
();
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
trunc
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
return
FAILED
;
}
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
fs
->
good
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
return
FAILED
;
}
file_streams_random_
[
j
].
push_back
(
fs
);
}
...
...
@@ -311,12 +305,10 @@ MSRStatus ShardReader::ReadAllRowsInShard(int shard_id, const std::string &sql,
std
::
string
file_name
=
file_paths_
[
shard_id
];
std
::
shared_ptr
<
std
::
fstream
>
fs
=
std
::
make_shared
<
std
::
fstream
>
();
if
(
!
all_in_index_
)
{
fs
->
open
(
common
::
SafeCStr
(
file_name
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
fs
->
open
(
common
::
SafeCStr
(
file_name
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
trunc
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
}
fs
->
open
(
common
::
SafeCStr
(
file_name
),
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
fs
->
good
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
return
FAILED
;
}
}
sqlite3_free
(
errmsg
);
...
...
@@ -520,8 +512,8 @@ std::pair<MSRStatus, std::vector<json>> ShardReader::GetLabelsFromBinaryFile(
std
::
string
file_name
=
file_paths_
[
shard_id
];
std
::
vector
<
json
>
res
;
std
::
shared_ptr
<
std
::
fstream
>
fs
=
std
::
make_shared
<
std
::
fstream
>
();
fs
->
open
(
common
::
SafeCStr
(
file_name
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
fs
->
open
(
common
::
SafeCStr
(
file_name
),
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
fs
->
good
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
return
{
FAILED
,
{}};
}
...
...
mindspore/ccsrc/mindrecord/io/shard_writer.cc
浏览文件 @
d9dd6aa0
...
...
@@ -76,16 +76,27 @@ MSRStatus ShardWriter::Open(const std::vector<std::string> &paths, bool append)
// Open files
for
(
const
auto
&
file
:
file_paths_
)
{
std
::
shared_ptr
<
std
::
fstream
>
fs
=
std
::
make_shared
<
std
::
fstream
>
();
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
out
|
std
::
ios
::
trunc
|
std
::
ios
::
binary
);
if
(
fs
->
fail
())
{
MS_LOG
(
ERROR
)
<<
"File could not opened"
;
if
(
!
append
)
{
// if not append and mindrecord file exist, return FAILED
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
fs
->
good
())
{
MS_LOG
(
ERROR
)
<<
"MindRecord file already existed."
;
fs
->
close
();
return
FAILED
;
}
fs
->
close
();
// open the mindrecord file to write
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
out
|
std
::
ios
::
binary
);
if
(
!
fs
->
good
())
{
MS_LOG
(
ERROR
)
<<
"MindRecord file could not opened."
;
return
FAILED
;
}
}
else
{
if
(
!
append
)
{
MS_LOG
(
ERROR
)
<<
"MindRecord file already existed"
;
// open the mindrecord file to append
fs
->
open
(
common
::
SafeCStr
(
file
),
std
::
ios
::
out
|
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
fs
->
good
())
{
MS_LOG
(
ERROR
)
<<
"MindRecord file could not opened for append."
;
return
FAILED
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录