diff --git a/src/sql/engine/basic/ob_temp_column_store.cpp b/src/sql/engine/basic/ob_temp_column_store.cpp index fbb9f5adaa..687349a07a 100644 --- a/src/sql/engine/basic/ob_temp_column_store.cpp +++ b/src/sql/engine/basic/ob_temp_column_store.cpp @@ -171,6 +171,7 @@ int ObTempColumnStore::Iterator::get_next_batch(const ObExprPtrIArray &exprs, int64_t &read_rows) { int ret = OB_SUCCESS; + read_rows = 0; if (OB_UNLIKELY(exprs.count() != column_store_->get_col_cnt())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("column count mismatch", K(ret), K(exprs.count()), K(column_store_->get_col_cnt())); diff --git a/src/sql/engine/basic/ob_temp_column_store.h b/src/sql/engine/basic/ob_temp_column_store.h index f518a684d7..9357e344fc 100644 --- a/src/sql/engine/basic/ob_temp_column_store.h +++ b/src/sql/engine/basic/ob_temp_column_store.h @@ -288,15 +288,18 @@ template<> inline int ObTempColumnStore::from_vector(ObBitmapNullVectorBase *vec, ObExpr *expr, ObEvalCtx &ctx, const int64_t start_pos, const int64_t size) { - const uint16_t flag = vec->get_flag(); - ObBitVector &nulls = expr->get_nulls(ctx); - nulls.reset(size); - for (int64_t idx = start_pos; idx < size; ++idx) { - if (vec->is_null(idx)) { - nulls.set(idx - start_pos); + // reuse null vector memory if there is no null data + if (vec->has_null()) { + const uint16_t flag = vec->get_flag(); + ObBitVector &nulls = expr->get_nulls(ctx); + nulls.reset(size - start_pos); + for (int64_t idx = start_pos; idx < size; ++idx) { + if (vec->is_null(idx)) { + nulls.set(idx - start_pos); + } } + vec->from(&nulls, flag); } - vec->from(&nulls, flag); return common::OB_SUCCESS; } diff --git a/src/sql/engine/basic/ob_temp_row_store.cpp b/src/sql/engine/basic/ob_temp_row_store.cpp index d16b228670..0a95af1e23 100644 --- a/src/sql/engine/basic/ob_temp_row_store.cpp +++ b/src/sql/engine/basic/ob_temp_row_store.cpp @@ -263,6 +263,7 @@ int ObTempRowStore::Iterator::get_next_batch(const ObExprPtrIArray &exprs, const ObCompactRow **stored_rows) { int ret = OB_SUCCESS; + read_rows = 0; if (OB_FAIL(row_store_->init_batch_ctx())) { LOG_WARN("init batch ctx failed", K(ret)); } else if (OB_UNLIKELY(NULL == cur_blk_ || !cur_blk_->contain(cur_blk_id_))) { @@ -340,6 +341,7 @@ int ObTempRowStore::Iterator::get_next_batch(const int64_t max_rows, int64_t &read_rows, const ObCompactRow **stored_rows) { int ret = OB_SUCCESS; + read_rows = 0; if (OB_ISNULL(stored_rows)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("stored rows is null", K(ret));