| 59 | } |
| 60 | |
| 61 | RowBuilder::RowBuilder(const Schema& schema) |
| 62 | : schema_(schema), |
| 63 | buf_(NULL), |
| 64 | cnt_(0), |
| 65 | size_(0), |
| 66 | str_field_cnt_(0), |
| 67 | str_addr_length_(0), |
| 68 | str_field_start_offset_(0), |
| 69 | str_offset_(0), |
| 70 | schema_version_(1) { |
| 71 | str_field_start_offset_ = HEADER_LENGTH + BitMapSize(schema.size()); |
| 72 | for (int idx = 0; idx < schema.size(); idx++) { |
| 73 | const ::fedb::common::ColumnDesc& column = schema.Get(idx); |
| 74 | fedb::type::DataType cur_type = column.data_type(); |
| 75 | if (cur_type == ::fedb::type::kVarchar || |
| 76 | cur_type == ::fedb::type::kString) { |
| 77 | offset_vec_.push_back(str_field_cnt_); |
| 78 | str_field_cnt_++; |
| 79 | } else { |
| 80 | if (cur_type < TYPE_SIZE_ARRAY.size() && cur_type > 0) { |
| 81 | offset_vec_.push_back(str_field_start_offset_); |
| 82 | str_field_start_offset_ += TYPE_SIZE_ARRAY[cur_type]; |
| 83 | } else { |
| 84 | PDLOG(WARNING, "type is not supported"); |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | void RowBuilder::SetSchemaVersion(uint8_t version) { |
| 91 | schema_version_ = version; |