Skip to content
Closed
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
3 changes: 2 additions & 1 deletion cpp/src/arrow/ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ function(ADD_ARROW_IPC_TEST REL_TEST_NAME)
endfunction()

add_arrow_test(feather_test)
add_arrow_ipc_test(read_write_test)
add_arrow_ipc_test(json_simple_test)
add_arrow_ipc_test(read_write_test)
add_arrow_ipc_test(tensor_test)

# Headers: top level
arrow_install_all_headers("arrow/ipc")
Expand Down
15 changes: 12 additions & 3 deletions cpp/src/arrow/ipc/dictionary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,19 @@ Status DictionaryMemo::AddDictionaryDelta(int64_t id,
return Status::OK();
}

Status DictionaryMemo::AddOrReplaceDictionary(
Result<bool> DictionaryMemo::AddOrReplaceDictionary(
int64_t id, const std::shared_ptr<ArrayData>& dictionary) {
impl_->id_to_dictionary_[id] = {dictionary};
return Status::OK();
ArrayDataVector value{dictionary};

auto pair = impl_->id_to_dictionary_.emplace(id, value);
if (pair.second) {
// Inserted
return true;
} else {
// Update existing value
pair.first->second = std::move(value);
return false;
}
}

// ----------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion cpp/src/arrow/ipc/dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ class ARROW_EXPORT DictionaryMemo {

/// \brief Add a dictionary to the memo if it does not have one with the id,
/// otherwise, replace the dictionary with the new one.
Status AddOrReplaceDictionary(int64_t id, const std::shared_ptr<ArrayData>& dictionary);
///
/// Return true if the dictionary was added, false if replaced.
Result<bool> AddOrReplaceDictionary(int64_t id,
const std::shared_ptr<ArrayData>& dictionary);

private:
struct Impl;
Expand Down
Loading