17 #ifndef CYBER_RECORD_FILE_RECORD_FILE_READER_H_ 18 #define CYBER_RECORD_FILE_RECORD_FILE_READER_H_ 23 #include <unordered_map> 27 #include "google/protobuf/io/coded_stream.h" 28 #include "google/protobuf/io/zero_copy_stream_impl.h" 29 #include "google/protobuf/message.h" 30 #include "google/protobuf/text_format.h" 41 using google::protobuf::io::CodedInputStream;
42 using google::protobuf::io::FileInputStream;
43 using google::protobuf::io::ZeroCopyInputStream;
49 bool Open(
const std::string& path)
override;
50 void Close()
override;
61 bool end_of_file_ =
false;
66 if (size < std::numeric_limits<int>::min() ||
67 size > std::numeric_limits<int>::max()) {
68 AERROR <<
"Size value greater than the range of int value.";
71 FileInputStream raw_input(
fd_, static_cast<int>(size));
72 CodedInputStream coded_input(&raw_input);
73 CodedInputStream::Limit limit = coded_input.PushLimit(static_cast<int>(size));
74 if (!message->ParseFromCodedStream(&coded_input)) {
75 AERROR <<
"Parse section message failed.";
76 end_of_file_ = coded_input.ExpectAtEnd();
79 if (!coded_input.ConsumedEntireMessage()) {
80 AERROR <<
"Do not consumed entire message.";
83 coded_input.PopLimit(limit);
84 if (static_cast<int64_t>(message->ByteSizeLong()) != size) {
85 AERROR <<
"Message size is not consistent in section header" 86 <<
", expect: " << size <<
", actual: " << message->ByteSizeLong();
96 #endif // CYBER_RECORD_FILE_RECORD_FILE_READER_H_ int fd_
Definition: record_file_base.h:48
RecordFileReader()=default
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: record_file_base.h:31
Definition: record_file_reader.h:45
virtual ~RecordFileReader()=default
#define AERROR
Definition: log.h:44
bool Open(const std::string &path) override
bool SkipSection(int64_t size)
bool EndOfFile()
Definition: record_file_reader.h:57
bool ReadSection(Section *section)