27 const std::vector<std::string>& white_channels,
28 const std::vector<std::string>& black_channels,
29 uint64_t begin_time, uint64_t end_time)
30 : input_file_(input_file),
31 output_file_(output_file),
32 white_channels_(white_channels),
33 black_channels_(black_channels),
34 begin_time_(begin_time),
35 end_time_(end_time) {}
41 if (begin_time_ >= end_time_) {
42 AERROR <<
"begin time larger or equal than end time, begin_time_: "
43 << begin_time_ <<
"end_time_: " << end_time_;
46 for (
const auto& channel_name : white_channels_) {
47 if (std::find(black_channels_.begin(), black_channels_.end(),
48 channel_name) != black_channels_.end()) {
49 AERROR <<
"find channel in both of white list and black list, channel: "
55 AINFO <<
"split record file started.";
58 if (!reader_.
Open(input_file_)) {
59 AERROR <<
"open input file failed, file: " << input_file_;
64 AERROR <<
"time range " << begin_time_ <<
" to " << end_time_
65 <<
" is not include in this record file.";
71 if (!writer_.
Open(output_file_)) {
72 AERROR <<
"open output file failed. file: " << output_file_;
76 AERROR <<
"write header to output file failed. file: " << output_file_;
81 bool skip_next_chunk_body(
false);
86 AERROR <<
"read section failed.";
89 if (section.
type == SectionType::SECTION_INDEX) {
92 switch (section.
type) {
93 case SectionType::SECTION_CHANNEL: {
96 AERROR <<
"read channel section fail.";
99 if (white_channels_.empty() ||
100 std::find(white_channels_.begin(), white_channels_.end(),
101 chan.
name()) != white_channels_.end()) {
102 if (std::find(black_channels_.begin(), black_channels_.end(),
103 chan.
name()) == black_channels_.end()) {
109 case SectionType::SECTION_CHUNK_HEADER: {
112 AERROR <<
"read chunk header section fail.";
116 skip_next_chunk_body =
true;
120 case SectionType::SECTION_CHUNK_BODY: {
121 if (skip_next_chunk_body) {
123 skip_next_chunk_body =
false;
128 AERROR <<
"read chunk body section fail.";
131 for (
int idx = 0; idx < cbd.messages_size(); ++idx) {
132 if (!white_channels_.empty() &&
133 std::find(white_channels_.begin(), white_channels_.end(),
135 white_channels_.end()) {
138 if (std::find(black_channels_.begin(), black_channels_.end(),
140 black_channels_.end()) {
148 AERROR <<
"add new message failed.";
155 AERROR <<
"this section should not be here, section type: "
161 AINFO <<
"split record file done.";
Spliter(const std::string &input_file, const std::string &output_file, const std::vector< std::string > &white_channels, const std::vector< std::string > &black_channels, uint64_t begin_time=0, uint64_t end_time=std::numeric_limits< uint64_t >::max())
repeated SingleMessage messages