static
| 146 | |
| 147 | // static |
| 148 | std::vector<std::string> OperatorTraceSplitReader::deserialize( |
| 149 | common::FileInputStream* stream) { |
| 150 | std::vector<std::string> splits; |
| 151 | try { |
| 152 | while (!stream->atEnd()) { |
| 153 | const auto length = stream->read<uint32_t>(); |
| 154 | std::string splitStr(length, '\0'); |
| 155 | stream->readBytes(reinterpret_cast<uint8_t*>(splitStr.data()), length); |
| 156 | const auto crc32 = stream->read<uint32_t>(); |
| 157 | const auto actualCrc32 = folly::crc32( |
| 158 | reinterpret_cast<const uint8_t*>(splitStr.data()), splitStr.size()); |
| 159 | if (crc32 != actualCrc32) { |
| 160 | LOG(ERROR) << "Failed to verify the split checksum " << crc32 |
| 161 | << " which does not equal to the actual computed checksum " |
| 162 | << actualCrc32; |
| 163 | break; |
| 164 | } |
| 165 | splits.push_back(std::move(splitStr)); |
| 166 | } |
| 167 | } catch (const BoltException& e) { |
| 168 | LOG(ERROR) << "Failed to deserialize split: " << e.message(); |
| 169 | } |
| 170 | return splits; |
| 171 | } |
| 172 | } // namespace bytedance::bolt::exec::trace |