Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
823f8d5c
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
823f8d5c
编写于
9月 24, 2018
作者:
fengqikai1414
提交者:
Zhongjun Ni
9月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
framework: optimize header builder
上级
e107a328
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
63 addition
and
71 deletion
+63
-71
framework/cybertron/proto/record.proto
framework/cybertron/proto/record.proto
+8
-8
framework/cybertron/record/header_builder.cpp
framework/cybertron/record/header_builder.cpp
+33
-29
framework/cybertron/record/header_builder.h
framework/cybertron/record/header_builder.h
+13
-17
framework/cybertron/record/record_writer.cpp
framework/cybertron/record/record_writer.cpp
+1
-3
framework/cybertron/test/record/record_file_test.cpp
framework/cybertron/test/record/record_file_test.cpp
+6
-8
framework/cybertron/tools/cyber_recorder/recoverer.cpp
framework/cybertron/tools/cyber_recorder/recoverer.cpp
+1
-3
framework/cybertron/tools/cyber_recorder/spliter.cpp
framework/cybertron/tools/cyber_recorder/spliter.cpp
+1
-3
未找到文件。
framework/cybertron/proto/record.proto
浏览文件 @
823f8d5c
...
...
@@ -56,14 +56,14 @@ message Header {
required
CompressType
compress
=
3
;
required
uint64
chunk_interval
=
4
;
required
uint64
segment_interval
=
5
;
required
uint64
index_position
=
6
;
required
uint64
chunk_number
=
7
;
required
uint64
channel_number
=
8
;
required
uint64
begin_time
=
9
;
required
uint64
end_time
=
10
;
required
uint64
message_number
=
11
;
required
uint64
size
=
12
;
required
bool
is_complete
=
13
;
required
uint64
index_position
=
6
[
default
=
0
]
;
required
uint64
chunk_number
=
7
[
default
=
0
]
;
required
uint64
channel_number
=
8
[
default
=
0
]
;
required
uint64
begin_time
=
9
[
default
=
0
]
;
required
uint64
end_time
=
10
[
default
=
0
]
;
required
uint64
message_number
=
11
[
default
=
0
]
;
required
uint64
size
=
12
[
default
=
0
]
;
required
bool
is_complete
=
13
[
default
=
false
]
;
required
uint64
chunk_raw_size
=
14
;
required
uint64
segment_raw_size
=
15
;
}
...
...
framework/cybertron/record/header_builder.cpp
浏览文件 @
823f8d5c
...
...
@@ -20,42 +20,46 @@ namespace apollo {
namespace
cybertron
{
namespace
record
{
HeaderBuilder
::
HeaderBuilder
()
{
BuildDefault
();
}
using
::
apollo
::
cybertron
::
proto
::
CompressType
;
HeaderBuilder
::~
HeaderBuilder
()
{}
void
HeaderBuilder
::
BuildDefault
()
{
header_
.
set_major_version
(
major_version_
);
header_
.
set_minor_version
(
minor_version_
);
header_
.
set_compress
(
compress_type_
);
header_
.
set_chunk_interval
(
chunk_interval_
);
header_
.
set_segment_interval
(
segment_interval_
);
header_
.
set_index_position
(
0
);
header_
.
set_chunk_number
(
0
);
header_
.
set_channel_number
(
0
);
header_
.
set_begin_time
(
0
);
header_
.
set_end_time
(
0
);
header_
.
set_message_number
(
0
);
header_
.
set_size
(
0
);
header_
.
set_is_complete
(
false
);
header_
.
set_chunk_raw_size
(
chunk_raw_size_
);
header_
.
set_segment_raw_size
(
segment_raw_size_
);
proto
::
Header
HeaderBuilder
::
GetHeader
()
{
proto
::
Header
header
;
header
.
set_major_version
(
MAJOR_VERSION_
);
header
.
set_minor_version
(
MINOR_VERSION_
);
header
.
set_compress
(
COMPRESS_TYPE_
);
header
.
set_chunk_interval
(
CHUNK_INTERVAL_
);
header
.
set_segment_interval
(
SEGMENT_INTERVAL_
);
header
.
set_chunk_raw_size
(
CHUNK_RAW_SIZE_
);
header
.
set_segment_raw_size
(
SEGMENT_RAW_SIZE_
);
return
header
;
}
void
HeaderBuilder
::
BuildSegmentPart
(
uint64_t
segment_interval
,
uint64_t
segment_raw_size
)
{
header_
.
set_segment_interval
(
segment_interval
);
header_
.
set_segment_raw_size
(
segment_raw_size
);
proto
::
Header
HeaderBuilder
::
GetHeaderWithSegmentParams
(
const
uint64_t
segment_interval
,
const
uint64_t
segment_raw_size
)
{
proto
::
Header
header
;
header
.
set_major_version
(
MAJOR_VERSION_
);
header
.
set_minor_version
(
MINOR_VERSION_
);
header
.
set_compress
(
COMPRESS_TYPE_
);
header
.
set_chunk_interval
(
CHUNK_INTERVAL_
);
header
.
set_chunk_raw_size
(
CHUNK_RAW_SIZE_
);
header
.
set_segment_raw_size
(
segment_raw_size
);
header
.
set_segment_interval
(
segment_interval
);
return
header
;
}
void
HeaderBuilder
::
BuildChunkPart
(
uint64_t
chunk_interval
,
uint64_t
chunk_raw_size
)
{
header_
.
set_chunk_interval
(
chunk_interval
);
header_
.
set_chunk_raw_size
(
chunk_raw_size
);
proto
::
Header
HeaderBuilder
::
GetHeaderWithChunkParams
(
const
uint64_t
chunk_interval
,
const
uint64_t
chunk_raw_size
)
{
proto
::
Header
header
;
header
.
set_major_version
(
MAJOR_VERSION_
);
header
.
set_minor_version
(
MINOR_VERSION_
);
header
.
set_compress
(
COMPRESS_TYPE_
);
header
.
set_segment_interval
(
SEGMENT_INTERVAL_
);
header
.
set_segment_raw_size
(
SEGMENT_RAW_SIZE_
);
header
.
set_chunk_interval
(
chunk_interval
);
header
.
set_chunk_raw_size
(
chunk_raw_size
);
return
header
;
}
const
Header
HeaderBuilder
::
GetHeader
()
{
return
header_
;
}
}
// namespace record
}
// namespace cybertron
}
// namespace apollo
framework/cybertron/record/header_builder.h
浏览文件 @
823f8d5c
...
...
@@ -23,27 +23,23 @@ namespace apollo {
namespace
cybertron
{
namespace
record
{
using
::
apollo
::
cybertron
::
proto
::
Header
;
using
::
apollo
::
cybertron
::
proto
::
CompressType
;
class
HeaderBuilder
{
public:
HeaderBuilder
();
virtual
~
HeaderBuilder
();
void
BuildDefault
();
void
BuildSegmentPart
(
uint64_t
segment_interval
,
uint64_t
segment_raw_size
);
void
BuildChunkPart
(
uint64_t
chunk_interval
,
uint64_t
chunk_raw_size
);
const
Header
GetHeader
();
static
proto
::
Header
GetHeaderWithSegmentParams
(
const
uint64_t
segment_interval
,
const
uint64_t
segment_raw_size
);
static
proto
::
Header
GetHeaderWithChunkParams
(
const
uint64_t
chunk_interval
,
const
uint64_t
chunk_raw_size
);
static
proto
::
Header
GetHeader
();
private:
Header
header_
;
const
uint32_t
major_version_
=
1
;
const
uint32_t
minor_version_
=
0
;
const
CompressType
compress_type_
=
CompressType
::
COMPRESS_NONE
;
const
uint64_t
chunk_interval
_
=
20
*
1e9L
;
// 20s
const
uint64_t
segment_interval
_
=
60
*
1e9L
;
// 60s
const
uint64_t
chunk_raw_size
_
=
200
*
1024
*
1024
;
// 200MB
const
uint64_t
segment_raw_size
_
=
2ULL
*
1024
*
1024
*
1024
;
// 2GB
static
const
uint32_t
MAJOR_VERSION_
=
1
;
static
const
uint32_t
MINOR_VERSION_
=
0
;
static
const
proto
::
CompressType
COMPRESS_TYPE_
=
proto
::
CompressType
::
COMPRESS_NONE
;
static
const
uint64_t
CHUNK_INTERVAL
_
=
20
*
1e9L
;
// 20s
static
const
uint64_t
SEGMENT_INTERVAL
_
=
60
*
1e9L
;
// 60s
static
const
uint64_t
CHUNK_RAW_SIZE
_
=
200
*
1024
*
1024
;
// 200MB
static
const
uint64_t
SEGMENT_RAW_SIZE
_
=
2ULL
*
1024
*
1024
*
1024
;
// 2GB
};
}
// namespace record
...
...
framework/cybertron/record/record_writer.cpp
浏览文件 @
823f8d5c
...
...
@@ -28,9 +28,7 @@ bool RecordWriter::Open(const std::string& file) {
file_
=
file
;
path_
=
file_
;
file_writer_
.
reset
(
new
RecordFileWriter
());
HeaderBuilder
*
header_builder
=
new
HeaderBuilder
();
header_
=
header_builder
->
GetHeader
();
delete
header_builder
;
header_
=
HeaderBuilder
::
GetHeader
();
if
(
!
file_writer_
->
Open
(
path_
))
{
AERROR
<<
"open outfile failed. file: "
<<
path_
;
return
false
;
...
...
framework/cybertron/test/record/record_file_test.cpp
浏览文件 @
823f8d5c
...
...
@@ -87,10 +87,9 @@ TEST(RecordFileTest, TestOneMessageFile) {
ASSERT_NE
(
nullptr
,
rfw
->
flush_thread_
);
// write header section
HeaderBuilder
*
hb
=
new
HeaderBuilder
();
hb
->
BuildSegmentPart
(
0
,
0
);
hb
->
BuildChunkPart
(
0
,
0
);
Header
hdr1
=
hb
->
GetHeader
();
Header
hdr1
=
GetHeaderWithSegmentParams
(
0
,
0
);
hdr1
.
set_chunk_interval
(
0
);
hdr1
.
set_chunk_raw_size
(
0
);
ASSERT_TRUE
(
rfw
->
WriteHeader
(
hdr1
));
ASSERT_FALSE
(
rfw
->
header_
.
is_complete
());
...
...
@@ -183,10 +182,9 @@ TEST(RecordFileTest, TestOneChunkFile) {
ASSERT_TRUE
(
rfw
->
is_writing_
);
ASSERT_NE
(
nullptr
,
rfw
->
flush_thread_
);
HeaderBuilder
*
hb
=
new
HeaderBuilder
();
hb
->
BuildSegmentPart
(
0
,
0
);
hb
->
BuildChunkPart
(
0
,
0
);
Header
header
=
hb
->
GetHeader
();
Header
header
=
HeaderBuilder
::
GetHeaderWithChunkParams
(
0
,
0
);
header
.
set_segment_interval
(
0
);
header
.
set_segment_raw_size
(
0
);
ASSERT_TRUE
(
rfw
->
WriteHeader
(
header
));
ASSERT_FALSE
(
rfw
->
header_
.
is_complete
());
...
...
framework/cybertron/tools/cyber_recorder/recoverer.cpp
浏览文件 @
823f8d5c
...
...
@@ -37,9 +37,7 @@ bool Recoverer::Proc() {
}
// open output file
HeaderBuilder
*
header_builder
=
new
HeaderBuilder
();
Header
new_hdr
=
header_builder
->
GetHeader
();
delete
header_builder
;
Header
new_hdr
=
HeaderBuilder
::
GetHeader
();
if
(
!
writer_
.
Open
(
output_file_
))
{
AERROR
<<
"open output file failed. file: "
<<
output_file_
;
return
false
;
...
...
framework/cybertron/tools/cyber_recorder/spliter.cpp
浏览文件 @
823f8d5c
...
...
@@ -68,9 +68,7 @@ bool Spliter::Proc() {
}
// open output file
HeaderBuilder
*
header_builder
=
new
HeaderBuilder
();
Header
new_hdr
=
header_builder
->
GetHeader
();
delete
header_builder
;
Header
new_hdr
=
HeaderBuilder
::
GetHeader
();
if
(
!
writer_
.
Open
(
output_file_
))
{
AERROR
<<
"open output file failed. file: "
<<
output_file_
;
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录