| 183 | } |
| 184 | |
| 185 | Status ExportValues(OpKernelContext* context) override { |
| 186 | if (!is_initialized_) { |
| 187 | return errors::Aborted("HashTable is not initialized."); |
| 188 | } |
| 189 | |
| 190 | const int64 size = table_->size(); |
| 191 | |
| 192 | Tensor* keys; |
| 193 | Tensor* values; |
| 194 | TF_RETURN_IF_ERROR( |
| 195 | context->allocate_output("keys", TensorShape({size}), &keys)); |
| 196 | TF_RETURN_IF_ERROR( |
| 197 | context->allocate_output("values", TensorShape({size}), &values)); |
| 198 | |
| 199 | auto keys_data = keys->flat<K>(); |
| 200 | auto values_data = values->flat<V>(); |
| 201 | int64 i = 0; |
| 202 | for (auto it = table_->begin(); it != table_->end(); ++it, ++i) { |
| 203 | keys_data(i) = it->first; |
| 204 | values_data(i) = it->second; |
| 205 | } |
| 206 | return Status::OK(); |
| 207 | } |
| 208 | |
| 209 | DataType key_dtype() const override { return DataTypeToEnum<K>::v(); } |
| 210 |
nothing calls this directly
no test coverage detected