| 175 | } |
| 176 | |
| 177 | void |
| 178 | InnerIndexInterface::Deserialize(const BinarySet& binary_set) { |
| 179 | std::string time_record_name = this->GetName() + " Deserialize"; |
| 180 | SlowTaskTimer t(time_record_name); |
| 181 | |
| 182 | // new version serialization will contains the META_KEY |
| 183 | if (binary_set.Contains(SERIAL_META_KEY)) { |
| 184 | logger::debug("parse with new version format"); |
| 185 | auto metadata = std::make_shared<Metadata>(binary_set.Get(SERIAL_META_KEY)); |
| 186 | |
| 187 | if (metadata->EmptyIndex()) { |
| 188 | return; |
| 189 | } |
| 190 | } else { |
| 191 | logger::debug("parse with v0.11 version format"); |
| 192 | |
| 193 | // check if binary set is an empty index |
| 194 | if (binary_set.Contains(BLANK_INDEX)) { |
| 195 | return; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | Binary b = binary_set.Get(this->GetName()); |
| 200 | auto func = [&](uint64_t offset, uint64_t len, void* dest) -> void { |
| 201 | // logger::debug("read offset {} len {}", offset, len); |
| 202 | std::memcpy(dest, b.data.get() + offset, len); |
| 203 | }; |
| 204 | |
| 205 | try { |
| 206 | uint64_t cursor = 0; |
| 207 | auto reader = ReadFuncStreamReader(func, cursor, b.size); |
| 208 | this->Deserialize(reader); |
| 209 | } catch (const std::runtime_error& e) { |
| 210 | throw VsagException(ErrorType::READ_ERROR, "failed to Deserialize: ", e.what()); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | void |
| 215 | InnerIndexInterface::Deserialize(const ReaderSet& reader_set) { |
no test coverage detected