From 607cd63eda5ec30b9c998a25cded21ae226a4167 Mon Sep 17 00:00:00 2001 From: taiyang-li <654010905@qq.com> Date: Fri, 18 Nov 2022 11:08:01 +0800 Subject: [PATCH] close https://github.com/Kyligence/ClickHouse/issues/199 --- utils/local-engine/Parser/SparkRowToCHColumn.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/utils/local-engine/Parser/SparkRowToCHColumn.h b/utils/local-engine/Parser/SparkRowToCHColumn.h index 8a06d8237d7e..200194d68518 100644 --- a/utils/local-engine/Parser/SparkRowToCHColumn.h +++ b/utils/local-engine/Parser/SparkRowToCHColumn.h @@ -91,14 +91,23 @@ class SparkRowToCHColumn auto * rows_buf_ptr = static_cast(env->GetDirectBufferAddress(rows_buf)); int len = *(reinterpret_cast(rows_buf_ptr)); - // when len = -1, reach the buf's end. - while (len > 0) + // len = -1 means reaching the buf's end. + while (len >= 0) { rows_buf_ptr += 4; appendSparkRowToCHColumn(helper, rows_buf_ptr, len); - rows_buf_ptr += len; - len = *(reinterpret_cast(rows_buf_ptr)); + + if (len > 0) + { + rows_buf_ptr += len; + len = *(reinterpret_cast(rows_buf_ptr)); + } + else + { + len = -1; + } } + // Try to release reference. env->DeleteLocalRef(rows_buf); }