75 bool Open(
const std::string& file);
92 const std::string& message_type,
93 const std::string& proto_desc);
106 template <
typename MessageT>
107 bool WriteMessage(
const std::string& channel_name,
const MessageT& message,
108 const uint64_t time_nanosec,
109 const std::string& proto_desc =
"");
146 const std::string& channel_name)
const override;
156 const std::string& channel_name)
const override;
170 bool IsNewChannel(
const std::string& channel_name)
const;
175 void OnNewChannel(
const std::string& channel_name,
176 const std::string& message_type,
177 const std::string& proto_desc);
178 void OnNewMessage(
const std::string& channel_name);
181 uint64_t segment_raw_size_ = 0;
182 uint64_t segment_begin_time_ = 0;
183 uint32_t file_index_ = 0;
190 std::stringstream sstream_;
207 const std::string& channel_name,
208 const std::shared_ptr<message::RawMessage>& message,
209 const uint64_t time_nanosec,
const std::string& proto_desc) {
210 if (message ==
nullptr) {
211 AERROR <<
"nullptr error, channel: " << channel_name;
214 return WriteMessage(channel_name, message->message, time_nanosec);
219 const MessageT& message,
220 const uint64_t time_nanosec,
221 const std::string& proto_desc) {
223 if (message_type.empty()) {
224 if (!
WriteChannel(channel_name, message::GetMessageName<MessageT>(),
226 AERROR <<
"Failed to write meta data to channel [" << channel_name
231 if (MessageT::descriptor()->full_name() != message_type) {
232 AERROR <<
"Message type is invalid, expect: " << message_type
233 <<
", actual: " << message::GetMessageName<MessageT>();
237 std::string content(
"");
238 if (!message.SerializeToString(&content)) {
239 AERROR <<
"Failed to serialize message, channel: " << channel_name;
242 return WriteMessage(channel_name, content, time_nanosec);