bkietz commented on code in PR #37754:
URL: https://github.com/apache/arrow/pull/37754#discussion_r1329271253


##########
cpp/src/arrow/array/array_dict.cc:
##########
@@ -299,10 +300,11 @@ class DictionaryUnifierImpl : public DictionaryUnifier {
     }
 
     // Build unified dictionary array
-    std::shared_ptr<ArrayData> data;
-    RETURN_NOT_OK(DictTraits::GetDictionaryArrayData(pool_, value_type_, 
memo_table_,
-                                                     0 /* start_offset */, 
&data));
-    *out_dict = MakeArray(data);
+    Result<std::shared_ptr<ArrayData>> data;
+    data = DictTraits::GetDictionaryArrayData(pool_, value_type_, memo_table_,
+                                              0 /* start_offset */);
+    RETURN_NOT_OK(data.status());
+    *out_dict = MakeArray(data.ValueOrDie());

Review Comment:
   Likewise:
   ```suggestion
       ARROW_ASSIGN_OR_RAISE(auto data, DictTraits::GetDictionaryArrayData(
           pool_, value_type_, memo_table_, /*start_offset=*/0));
       *out_dict = MakeArray(data);
   ```



##########
cpp/src/arrow/array/array_dict.cc:
##########
@@ -282,10 +282,11 @@ class DictionaryUnifierImpl : public DictionaryUnifier {
     *out_type = arrow::dictionary(index_type, value_type_);
 
     // Build unified dictionary array
-    std::shared_ptr<ArrayData> data;
-    RETURN_NOT_OK(DictTraits::GetDictionaryArrayData(pool_, value_type_, 
memo_table_,
-                                                     0 /* start_offset */, 
&data));
-    *out_dict = MakeArray(data);
+    Result<std::shared_ptr<ArrayData>> data;
+    data = DictTraits::GetDictionaryArrayData(pool_, value_type_, memo_table_,
+                                              0 /* start_offset */);
+    RETURN_NOT_OK(data.status());
+    *out_dict = MakeArray(data.ValueOrDie());

Review Comment:
   For `Result`s we have a convenience macro which should save you some 
boilerplate:
   ```suggestion
       ARROW_ASSIGN_OR_RAISE(auto data, DictTraits::GetDictionaryArrayData(
           pool_, value_type_, memo_table_, /*start_offset=*/0));
       *out_dict = MakeArray(data);
   ```



##########
cpp/src/arrow/array/builder_dict.cc:
##########
@@ -106,8 +106,11 @@ class DictionaryMemoTable::DictionaryMemoTableImpl {
     enable_if_memoize<T, Status> Visit(const T&) {
       using ConcreteMemoTable = typename DictionaryTraits<T>::MemoTableType;
       auto memo_table = checked_cast<ConcreteMemoTable*>(memo_table_);
-      return DictionaryTraits<T>::GetDictionaryArrayData(pool_, value_type_, 
*memo_table,
-                                                         start_offset_, out_);
+      Result<std::shared_ptr<ArrayData>> data;
+      data = DictionaryTraits<T>::GetDictionaryArrayData(pool_, value_type_, 
*memo_table,
+                                                         start_offset_);
+      *out_ = data.ok() ? data.ValueOrDie() : nullptr;
+      return data.status();

Review Comment:
   ```suggestion
         ARROW_ASSIGN_OR_RAISE(*out_, 
DictionaryTraits<T>::GetDictionaryArrayData(
             pool_, value_type_, *memo_table, start_offset_));
         return Status::OK();
   ```



##########
cpp/src/arrow/compute/kernels/vector_hash.cc:
##########
@@ -285,8 +285,11 @@ class RegularHashKernel : public HashKernel {
   Status FlushFinal(ExecResult* out) override { return 
action_.FlushFinal(out); }
 
   Status GetDictionary(std::shared_ptr<ArrayData>* out) override {
-    return DictionaryTraits<Type>::GetDictionaryArrayData(pool_, type_, 
*memo_table_,
-                                                          0 /* start_offset 
*/, out);
+    Result<std::shared_ptr<ArrayData>> data;

Review Comment:
   also here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to