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