From 022ce981bbce938ef60ef78892b100ad292ed575 Mon Sep 17 00:00:00 2001 From: zhixingheyi-tian Date: Wed, 21 Sep 2022 13:43:10 +0800 Subject: [PATCH] [NSE-1112] Fix Arrow array meta data validating issue when writing parquet files (#1113) * Add log to troubleshoot * change reserve to resize * comment cout --- .../cpp/src/operators/row_to_columnar_converter.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/native-sql-engine/cpp/src/operators/row_to_columnar_converter.cc b/native-sql-engine/cpp/src/operators/row_to_columnar_converter.cc index 351620631..d9579d3f7 100644 --- a/native-sql-engine/cpp/src/operators/row_to_columnar_converter.cc +++ b/native-sql-engine/cpp/src/operators/row_to_columnar_converter.cc @@ -149,15 +149,15 @@ inline arrow::Status CreateArrayData( int32_t wordoffset = int32_t(offsetAndSize >> 32); auto value_offset = array_offset[position + 1] = array_offset[position] + length; - uint64_t capacity = array->buffers[2]->capacity(); + uint64_t size = array->buffers[2]->size(); - if (ARROW_PREDICT_FALSE(value_offset >= capacity)) { + if (ARROW_PREDICT_FALSE(value_offset >= size)) { // allocate value buffer again // enlarge the buffer by 1.5x - capacity = capacity + std::max((capacity >> 1), (uint64_t)length); + size = size + std::max((size >> 1), (uint64_t)length); auto value_buffer = std::static_pointer_cast(array->buffers[2]); - value_buffer->Reserve(capacity); + value_buffer->Resize(size); array_data = value_buffer->mutable_data(); }