jt2594838 commented on code in PR #409:
URL: https://github.com/apache/tsfile/pull/409#discussion_r1968737424
##########
cpp/src/writer/tsfile_writer.cc:
##########
@@ -384,6 +386,99 @@ int TsFileWriter::do_check_schema_aligned(
return ret;
}
+int TsFileWriter::do_check_schema_table(
+ std::shared_ptr<IDeviceID> device_id,
+ Tablet &tablet,
+ storage::TimeChunkWriter *&time_chunk_writer,
+ common::SimpleVector<storage::ValueChunkWriter *> &value_chunk_writers) {
+ int ret = E_OK;
+
+ auto dev_it = schemas_.find(device_id);
+ MeasurementSchemaGroup *device_schema = NULL;
+
+ auto &schema_map = io_writer_->get_schema()->table_schema_map_;
+ auto table_schema_it = schema_map.find(tablet.get_table_name());
+ if (UNLIKELY(table_schema_it == schema_map.end())) {
+ return E_TABLE_NOT_EXIST;
+ }
+ auto table_schema = table_schema_it->second;
+
+ if (UNLIKELY(dev_it == schemas_.end()) ||
+ IS_NULL(device_schema = dev_it->second)) {
+
+ device_schema = new MeasurementSchemaGroup;
+ device_schema->is_aligned_ = true;
+ device_schema->time_chunk_writer_ = new TimeChunkWriter();
+ device_schema->time_chunk_writer_->init(
+ "", g_config_value_.time_encoding_type_,
+ g_config_value_.time_compress_type_);
+
+ for (int i = 0; i < table_schema->get_measurement_schemas().size();
++i) {
+ if (table_schema->get_column_categories().at(i) ==
common::ColumnCategory::FIELD) {
+ auto table_column_schema =
table_schema->get_measurement_schemas().at(i);
+ auto device_column_schema = new
MeasurementSchema(table_column_schema->measurement_name_,
+ table_column_schema->data_type_,
table_column_schema->encoding_,
+ table_column_schema->compression_type_);
+ if (!table_column_schema->props_.empty()) {
+ device_column_schema->props_ = table_column_schema->props_;
+ }
+
device_schema->measurement_schema_map_[device_column_schema->measurement_name_]
= device_column_schema;
+ }
+ }
+ schemas_[device_id] = device_schema;
+ }
+
+ uint32_t column_cnt = tablet.get_column_count();
+ if (tablet.column_categories_.empty()) {
+ for (uint32_t i = 0; i < column_cnt; i++) {
+ auto& col_name = tablet.get_column_name(i);
+ int col_index = table_schema->find_column_index(col_name);
+ const common::ColumnCategory column_category =
table_schema->get_column_categories()[col_index];
+ tablet.column_categories_.emplace_back(column_category);
Review Comment:
Fixed
--
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]