Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/src/arrow/util/key_value_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Status KeyValueMetadata::DeleteMany(std::vector<int64_t> indices) {
DCHECK_GE(stop, 0);
DCHECK_LE(stop, size);
for (int64_t index = start; index < stop; ++index) {
DCHECK_GE(index - shift, 0);
keys_[index - shift] = std::move(keys_[index]);
values_[index - shift] = std::move(values_[index]);
}
Expand Down
6 changes: 6 additions & 0 deletions cpp/src/arrow/util/key_value_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ class ARROW_EXPORT KeyValueMetadata {
// Note that deleting may invalidate known indices
Status Delete(std::string_view key);
Status Delete(int64_t index);

/// \brief Delete metadata entries at specified index in keys and values array
/// \param indices Vector of distinct indices identifying the entries to
/// remove from the metadata.
/// \return Status indicating success or failure.

Status DeleteMany(std::vector<int64_t> indices);
Status Set(std::string key, std::string value);

Expand Down
4 changes: 4 additions & 0 deletions cpp/src/arrow/util/key_value_metadata_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ TEST(KeyValueMetadataTest, Delete) {
ASSERT_OK(metadata.DeleteMany({}));
ASSERT_TRUE(metadata.Equals(KeyValueMetadata({"bb", "dd", "ee"}, {"2", "4", "5"})));
}
{
KeyValueMetadata metadata(keys, values);
ASSERT_DEATH(static_cast<void>(metadata.DeleteMany({0, 0, 5, 2})), "Check failed");
}
}

} // namespace arrow
Loading