* @brief Get the index of key in rows * * @return -1 if the key does not exists. */
| 78 | * @return -1 if the key does not exists. |
| 79 | */ |
| 80 | int64_t Index(int64_t key) const { |
| 81 | auto it = std::find(rows_.begin(), rows_.end(), key); |
| 82 | if (it == rows_.end()) { |
| 83 | PADDLE_THROW(common::errors::NotFound( |
| 84 | "Input id (%lld) is not in current rows table.", key)); |
| 85 | } |
| 86 | return static_cast<int64_t>(std::distance(rows_.begin(), it)); |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * @brief whether has the specified key in the table. |