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

zhztheplayer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new dfcf4378c6 [GLUTEN][VL] Fix redundant copies in Delta DV plan 
conversion (#12389)
dfcf4378c6 is described below

commit dfcf4378c6401cec6880eca02ad6f9a1a3648e5c
Author: Ismaël Mejía <[email protected]>
AuthorDate: Fri Jul 3 18:23:09 2026 +0200

    [GLUTEN][VL] Fix redundant copies in Delta DV plan conversion (#12389)
    
    VeloxPlanConverter.cc (parseDeltaSplitInfo):
    - Fix double dynamic_pointer_cast: the original code called
      dynamic_pointer_cast<DeltaSplitInfo> twice (once in the ternary
      condition, once in the true branch). Use a single cast + null check.
    - Avoid unnecessary std::string copy from protobuf: the accessor
      serialized_deletion_vector() returns a const std::string& to the
      internal protobuf field, but 'auto' (by value) triggered a full
      string copy into a local variable. Changed to 'const auto&' to
      bind directly to the protobuf internal field, eliminating the
      intermediate copy. The shared_ptr<string> construction then copies
      once from the reference (unavoidable since it needs ownership).
    
    Assisted-by: GitHub Copilot:claude-opus-4.6
---
 cpp/velox/compute/VeloxPlanConverter.cc | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/cpp/velox/compute/VeloxPlanConverter.cc 
b/cpp/velox/compute/VeloxPlanConverter.cc
index f47ca61050..22a7c49ac3 100644
--- a/cpp/velox/compute/VeloxPlanConverter.cc
+++ b/cpp/velox/compute/VeloxPlanConverter.cc
@@ -104,9 +104,10 @@ delta::DeltaRowIndexFilterType 
parseDeltaRowIndexFilterType(int filterType) {
 std::shared_ptr<DeltaSplitInfo> parseDeltaSplitInfo(
     const substrait::ReadRel_LocalFiles_FileOrFiles& file,
     std::shared_ptr<SplitInfo> splitInfo) {
-  auto deltaSplitInfo = std::dynamic_pointer_cast<DeltaSplitInfo>(splitInfo)
-      ? std::dynamic_pointer_cast<DeltaSplitInfo>(splitInfo)
-      : std::make_shared<DeltaSplitInfo>(*splitInfo);
+  auto deltaSplitInfo = std::dynamic_pointer_cast<DeltaSplitInfo>(splitInfo);
+  if (!deltaSplitInfo) {
+    deltaSplitInfo = std::make_shared<DeltaSplitInfo>(*splitInfo);
+  }
 
   deltaSplitInfo->format = dwio::common::FileFormat::PARQUET;
   const auto& deltaReadOptions = file.delta();
@@ -118,14 +119,14 @@ std::shared_ptr<DeltaSplitInfo> parseDeltaSplitInfo(
     return deltaSplitInfo;
   }
 
-  auto serializedPayload = deltaReadOptions.serialized_deletion_vector();
+  const auto& serializedPayload = 
deltaReadOptions.serialized_deletion_vector();
   VELOX_USER_CHECK(!serializedPayload.empty(), "Delta split has a deletion 
vector without a serialized payload");
   VELOX_USER_CHECK_LE(
       serializedPayload.size(),
       static_cast<size_t>(std::numeric_limits<int32_t>::max()),
       "Delta deletion vector serialized payload is too large");
   const auto cardinality = 
static_cast<uint64_t>(deltaReadOptions.deletion_vector_cardinality());
-  auto payload = std::make_shared<std::string>(std::move(serializedPayload));
+  auto payload = std::make_shared<std::string>(serializedPayload);
   const SplitPayloadBufferView payloadView{
       reinterpret_cast<const uint8_t*>(payload->data()), 
static_cast<int32_t>(payload->size())};
   deltaSplitInfo->deletionVectors.emplace_back(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to