Fix group by pushdown to rle/const decoder
This commit is contained in:
@ -897,6 +897,8 @@ int ObConstDecoder::read_distinct(
|
|||||||
ctx.col_header_->length_ - meta_header_->offset_,
|
ctx.col_header_->length_ - meta_header_->offset_,
|
||||||
group_by_cell))) {
|
group_by_cell))) {
|
||||||
LOG_WARN("Failed to load dict", K(ret));
|
LOG_WARN("Failed to load dict", K(ret));
|
||||||
|
} else if (has_null_execption_value()) {
|
||||||
|
group_by_cell.add_distinct_null_value();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -919,5 +921,22 @@ int ObConstDecoder::read_reference(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ObConstDecoder::has_null_execption_value() const
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
bool has_null = false;
|
||||||
|
const int64_t dict_count = dict_decoder_.get_dict_header()->count_;
|
||||||
|
if (meta_header_->const_ref_ == dict_count) {
|
||||||
|
has_null = true;
|
||||||
|
} else {
|
||||||
|
int64_t ref;
|
||||||
|
for (int64_t pos = 0; !has_null && pos < meta_header_->count_; ++pos) {
|
||||||
|
ref = reinterpret_cast<const uint8_t*>(meta_header_->payload_)[pos];
|
||||||
|
has_null = ref >= dict_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return has_null;
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace blocksstable
|
} // end namespace blocksstable
|
||||||
} // end namespace oceanbase
|
} // end namespace oceanbase
|
||||||
|
@ -147,6 +147,8 @@ private:
|
|||||||
int64_t &null_count,
|
int64_t &null_count,
|
||||||
uint32_t *ref_buf = nullptr) const;
|
uint32_t *ref_buf = nullptr) const;
|
||||||
|
|
||||||
|
bool has_null_execption_value() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ObConstMetaHeader *meta_header_;
|
const ObConstMetaHeader *meta_header_;
|
||||||
ObDictDecoder dict_decoder_;
|
ObDictDecoder dict_decoder_;
|
||||||
|
@ -1471,7 +1471,16 @@ int ObDictDecoder::read_distinct(
|
|||||||
const char **cell_datas,
|
const char **cell_datas,
|
||||||
storage::ObGroupByCell &group_by_cell) const
|
storage::ObGroupByCell &group_by_cell) const
|
||||||
{
|
{
|
||||||
return batch_read_distinct(ctx, cell_datas, ctx.col_header_->length_, group_by_cell);
|
int ret = OB_SUCCESS;
|
||||||
|
bool has_null = false;
|
||||||
|
if (OB_FAIL(batch_read_distinct(ctx, cell_datas, ctx.col_header_->length_, group_by_cell))) {
|
||||||
|
LOG_WARN("Failed to batch read distinct", K(ret));
|
||||||
|
} else if (check_has_null(ctx, ctx.col_header_->length_, has_null)) {
|
||||||
|
LOG_WARN("Failed to check has null", K(ret));
|
||||||
|
} else if (has_null) {
|
||||||
|
group_by_cell.add_distinct_null_value();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObDictDecoder::batch_read_distinct(
|
int ObDictDecoder::batch_read_distinct(
|
||||||
@ -1485,7 +1494,6 @@ int ObDictDecoder::batch_read_distinct(
|
|||||||
const char *dict_payload = meta_header_->payload_;
|
const char *dict_payload = meta_header_->payload_;
|
||||||
const common::ObObjType obj_type = ctx.col_header_->get_store_obj_type();
|
const common::ObObjType obj_type = ctx.col_header_->get_store_obj_type();
|
||||||
common::ObDatum *datums = group_by_cell.get_group_by_col_datums_to_fill();
|
common::ObDatum *datums = group_by_cell.get_group_by_col_datums_to_fill();
|
||||||
bool has_null = false;
|
|
||||||
group_by_cell.set_distinct_cnt(count);
|
group_by_cell.set_distinct_cnt(count);
|
||||||
if (meta_header_->is_fix_length_dict()) {
|
if (meta_header_->is_fix_length_dict()) {
|
||||||
const int64_t dict_data_size = meta_header_->data_size_;
|
const int64_t dict_data_size = meta_header_->data_size_;
|
||||||
@ -1513,10 +1521,6 @@ int ObDictDecoder::batch_read_distinct(
|
|||||||
}
|
}
|
||||||
if (OB_FAIL(batch_load_data_to_datum(obj_type, cell_datas, count, integer_mask_, datums))) {
|
if (OB_FAIL(batch_load_data_to_datum(obj_type, cell_datas, count, integer_mask_, datums))) {
|
||||||
LOG_WARN("Failed to batch load data to datum", K(ret));
|
LOG_WARN("Failed to batch load data to datum", K(ret));
|
||||||
} else if (check_has_null(ctx, meta_length, has_null)) {
|
|
||||||
LOG_WARN("Failed to check has null", K(ret));
|
|
||||||
} else if (has_null) {
|
|
||||||
group_by_cell.add_distinct_null_value();
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -570,6 +570,8 @@ int ObRLEDecoder::read_distinct(
|
|||||||
ctx.col_header_->length_ - meta_header_->offset_,
|
ctx.col_header_->length_ - meta_header_->offset_,
|
||||||
group_by_cell))) {
|
group_by_cell))) {
|
||||||
LOG_WARN("Failed to load dict", K(ret));
|
LOG_WARN("Failed to load dict", K(ret));
|
||||||
|
} else if (has_null_value()) {
|
||||||
|
group_by_cell.add_distinct_null_value();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -588,5 +590,19 @@ int ObRLEDecoder::read_reference(
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ObRLEDecoder::has_null_value() const
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
bool has_null = false;
|
||||||
|
int64_t ref;
|
||||||
|
const int64_t dict_count = dict_decoder_.get_dict_header()->count_;
|
||||||
|
const ObIntArrayFuncTable &refs = ObIntArrayFuncTable::instance(meta_header_->ref_byte_);
|
||||||
|
for (int64_t i = 0; !has_null && i < meta_header_->count_; ++i) {
|
||||||
|
ref = refs.at_(meta_header_->payload_ + ref_offset_, i);
|
||||||
|
has_null = ref >= dict_count;
|
||||||
|
}
|
||||||
|
return has_null;
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace blocksstable
|
} // end namespace blocksstable
|
||||||
} // end namespace oceanbase
|
} // end namespace oceanbase
|
||||||
|
@ -150,6 +150,8 @@ private:
|
|||||||
const int64_t row_cap,
|
const int64_t row_cap,
|
||||||
storage::ObGroupByCell &group_by_cell) const override;
|
storage::ObGroupByCell &group_by_cell) const override;
|
||||||
|
|
||||||
|
bool has_null_value() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const ObRLEMetaHeader *meta_header_;
|
const ObRLEMetaHeader *meta_header_;
|
||||||
uint16_t ref_offset_;
|
uint16_t ref_offset_;
|
||||||
|
Reference in New Issue
Block a user