You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2022/10/17 01:23:25 UTC

[arrow] branch master updated: ARROW-18019: [C++][Gandiva] Improve Projector evaluation performance (#14394)

This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 63e1756778 ARROW-18019: [C++][Gandiva] Improve Projector evaluation performance (#14394)
63e1756778 is described below

commit 63e1756778c8c7f0cfcd3cfca6774cd30ffc6c9d
Author: Jin Shang <sh...@gmail.com>
AuthorDate: Mon Oct 17 09:23:17 2022 +0800

    ARROW-18019: [C++][Gandiva] Improve Projector evaluation performance (#14394)
    
    1. Some dynamic_casts are not necessary because the safety is checked already.
    2. RecordBatch's column(int i) function involves atomic operation and column_data(int i) doesn't. So we prefer to use column_data() instead if column()->data().
    
    Authored-by: Jin Shang <sh...@gmail.com>
    Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
 cpp/src/gandiva/annotator.cc | 2 +-
 cpp/src/gandiva/projector.cc | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cpp/src/gandiva/annotator.cc b/cpp/src/gandiva/annotator.cc
index 816732878f..b341fdde3a 100644
--- a/cpp/src/gandiva/annotator.cc
+++ b/cpp/src/gandiva/annotator.cc
@@ -107,7 +107,7 @@ EvalBatchPtr Annotator::PrepareEvalBatch(const arrow::RecordBatch& record_batch,
       continue;
     }
 
-    PrepareBuffersForField(*(found->second), *(record_batch.column(i))->data(),
+    PrepareBuffersForField(*(found->second), *(record_batch.column_data(i)),
                            eval_batch.get(), false /*is_output*/);
   }
 
diff --git a/cpp/src/gandiva/projector.cc b/cpp/src/gandiva/projector.cc
index 76e0206b52..7024a3bc20 100644
--- a/cpp/src/gandiva/projector.cc
+++ b/cpp/src/gandiva/projector.cc
@@ -207,7 +207,7 @@ Status Projector::AllocArrayData(const DataTypePtr& type, int64_t num_records,
   // The output vector always has a data array.
   int64_t data_len;
   if (arrow::is_primitive(type_id) || type_id == arrow::Type::DECIMAL) {
-    const auto& fw_type = dynamic_cast<const arrow::FixedWidthType&>(*type);
+    const auto& fw_type = static_cast<const arrow::FixedWidthType&>(*type);
     data_len = arrow::bit_util::BytesForBits(num_records * fw_type.bit_width());
   } else if (arrow::is_binary_like(type_id)) {
     // we don't know the expected size for varlen output vectors.
@@ -267,7 +267,7 @@ Status Projector::ValidateArrayDataCapacity(const arrow::ArrayData& array_data,
         Status::Invalid("data buffer for varlen output vectors must be resizable"));
   } else if (arrow::is_primitive(type_id) || type_id == arrow::Type::DECIMAL) {
     // verify size of data buffer.
-    const auto& fw_type = dynamic_cast<const arrow::FixedWidthType&>(*field.type());
+    const auto& fw_type = static_cast<const arrow::FixedWidthType&>(*field.type());
     int64_t min_data_len =
         arrow::bit_util::BytesForBits(num_records * fw_type.bit_width());
     int64_t data_len = array_data.buffers[1]->capacity();