curioustien commented on code in PR #45351:
URL: https://github.com/apache/arrow/pull/45351#discussion_r2028020253


##########
cpp/src/parquet/column_writer.cc:
##########
@@ -2383,29 +2391,45 @@ struct SerializeFunctor<
     int64_t non_null_count = array.length() - array.null_count();
     int64_t size = non_null_count * ArrowType::kByteWidth;
     scratch_buffer = AllocateBuffer(ctx->memory_pool, size);
-    scratch = reinterpret_cast<int64_t*>(scratch_buffer->mutable_data());
+    scratch_i32 = reinterpret_cast<int32_t*>(scratch_buffer->mutable_data());
+    scratch_i64 = reinterpret_cast<int64_t*>(scratch_buffer->mutable_data());

Review Comment:
   I tried to delay the casting in this commit 
https://github.com/apache/arrow/pull/45351/commits/f27934908c06388f58cd663c44569be9e8ee5e87,
 and got some test failures. After some debugging, I realized that we had to 
initialize the scratch pointer values here. If you look at the current 
[Serialize 
function](https://github.com/apache/arrow/blob/main/cpp/src/parquet/column_writer.cc#L2359-L2377)
 and [FixDecimalEndianness 
function](https://github.com/apache/arrow/blob/main/cpp/src/parquet/column_writer.cc#L2398-L2417),
 we first allocate the scratch buffer and capture the scratch pointer. Then, we 
move along that scratch pointer until we finish the output. Therefore, we need 
to do the initialization and casting in this method



-- 
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