MCPcopy Create free account
hub / github.com/apache/arrow / Unify

Method Unify

cpp/src/arrow/array/array_dict.cc:354–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352 : pool_(pool), value_type_(std::move(value_type)), memo_table_(pool) {}
353
354 Status Unify(const Array& dictionary, std::shared_ptr<Buffer>* out) override {
355 if (dictionary.null_count() > 0) {
356 return Status::Invalid("Cannot yet unify dictionaries with nulls");
357 }
358 if (!dictionary.type()->Equals(*value_type_)) {
359 return Status::Invalid("Dictionary type different from unifier: ",
360 dictionary.type()->ToString());
361 }
362 const ArrayType& values = checked_cast<const ArrayType&>(dictionary);
363 if (out != nullptr) {
364 ARROW_ASSIGN_OR_RAISE(auto result,
365 AllocateBuffer(dictionary.length() * sizeof(int32_t), pool_));
366 auto result_raw = reinterpret_cast<int32_t*>(result->mutable_data());
367 for (int64_t i = 0; i < values.length(); ++i) {
368 RETURN_NOT_OK(memo_table_.GetOrInsert(values.GetView(i), &result_raw[i]));
369 }
370 *out = std::move(result);
371 } else {
372 for (int64_t i = 0; i < values.length(); ++i) {
373 int32_t unused_memo_index;
374 RETURN_NOT_OK(memo_table_.GetOrInsert(values.GetView(i), &unused_memo_index));
375 }
376 }
377 return Status::OK();
378 }
379
380 Status Unify(const Array& dictionary) override { return Unify(dictionary, nullptr); }
381

Callers

nothing calls this directly

Calls 10

InvalidFunction · 0.50
OKFunction · 0.50
null_countMethod · 0.45
EqualsMethod · 0.45
typeMethod · 0.45
ToStringMethod · 0.45
mutable_dataMethod · 0.45
lengthMethod · 0.45
GetOrInsertMethod · 0.45
GetViewMethod · 0.45

Tested by

no test coverage detected