| 300 | } |
| 301 | |
| 302 | Result<uint32_t> ExtensionSet::EncodeType(const DataType& type) { |
| 303 | if (auto rec = registry_->GetType(type)) { |
| 304 | RETURN_NOT_OK(this->AddUri(rec->id)); |
| 305 | auto it_success = |
| 306 | types_map_.emplace(rec->id, static_cast<uint32_t>(types_map_.size())); |
| 307 | if (it_success.second) { |
| 308 | DCHECK_EQ(types_.find(static_cast<uint32_t>(types_.size())), types_.end()) |
| 309 | << "Type existed in types_ but not types_map_. ExtensionSet is inconsistent"; |
| 310 | types_[static_cast<uint32_t>(types_.size())] = {rec->id, rec->type}; |
| 311 | } |
| 312 | return it_success.first->second; |
| 313 | } |
| 314 | return Status::KeyError("type ", type.ToString(), " not found in the registry"); |
| 315 | } |
| 316 | |
| 317 | Result<Id> ExtensionSet::DecodeFunction(uint32_t anchor) const { |
| 318 | if (functions_.find(anchor) == functions_.end() || functions_.at(anchor).empty()) { |