batch cherry pick bugfix codes

This commit is contained in:
obdev
2021-07-12 19:24:43 +08:00
committed by wangzelin.wzl
parent 9c7663609e
commit 4de3feb72f
12 changed files with 77 additions and 222 deletions

View File

@ -304,66 +304,5 @@ int ObShuffleService::init_expr_ctx(ObExecContext& exec_ctx)
return ret;
}
int ObShuffleService::get_hash_part_id(
const ObNewRow& row, const int64_t part_num, ObIArray<int64_t>& part_ids, const PartIdx2PartIdMap& part_map)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(row.is_invalid())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("row is invalid", K(ret), K(row));
} else if (1 != row.get_count() || (!row.get_cell(0).is_int() && !row.get_cell(0).is_null())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("row is invalid", K(ret), K(row));
} else {
int64_t value = row.get_cell(0).is_int() ? row.get_cell(0).get_int() : 0;
int64_t part_idx = -1;
int64_t part_id = -1;
if (value < 0) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("value should not be less than 0", K(ret), K(row));
} else if (OB_FAIL(ObPartitionUtils::calc_hash_part_idx(value, part_num, part_idx))) {
LOG_WARN("fail to calc hash part idx", K(ret));
} else if (OB_FAIL(part_map.get_refactored(part_idx, part_id))) {
LOG_WARN("fail to get part id by idx", K(ret), K(part_idx));
} else if (OB_FAIL(part_ids.push_back(part_id))) {
LOG_WARN("fail to add part id", K(ret));
} else {
// do nothing
}
}
return ret;
}
int ObShuffleService::get_hash_subpart_id(const common::ObNewRow& row, const int64_t subpart_num,
common::ObIArray<int64_t>& subpart_ids, const SubPartIdx2SubPartIdMap& subpart_map)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(row.is_invalid())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("row is invalid", K(ret), K(row));
} else if (1 != row.get_count() || (!row.get_cell(0).is_int() && !row.get_cell(0).is_null())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("row is invalid", K(ret), K(row));
} else {
int64_t value = row.get_cell(0).is_int() ? row.get_cell(0).get_int() : 0;
int64_t subpart_idx = -1;
int64_t subpart_id = -1;
if (value < 0) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("value should not be less than 0", K(ret), K(row));
} else if (OB_FAIL(ObPartitionUtils::calc_hash_part_idx(value, subpart_num, subpart_idx))) {
LOG_WARN("fail to calc hash subpart idx", K(ret), K(value), K(subpart_num));
} else if (OB_FAIL(subpart_map.get_refactored(subpart_idx, subpart_id))) {
LOG_WARN("fail to get subpart id by idx", K(ret), K(subpart_idx));
} else if (OB_FAIL(subpart_ids.push_back(subpart_id))) {
LOG_WARN("fail to push back subpart id to array", K(ret));
} else {
// do nothing
}
}
return ret;
}
} // namespace sql
} // namespace oceanbase