Merge branch 'column_store'
Co-authored-by: wangt1xiuyi <13547954130@163.com> Co-authored-by: yangqise7en <877793735@qq.com> Co-authored-by: Zach41 <zach_41@163.com>
This commit is contained in:
@ -31,14 +31,15 @@ namespace storage
|
||||
|
||||
ObBlockRowStore::ObBlockRowStore(ObTableAccessContext &context)
|
||||
: is_inited_(false),
|
||||
context_(context),
|
||||
can_blockscan_(false),
|
||||
filter_applied_(false),
|
||||
disabled_(false)
|
||||
pd_filter_info_(),
|
||||
context_(context),
|
||||
can_blockscan_(false),
|
||||
filter_applied_(false),
|
||||
disabled_(false)
|
||||
{}
|
||||
|
||||
ObBlockRowStore::~ObBlockRowStore()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
void ObBlockRowStore::reset()
|
||||
@ -46,16 +47,7 @@ void ObBlockRowStore::reset()
|
||||
is_inited_ = false;
|
||||
can_blockscan_ = false;
|
||||
filter_applied_ = false;
|
||||
if (nullptr != context_.stmt_allocator_ && nullptr != pd_filter_info_.col_buf_) {
|
||||
context_.stmt_allocator_->free(pd_filter_info_.col_buf_);
|
||||
pd_filter_info_.col_buf_ = nullptr;
|
||||
}
|
||||
if (nullptr != context_.stmt_allocator_ && nullptr != pd_filter_info_.datum_buf_) {
|
||||
context_.stmt_allocator_->free(pd_filter_info_.datum_buf_);
|
||||
pd_filter_info_.datum_buf_ = nullptr;
|
||||
}
|
||||
pd_filter_info_.col_capacity_ = 0;
|
||||
pd_filter_info_.filter_ = nullptr;
|
||||
pd_filter_info_.reset();
|
||||
disabled_ = false;
|
||||
}
|
||||
|
||||
@ -69,38 +61,15 @@ void ObBlockRowStore::reuse()
|
||||
int ObBlockRowStore::init(const ObTableAccessParam ¶m)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
void *buf = nullptr;
|
||||
const ObTableIterParam &iter_param = param.iter_param_;
|
||||
int64_t out_col_cnt = iter_param.get_out_col_cnt();
|
||||
pd_filter_info_.is_pd_filter_ = iter_param.enable_pd_filter();
|
||||
const bool need_padding = is_pad_char_to_full_length(context_.sql_mode_);
|
||||
if (IS_INIT) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("ObBlockRowStore init twice", K(ret));
|
||||
} else if (OB_UNLIKELY(!iter_param.is_valid() || nullptr == context_.stmt_allocator_
|
||||
|| nullptr == iter_param.get_col_params() || nullptr == iter_param.out_cols_project_)) {
|
||||
} else if (OB_ISNULL(context_.stmt_allocator_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("Invalid argument to init store pushdown filter", K(ret), K(iter_param));
|
||||
} else if (nullptr == iter_param.pushdown_filter_) {
|
||||
// nothing to do without filter exprs
|
||||
is_inited_ = true;
|
||||
} else if (OB_UNLIKELY(0 == out_col_cnt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpceted empty output", K(ret), K(iter_param));
|
||||
} else if (OB_ISNULL((buf = context_.stmt_allocator_->alloc(sizeof(ObObj) * out_col_cnt)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("Fail to allocate memory for pushdown filter col buf", K(ret), K(out_col_cnt));
|
||||
} else if (FALSE_IT(pd_filter_info_.col_buf_ = new (buf) ObObj[out_col_cnt]())) {
|
||||
} else if (OB_ISNULL((buf = context_.stmt_allocator_->alloc(sizeof(blocksstable::ObStorageDatum) * out_col_cnt)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("Fail to allocate memory for pushdown filter col buf", K(ret), K(out_col_cnt));
|
||||
} else if (FALSE_IT(pd_filter_info_.datum_buf_ = new (buf) blocksstable::ObStorageDatum[out_col_cnt]())) {
|
||||
} else if (OB_FAIL(iter_param.pushdown_filter_->init_filter_param(
|
||||
*iter_param.get_col_params(), *iter_param.out_cols_project_, need_padding))) {
|
||||
LOG_WARN("Failed to init pushdown filter executor", K(ret));
|
||||
LOG_WARN("Invalid argument to init store pushdown filter", K(ret));
|
||||
} else if (OB_FAIL(pd_filter_info_.init(param.iter_param_, *context_.stmt_allocator_))) {
|
||||
LOG_WARN("Fail to init pd filter info", K(ret));
|
||||
} else {
|
||||
pd_filter_info_.filter_ = iter_param.pushdown_filter_;
|
||||
pd_filter_info_.col_capacity_ = out_col_cnt;
|
||||
is_inited_ = true;
|
||||
}
|
||||
|
||||
@ -112,26 +81,20 @@ int ObBlockRowStore::init(const ObTableAccessParam ¶m)
|
||||
|
||||
int ObBlockRowStore::apply_blockscan(
|
||||
blocksstable::ObIMicroBlockRowScanner µ_scanner,
|
||||
const int64_t row_count,
|
||||
const bool can_pushdown,
|
||||
ObTableStoreStat &table_store_stat)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t access_count = micro_scanner.get_access_cnt();
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ObBlockRowStore is not inited", K(ret), K(*this));
|
||||
} else if (OB_UNLIKELY(row_count <= 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpceted row count of micro block", K(ret), K(row_count));
|
||||
} else if (!pd_filter_info_.is_pd_filter_ || !can_pushdown) {
|
||||
filter_applied_ = false;
|
||||
} else if (nullptr == pd_filter_info_.filter_) {
|
||||
// nothing to do
|
||||
filter_applied_ = true;
|
||||
} else if (OB_FAIL(filter_micro_block(row_count,
|
||||
micro_scanner,
|
||||
nullptr,
|
||||
pd_filter_info_.filter_))) {
|
||||
} else if (OB_FAIL(micro_scanner.filter_micro_block_in_blockscan(pd_filter_info_))) {
|
||||
LOG_WARN("Failed to apply pushdown filter in block reader", K(ret), K(*this));
|
||||
} else {
|
||||
filter_applied_ = true;
|
||||
@ -141,103 +104,63 @@ int ObBlockRowStore::apply_blockscan(
|
||||
// Check pushdown filter successed
|
||||
can_blockscan_ = true;
|
||||
++table_store_stat.pushdown_micro_access_cnt_;
|
||||
table_store_stat.pushdown_row_access_cnt_ += row_count;
|
||||
table_store_stat.pushdown_row_access_cnt_ += access_count;
|
||||
if (!filter_applied_ || nullptr == pd_filter_info_.filter_) {
|
||||
table_store_stat.pushdown_row_select_cnt_ += row_count;
|
||||
table_store_stat.pushdown_row_select_cnt_ += access_count;
|
||||
} else {
|
||||
table_store_stat.pushdown_row_select_cnt_ += pd_filter_info_.filter_->get_result()->popcnt();
|
||||
EVENT_ADD(ObStatEventIds::PUSHDOWN_STORAGE_FILTER_ROW_CNT, pd_filter_info_.filter_->get_result()->popcnt());
|
||||
int64_t select_cnt = pd_filter_info_.filter_->get_result()->popcnt();
|
||||
table_store_stat.pushdown_row_select_cnt_ += select_cnt;
|
||||
EVENT_ADD(ObStatEventIds::PUSHDOWN_STORAGE_FILTER_ROW_CNT, select_cnt);
|
||||
}
|
||||
EVENT_ADD(ObStatEventIds::BLOCKSCAN_ROW_CNT, row_count);
|
||||
LOG_DEBUG("[PUSHDOWN] apply blockscan succ", K(row_count), KPC(pd_filter_info_.filter_), K(*this));
|
||||
EVENT_ADD(ObStatEventIds::BLOCKSCAN_ROW_CNT, access_count);
|
||||
LOG_DEBUG("[PUSHDOWN] apply blockscan succ", K(access_count), KPC(pd_filter_info_.filter_), K(*this));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObBlockRowStore::filter_micro_block(
|
||||
const int64_t row_count,
|
||||
blocksstable::ObIMicroBlockRowScanner µ_scanner,
|
||||
sql::ObPushdownFilterExecutor *parent,
|
||||
sql::ObPushdownFilterExecutor *filter)
|
||||
int ObBlockRowStore::get_filter_result(ObFilterResult &res)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObBitmap *result = nullptr;
|
||||
if (OB_UNLIKELY(nullptr == filter || row_count <= 0)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("Invalid argument", K(ret), KP(filter), K(row_count));
|
||||
} else if (OB_FAIL(filter->init_bitmap(row_count, result))) {
|
||||
LOG_WARN("Failed to get filter bitmap", K(ret));
|
||||
} else if (OB_ISNULL(result)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpected null filter bitmap", K(ret));
|
||||
} else if (nullptr != parent && OB_FAIL(parent->prepare_skip_filter())) {
|
||||
LOG_WARN("Failed to check parent blockscan", K(ret));
|
||||
} else if (filter->is_filter_node()) {
|
||||
if (OB_FAIL(micro_scanner.filter_pushdown_filter(parent, filter, pd_filter_info_, *result))) {
|
||||
LOG_WARN("Failed to filter pushdown filter", K(ret), KPC(filter));
|
||||
}
|
||||
} else if (filter->is_logic_op_node()) {
|
||||
if (OB_UNLIKELY(filter->get_child_count() < 2)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpected child count of filter executor", K(ret), K(filter->get_child_count()), KP(filter));
|
||||
} else {
|
||||
sql::ObPushdownFilterExecutor **children = filter->get_childs();
|
||||
for (uint32_t i = 0; OB_SUCC(ret) && i < filter->get_child_count(); i++) {
|
||||
const common::ObBitmap *child_result = nullptr;
|
||||
if (OB_ISNULL(children[i])) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpected null child filter", K(ret));
|
||||
} else if (OB_FAIL(filter_micro_block(row_count, micro_scanner, filter, children[i]))) {
|
||||
LOG_WARN("Failed to filter micro block", K(ret), K(i), KP(children[i]));
|
||||
} else if (OB_ISNULL(child_result = children[i]->get_result())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpected get null filter bitmap", K(ret));
|
||||
} else {
|
||||
if (filter->is_logic_and_node()) {
|
||||
if (OB_FAIL(result->bit_and(*child_result))) {
|
||||
LOG_WARN("Failed to merge result bitmap", K(ret), KP(child_result));
|
||||
} else if (result->is_all_false()) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(result->bit_or(*child_result))) {
|
||||
LOG_WARN("Failed to merge result bitmap", K(ret), KP(child_result));
|
||||
} else if (result->is_all_true()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("not supported filter executor type", K(ret), K(filter->get_type()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObBlockRowStore::get_result_bitmap(const common::ObBitmap *&bitmap)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bitmap = nullptr;
|
||||
res.bitmap_ = nullptr;
|
||||
res.filter_start_ = pd_filter_info_.start_;
|
||||
if (nullptr == pd_filter_info_.filter_ || !filter_applied_) {
|
||||
} else if (OB_ISNULL(bitmap = pd_filter_info_.filter_->get_result())) {
|
||||
} else if (OB_ISNULL(res.bitmap_ = pd_filter_info_.filter_->get_result())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpected null filter bitmap", K(ret));
|
||||
} else if (res.bitmap_->is_all_true()) {
|
||||
res.bitmap_ = nullptr;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObBlockRowStore::open()
|
||||
int ObBlockRowStore::open(const ObTableIterParam &iter_param)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const bool need_padding = is_pad_char_to_full_length(context_.sql_mode_);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("Not init", K(ret));
|
||||
} else if (OB_UNLIKELY(!iter_param.is_valid() ||
|
||||
nullptr == iter_param.get_col_params() ||
|
||||
nullptr == iter_param.out_cols_project_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("Invalid argument to init store pushdown filter", K(ret), K(iter_param));
|
||||
} else if (nullptr == pd_filter_info_.filter_) {
|
||||
// nothing to do
|
||||
} else if (OB_FAIL(pd_filter_info_.filter_->init_evaluated_datums())) {
|
||||
LOG_WARN("Failed to init pushdown filter evaluated datums", K(ret));
|
||||
} else {
|
||||
if (iter_param.is_use_column_store()) {
|
||||
if (OB_FAIL(pd_filter_info_.filter_->init_co_filter_param(iter_param, need_padding))) {
|
||||
LOG_WARN("Failed to init pushdown filter executor", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(pd_filter_info_.filter_->init_filter_param(
|
||||
*iter_param.get_col_params(), *iter_param.out_cols_project_, need_padding))) {
|
||||
LOG_WARN("Failed to init pushdown filter executor", K(ret));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(pd_filter_info_.filter_->init_evaluated_datums())) {
|
||||
LOG_WARN("Failed to init pushdown filter evaluated datums", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user