hongzhi-gao commented on code in PR #731:
URL: https://github.com/apache/tsfile/pull/731#discussion_r2876634320
##########
cpp/src/writer/tsfile_writer.cc:
##########
@@ -113,11 +115,50 @@ int TsFileWriter::init(WriteFile* write_file) {
}
write_file_ = write_file;
write_file_created_ = false;
+ io_writer_owned_ = true;
io_writer_ = new TsFileIOWriter();
io_writer_->init(write_file_);
return E_OK;
}
+int TsFileWriter::init(RestorableTsFileIOWriter* rw) {
+ // Initialize from a recovered writer: take schema from file, do not own
+ // io_writer_
+ if (rw == nullptr) {
+ return E_INVALID_ARG;
+ }
+ if (!rw->can_write()) {
+ return E_INVALID_ARG;
+ }
+ write_file_ = rw->get_write_file();
+ write_file_created_ = false;
+ io_writer_owned_ = false;
+ io_writer_ = rw; // RestorableTsFileIOWriter is also a TsFileIOWriter
+ std::shared_ptr<Schema> known = rw->get_known_schema();
+ for (const auto& kv : known->table_schema_map_) {
+ const std::string& table_name = kv.first;
+ const std::shared_ptr<TableSchema>& ts = kv.second;
+ if (!ts || ts->get_measurement_names().empty()) {
+ continue;
+ }
+ auto device_id = std::make_shared<StringArrayDeviceID>(table_name);
+ auto* ms_group = new MeasurementSchemaGroup;
Review Comment:
We rebuild mutable in-memory schema cache from recovered schema; table_name
is used as device key, and ms_group supports lazy writer creation later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]