diff --git a/src/sql/engine/sort/ob_sort_op_impl.cpp b/src/sql/engine/sort/ob_sort_op_impl.cpp index 94d2247c7c..b0d04bc4b7 100644 --- a/src/sql/engine/sort/ob_sort_op_impl.cpp +++ b/src/sql/engine/sort/ob_sort_op_impl.cpp @@ -1423,11 +1423,10 @@ int ObSortOpImpl::prepare_bucket_array(ArrayType *&buckets, uint64_t bucket_num) } else { int64_t max_bucket_cnt = buckets->get_capacity(); if (max_bucket_cnt < bucket_num) { - if (OB_FAIL(buckets->reserve(bucket_num))) { - LOG_WARN("failed to reserve bucket array", K(ret), K(bucket_num)); - } - } else { buckets->reuse(); + if (OB_FAIL(buckets->init(bucket_num))) { + LOG_WARN("failed to init bucket array", K(ret), K(bucket_num)); + } } } return ret; @@ -1455,6 +1454,7 @@ int ObSortOpImpl::do_partition_sort(common::ObIArray(part_hash_nodes_, node_cnt))) { LOG_WARN("failed to create bucket node array", K(ret)); } else { + buckets_->set_all(nullptr); max_bucket_cnt_ = bucket_cnt; max_node_cnt_ = node_cnt; } diff --git a/src/sql/engine/sort/ob_sort_vec_op_impl.h b/src/sql/engine/sort/ob_sort_vec_op_impl.h index 6506329dbd..7052e67d03 100644 --- a/src/sql/engine/sort/ob_sort_vec_op_impl.h +++ b/src/sql/engine/sort/ob_sort_vec_op_impl.h @@ -383,11 +383,10 @@ protected: } else { int64_t max_bucket_cnt = buckets->get_capacity(); if (max_bucket_cnt < bucket_num) { - if (OB_FAIL(buckets->reserve(bucket_num))) { - LOG_WARN("failed to reserve bucket array", K(ret), K(bucket_num)); - } - } else { buckets->reuse(); + if (OB_FAIL(buckets->init(bucket_num))) { + LOG_WARN("failed to init bucket array", K(ret), K(bucket_num)); + } } } return ret; diff --git a/src/sql/engine/sort/ob_sort_vec_op_impl.ipp b/src/sql/engine/sort/ob_sort_vec_op_impl.ipp index aae09ba9b7..d2abc01172 100644 --- a/src/sql/engine/sort/ob_sort_vec_op_impl.ipp +++ b/src/sql/engine/sort/ob_sort_vec_op_impl.ipp @@ -1309,6 +1309,7 @@ int ObSortVecOpImpl::do_partition_sort( } else if (OB_FAIL(prepare_bucket_array(part_hash_nodes_, node_cnt))) { LOG_WARN("failed to create bucket node array", K(ret)); } else { + buckets_->set_all(nullptr); max_bucket_cnt_ = bucket_cnt; max_node_cnt_ = node_cnt; }