-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v4-write-process #345
v4-write-process #345
Conversation
# Conflicts: # cpp/src/common/tablet.cc # cpp/src/common/tablet.h # cpp/src/writer/tsfile_writer.cc # cpp/src/writer/tsfile_writer.h
cpp/src/common/device_id.h
Outdated
|
||
int segment_num() override { return static_cast<int>(segments_.size()); } | ||
|
||
std::vector<std::string> get_segments() const override { return segments_; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If read only
you can return const std::vector<std::string>&
to avoid copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cpp/src/common/device_id.h
Outdated
return tableName_; | ||
} | ||
|
||
size_t lastSeparatorPos = device_id_.find_last_of('.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use PATH_SEPARATOR_CHAR
instead of '.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cpp/src/common/device_id.h
Outdated
std::string get_device_name() const override { return device_id_; }; | ||
|
||
std::string get_table_name() override { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can verify that you need to return a copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cpp/src/common/schema.h
Outdated
if (ret == common::E_OK) { | ||
if (RET_FAIL(common::SerializationUtil::write_str(measurement_name_, | ||
out))) { | ||
for (auto &prop : props_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto& prop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cpp/src/common/schema.h
Outdated
: table_name_(table_name), | ||
measurement_schemas_(measurement_schemas), | ||
column_categories_(column_categories) { | ||
int idx = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use size_t
to avoid potential problems
cpp/src/common/allocator/my_string.h
Outdated
std::string to_string() { | ||
return std::string(buf_, len_); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already one such method. You can view the develop branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cpp/src/common/tablet.h
Outdated
|
||
int add_timestamp(uint32_t row_index, int64_t timestamp); | ||
|
||
// int set_value(int row_index, int schema_index, double val); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cpp/src/file/tsfile_io_writer.cc
Outdated
int ret = write_byte(CHUNK_GROUP_HEADER_MARKER); | ||
if (ret != common::E_OK) { | ||
return ret; | ||
} | ||
ret = write_string(device_name); | ||
device_name->serialize(write_stream_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ret = device_name->serialize(write_stream_);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
cpp/src/file/tsfile_io_writer.cc
Outdated
auto cur_device_name = cur_device_name_; | ||
if (*iter.get()->device_name_ == *cur_device_name) { | ||
use_prev_alloc_cgm_ = true; | ||
cur_chunk_group_meta_ = iter.get(); | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use cur_device_name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it
cpp/src/writer/tsfile_writer.h
Outdated
int write_typed_column(storage::ChunkWriter *chunk_writer, | ||
int64_t *timestamps, bool *col_values, | ||
common::BitMap &col_notnull_bitmap, | ||
int32_t row_count); | ||
common::BitMap &col_notnull_bitmap, int start_idx, | ||
int end_idx); | ||
int write_typed_column(storage::ChunkWriter *chunk_writer, | ||
int64_t *timestamps, int32_t *col_values, | ||
common::BitMap &col_notnull_bitmap, | ||
int32_t row_count); | ||
common::BitMap &col_notnull_bitmap, int start_idx, | ||
int end_idx); | ||
int write_typed_column(storage::ChunkWriter *chunk_writer, | ||
int64_t *timestamps, int64_t *col_values, | ||
common::BitMap &col_notnull_bitmap, | ||
int32_t row_count); | ||
common::BitMap &col_notnull_bitmap, int start_idx, | ||
int end_idx); | ||
int write_typed_column(storage::ChunkWriter *chunk_writer, | ||
int64_t *timestamps, float *col_values, | ||
common::BitMap &col_notnull_bitmap, | ||
int32_t row_count); | ||
common::BitMap &col_notnull_bitmap, int start_idx, | ||
int end_idx); | ||
int write_typed_column(storage::ChunkWriter *chunk_writer, | ||
int64_t *timestamps, double *col_values, | ||
common::BitMap &col_notnull_bitmap, | ||
int32_t row_count); | ||
common::BitMap &col_notnull_bitmap, int start_idx, | ||
int end_idx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to use template?
…t string data types.
…t string data types.
…t string data types.
…t string data types.
return E_OUT_OF_RANGE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果row_index 是 uint32_t的话,就把max_row_num_设置成uint32_t把,现在有些参数是int32的有些是 uint32的。
@@ -61,13 +65,26 @@ class TsFileWriter { | |||
int register_aligned_timeseries( | |||
const std::string &device_id, | |||
const std::vector<MeasurementSchema *> &measurement_schemas); | |||
void register_table(const std::shared_ptr<TableSchema> &table_schema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think pass a shared pointer to writer is a good idea. The TableSchema is internal info and shold not pass a sharedPtr directly
cpp/src/common/schema.h
Outdated
TableSchema(const std::string &table_name, | ||
const std::vector<std::shared_ptr<MeasurementSchema> > | ||
&column_schemas, | ||
const std::vector<ColumnCategory> &column_categories) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can make sure the owner of measurement schema, dont use shared_ptr.
cpp/src/common/row_record.h
Outdated
if (type_ == common::STRING) { | ||
return value_.strval_; | ||
} else { | ||
std::cout << "not String type" << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
cpp/src/common/tablet.cc
Outdated
// value_matrix_ = (void **)malloc(sizeof(void *) * schema_count); | ||
// for (size_t c = 0; c < schema_count; c++) { | ||
// const MeasurementSchema &schema = schema_vec_->at(c); | ||
// value_matrix_[c] = | ||
// malloc(get_data_type_size(schema.data_type_) * max_row_num_); | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
cpp/src/common/tablet.cc
Outdated
template <> | ||
void Tablet::process_val(uint32_t row_index, uint32_t schema_index, common::String val) { | ||
value_matrix_[schema_index].string_data[row_index].dup_from(val, page_arena_); | ||
bitmaps_[schema_index].set(row_index); /* mark as non-null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bitmaps of a Tablet in the Java edition are marked when the value is null. I think we should make them consistent.
cpp/src/common/tsblock/tuple_desc.cc
Outdated
@@ -44,6 +44,10 @@ uint32_t TupleDesc::get_single_row_len(int *erro_code) { | |||
totol_len += sizeof(double); | |||
break; | |||
} | |||
case common::STRING: { | |||
totol_len += DEFAULT_RESERVED_SIZE_OF_STRING + STRING_LEN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totol_len -> total_len
cpp/src/common/tsfile_common.h
Outdated
/* | ||
FORCE_INLINE bool is_same_measurement_name(const common::String &s1, const | ||
common::String &s2) | ||
{ | ||
return s1.equal_to(s2); | ||
} | ||
*/ | ||
private: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
cpp/src/file/tsfile_io_reader.h
Outdated
bool read_file_created_; | ||
}; | ||
|
||
// class TsFileIOReaderSet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
cpp/src/file/tsfile_io_writer.cc
Outdated
std::cout << "ChunkGroupMeta = {insert_target_name_=" | ||
<< cgm->insert_target_name_ << ", chunk_meta_list_={"; | ||
<< cgm->device_id_ << ", chunk_meta_list_={"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{insert_target_name_= -> {device_id_=
cpp/src/common/device_id.h
Outdated
static const char PATH_SEPARATOR = '.'; | ||
static const int DEFAULT_SEGMENT_NUM_FOR_TABLE_NAME = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include /common/constant/tsfile_constant
[](const std::string& a, const std::string& b) { | ||
return a.empty() ? b : a + PATH_SEPARATOR + b; | ||
}); | ||
final_segments.push_back(table_name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final_segments.push_back(table_name); | |
final_segments.emplace_back(std::move(table_name)); |
cpp/src/common/schema.h
Outdated
} else if (RET_FAIL(common::SerializationUtil::write_str( | ||
prop.second, out))) { | ||
} | ||
if (ret != common::E_OK) break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (ret != common::E_OK) break; | |
if (IS_FAIL(ret)) break; |
cpp/src/common/schema.h
Outdated
value, in))) { | ||
} | ||
props_.insert(std::make_pair(key, value)); | ||
if (ret != common::E_OK) break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (ret != common::E_OK) break; | |
if (IS_FAIL(ret)) break; |
cpp/src/common/schema.h
Outdated
const std::string &get_table_name() { return table_name_; } | ||
|
||
std::vector<std::string> get_measurement_names() const { | ||
std::vector<std::string> ret; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ret.reserve(column_schemas_.size())
Implemented the V4 tree model and table model write processes. Support string data types.. The following still need to be implemented/fixed: