| 38 | |
| 39 | template <typename K, typename V> |
| 40 | Status GenericShardedQueryMap<K, V>::Add(const K& query_id, const V& obj) { |
| 41 | GenericScopedShardedMapRef<K, V> map_ref(query_id, this); |
| 42 | DCHECK(map_ref.get() != nullptr); |
| 43 | |
| 44 | auto entry = map_ref->find(query_id); |
| 45 | if (entry != map_ref->end()) { |
| 46 | // There shouldn't be an active query with that same id. |
| 47 | // (query_id is globally unique) |
| 48 | return Status(ErrorMsg(TErrorCode::INTERNAL_ERROR, |
| 49 | strings::Substitute("query id $0 already exists", PrintId(query_id)))); |
| 50 | } |
| 51 | map_ref->insert(make_pair(query_id, obj)); |
| 52 | if (size_metric_ != nullptr) size_metric_->Increment(1); |
| 53 | return Status::OK(); |
| 54 | } |
| 55 | |
| 56 | template <typename K, typename V> |
| 57 | Status GenericShardedQueryMap<K, V>::Get(const K& query_id, V* obj) { |