| 98 | } |
| 99 | |
| 100 | bool SQLRequestRow::Init(int32_t str_length) { |
| 101 | if (schema_->GetColumnCnt() == 0) { |
| 102 | return true; |
| 103 | } |
| 104 | has_error_ = false; |
| 105 | str_length_expect_ = str_length; |
| 106 | str_length_current_ = 0; |
| 107 | uint32_t total_length = str_field_start_offset_; |
| 108 | total_length += str_length; |
| 109 | if (total_length + str_field_cnt_ <= UINT8_MAX) { |
| 110 | total_length += str_field_cnt_; |
| 111 | } else if (total_length + str_field_cnt_ * 2 <= UINT16_MAX) { |
| 112 | total_length += str_field_cnt_ * 2; |
| 113 | } else if (total_length + str_field_cnt_ * 3 <= SDK_UINT24_MAX) { |
| 114 | total_length += str_field_cnt_ * 3; |
| 115 | } else if (total_length + str_field_cnt_ * 4 <= UINT32_MAX) { |
| 116 | total_length += str_field_cnt_ * 4; |
| 117 | } |
| 118 | // TODO(wangtaize) limit total length |
| 119 | val_.resize(total_length); |
| 120 | buf_ = reinterpret_cast<int8_t*>(&(val_[0])); |
| 121 | size_ = total_length; |
| 122 | *(buf_) = 1; // FVersion |
| 123 | *(buf_ + 1) = 1; // SVersion |
| 124 | *(reinterpret_cast<uint32_t*>(buf_ + SDK_VERSION_LENGTH)) = total_length; |
| 125 | uint32_t bitmap_size = BitMapSize(schema_->GetColumnCnt()); |
| 126 | memset(buf_ + SDK_HEADER_LENGTH, 0, bitmap_size); |
| 127 | cnt_ = 0; |
| 128 | str_addr_length_ = SDKGetAddrLength(total_length); |
| 129 | str_offset_ = str_field_start_offset_ + str_addr_length_ * str_field_cnt_; |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | bool SQLRequestRow::Check(hybridse::sdk::DataType type) { |
| 134 | if (buf_ == NULL) { |
nothing calls this directly
no test coverage detected