From b2bf29f626fcb85096252ca3f0620ec644cab1f8 Mon Sep 17 00:00:00 2001 From: lichuang Date: Thu, 14 Sep 2023 20:50:06 +0800 Subject: [PATCH] [bug] byteBuffer calculate new capacity bug fix. --- .../doris/spark/load/RecordBatchInputStream.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/spark-doris-connector/src/main/java/org/apache/doris/spark/load/RecordBatchInputStream.java b/spark-doris-connector/src/main/java/org/apache/doris/spark/load/RecordBatchInputStream.java index 9444c1da..70069d2b 100644 --- a/spark-doris-connector/src/main/java/org/apache/doris/spark/load/RecordBatchInputStream.java +++ b/spark-doris-connector/src/main/java/org/apache/doris/spark/load/RecordBatchInputStream.java @@ -170,14 +170,13 @@ private void ensureCapacity(int need) { * @return new capacity */ private int calculateNewCapacity(int capacity, int minCapacity) { - int newCapacity; + int newCapacity = 0; if (capacity == 0) { newCapacity = DEFAULT_BUF_SIZE; - while (newCapacity < minCapacity) { - newCapacity = newCapacity << 1; - } - } else { - newCapacity = capacity << 1; + + } + while (newCapacity < minCapacity) { + newCapacity = newCapacity << 1; } return newCapacity; }