| 112 | } |
| 113 | |
| 114 | Status KeyValueMetadata::DeleteMany(std::vector<int64_t> indices) { |
| 115 | std::sort(indices.begin(), indices.end()); |
| 116 | const int64_t size = static_cast<int64_t>(keys_.size()); |
| 117 | indices.push_back(size); |
| 118 | |
| 119 | int64_t shift = 0; |
| 120 | for (int64_t i = 0; i < static_cast<int64_t>(indices.size() - 1); ++i) { |
| 121 | ++shift; |
| 122 | const auto start = indices[i] + 1; |
| 123 | const auto stop = indices[i + 1]; |
| 124 | DCHECK_GE(start, 0); |
| 125 | DCHECK_LE(start, size); |
| 126 | DCHECK_GE(stop, 0); |
| 127 | DCHECK_LE(stop, size); |
| 128 | for (int64_t index = start; index < stop; ++index) { |
| 129 | keys_[index - shift] = std::move(keys_[index]); |
| 130 | values_[index - shift] = std::move(values_[index]); |
| 131 | } |
| 132 | } |
| 133 | keys_.resize(size - shift); |
| 134 | values_.resize(size - shift); |
| 135 | return Status::OK(); |
| 136 | } |
| 137 | |
| 138 | Status KeyValueMetadata::Delete(std::string_view key) { |
| 139 | auto index = FindKey(key); |