[FEAT MERGE] memtable support dynamic sample

Co-authored-by: wangt1xiuyi <13547954130@163.com>
This commit is contained in:
ZenoWang
2023-08-17 17:19:49 +08:00
committed by ob-robot
parent 09f80e6a68
commit c550060ac7
33 changed files with 966 additions and 389 deletions

View File

@ -153,9 +153,9 @@ int ObBasicStatsEstimator::estimate_block_count(ObExecContext &ctx,
} else if (param.part_level_ == share::schema::PARTITION_LEVEL_TWO &&
OB_FAIL(generate_first_part_idx_map(param.all_part_infos_, first_part_idx_map))) {
LOG_WARN("failed to generate first part idx map", K(ret));
} else if (OB_FAIL(do_estimate_block_count(ctx, param.tenant_id_, table_id, tablet_ids,
partition_ids, estimate_result))) {
LOG_WARN("failed to do estimate block count", K(ret));
} else if (OB_FAIL(do_estimate_block_count_and_row_count(ctx, param.tenant_id_, table_id, tablet_ids,
partition_ids, estimate_result))) {
LOG_WARN("failed to do estimate block count and row count", K(ret));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < estimate_result.count(); ++i) {
BolckNumPair block_num_pair;
@ -213,12 +213,12 @@ int ObBasicStatsEstimator::estimate_block_count(ObExecContext &ctx,
return ret;
}
int ObBasicStatsEstimator::do_estimate_block_count(ObExecContext &ctx,
const uint64_t tenant_id,
const uint64_t table_id,
const ObIArray<ObTabletID> &tablet_ids,
const ObIArray<ObObjectID> &partition_ids,
ObIArray<EstimateBlockRes> &estimate_res)
int ObBasicStatsEstimator::do_estimate_block_count_and_row_count(ObExecContext &ctx,
const uint64_t tenant_id,
const uint64_t table_id,
const ObIArray<ObTabletID> &tablet_ids,
const ObIArray<ObObjectID> &partition_ids,
ObIArray<EstimateBlockRes> &estimate_res)
{
int ret = OB_SUCCESS;
common::ObSEArray<ObCandiTabletLoc, 4> candi_tablet_locs;
@ -279,8 +279,8 @@ int ObBasicStatsEstimator::do_estimate_block_count(ObExecContext &ctx,
} else {/*do nothing*/}
}
if (OB_SUCC(ret)) {//begin storage estimate block count
if (OB_FAIL(stroage_estimate_block_count(ctx, cur_selected_addr, arg, result))) {
LOG_WARN("failed to stroage estimate block count", K(ret));
if (OB_FAIL(stroage_estimate_block_count_and_row_count(ctx, cur_selected_addr, arg, result))) {
LOG_WARN("failed to stroage estimate block count and row count", K(ret));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < selected_tablet_idx.count(); ++i) {
int64_t idx = selected_tablet_idx.at(i);
@ -293,6 +293,8 @@ int ObBasicStatsEstimator::do_estimate_block_count(ObExecContext &ctx,
estimate_res.at(idx).part_id_ = partition_ids.at(idx);
estimate_res.at(idx).macro_block_count_ = result.tablet_params_res_.at(i).macro_block_count_;
estimate_res.at(idx).micro_block_count_ = result.tablet_params_res_.at(i).micro_block_count_;
estimate_res.at(idx).sstable_row_count_ = result.tablet_params_res_.at(i).sstable_row_count_;
estimate_res.at(idx).memtable_row_count_ = result.tablet_params_res_.at(i).memtable_row_count_;
}
}
LOG_TRACE("succeed to estimate block count", K(selected_tablet_idx), K(partition_ids),
@ -305,17 +307,17 @@ int ObBasicStatsEstimator::do_estimate_block_count(ObExecContext &ctx,
return ret;
}
int ObBasicStatsEstimator::stroage_estimate_block_count(ObExecContext &ctx,
const ObAddr &addr,
const obrpc::ObEstBlockArg &arg,
obrpc::ObEstBlockRes &result)
int ObBasicStatsEstimator::stroage_estimate_block_count_and_row_count(ObExecContext &ctx,
const ObAddr &addr,
const obrpc::ObEstBlockArg &arg,
obrpc::ObEstBlockRes &result)
{
int ret = OB_SUCCESS;
if (addr == ctx.get_addr()) {
if (OB_FAIL(ObStorageEstimator::estimate_block_count(arg, result))) {
if (OB_FAIL(ObStorageEstimator::estimate_block_count_and_row_count(arg, result))) {
LOG_WARN("failed to estimate partition rows", K(ret));
} else {
LOG_TRACE("succeed to stroage estimate block count", K(addr), K(arg), K(result));
LOG_TRACE("succeed to stroage estimate block count and row count", K(addr), K(arg), K(result));
}
} else {
obrpc::ObSrvRpcProxy *rpc_proxy = NULL;

View File

@ -24,13 +24,17 @@ namespace common
struct EstimateBlockRes
{
EstimateBlockRes() : part_id_(), macro_block_count_(0), micro_block_count_(0) {}
EstimateBlockRes() : part_id_(), macro_block_count_(0), micro_block_count_(0), sstable_row_count_(0), memtable_row_count_(0) {}
ObObjectID part_id_;
int64_t macro_block_count_;
int64_t micro_block_count_;
int64_t sstable_row_count_;
int64_t memtable_row_count_;
TO_STRING_KV(K(part_id_),
K(macro_block_count_),
K(micro_block_count_));
K(micro_block_count_),
K(sstable_row_count_),
K(memtable_row_count_));
};
class ObBasicStatsEstimator : public ObStatsEstimator
@ -87,12 +91,12 @@ public:
static int gen_tablet_list(const ObTableStatParam &param,
ObSqlString &tablet_list);
static int do_estimate_block_count(ObExecContext &ctx,
const uint64_t tenant_id,
const uint64_t table_id,
const ObIArray<ObTabletID> &tablet_ids,
const ObIArray<ObObjectID> &partition_ids,
ObIArray<EstimateBlockRes> &estimate_res);
static int do_estimate_block_count_and_row_count(ObExecContext &ctx,
const uint64_t tenant_id,
const uint64_t table_id,
const ObIArray<ObTabletID> &tablet_ids,
const ObIArray<ObObjectID> &partition_ids,
ObIArray<EstimateBlockRes> &estimate_res);
static int get_tablet_locations(ObExecContext &ctx,
const uint64_t ref_table_id,
@ -100,10 +104,10 @@ public:
const ObIArray<ObObjectID> &partition_ids,
ObCandiTabletLocIArray &candi_tablet_locs);
static int stroage_estimate_block_count(ObExecContext &ctx,
const ObAddr &addr,
const obrpc::ObEstBlockArg &arg,
obrpc::ObEstBlockRes &result);
static int stroage_estimate_block_count_and_row_count(ObExecContext &ctx,
const ObAddr &addr,
const obrpc::ObEstBlockArg &arg,
obrpc::ObEstBlockRes &result);
static int get_all_tablet_id_and_object_id(const ObTableStatParam &param,
ObIArray<ObTabletID> &tablet_ids,