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

Method Unify

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

Source from the content-addressed store, hash-verified

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

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