provide a better performing interface to get tablet ls mapping

This commit is contained in:
ZhenNan0
2023-08-02 04:42:19 +00:00
committed by ob-robot
parent b92ecbf728
commit 1ebe477f5e
3 changed files with 65 additions and 0 deletions

View File

@ -677,5 +677,39 @@ int ObTabletToLSTableOperator::construct_results_(
return ret;
}
int ObTabletToLSTableOperator::batch_get_tablet_ls_pairs(
common::ObISQLClient &sql_proxy,
const uint64_t tenant_id,
const ObIArray<common::ObTabletID> &tablet_ids,
ObIArray<ObTabletLSPair> &tablet_ls_pairs)
{
int ret = OB_SUCCESS;
BATCH_GET(sql_proxy, tenant_id, tablet_ids, tablet_ls_pairs);
if (OB_SUCC(ret) && OB_UNLIKELY(tablet_ls_pairs.count() != tablet_ids.count())) {
ret = OB_ITEM_NOT_MATCH;
LOG_WARN("count of tablet_ls_pairs and tablet_ids do not match,"
" there may be duplicates or nonexistent values in tablet_ids",
KR(ret), "tablet_ids count", tablet_ids.count(), "tablet_ls_pairs count",
tablet_ls_pairs.count(), K(tenant_id), K(tablet_ids), K(tablet_ls_pairs));
}
return ret;
}
int ObTabletToLSTableOperator::inner_batch_get_(
common::ObISQLClient &sql_proxy,
const uint64_t tenant_id,
const ObIArray<common::ObTabletID> &tablet_ids,
const int64_t start_idx,
const int64_t end_idx,
ObIArray<ObTabletLSPair> &tablet_ls_pairs)
{
int ret = OB_SUCCESS;
const char *query_column_str = "tablet_id, ls_id";
const bool keep_order = false;
INNER_BATCH_GET(sql_proxy, tenant_id, tablet_ids, start_idx, end_idx,
query_column_str, keep_order, tablet_ls_pairs);
return ret;
}
} // end namespace share
} // end namespace oceanbase

View File

@ -173,6 +173,22 @@ public:
const common::ObIArray<common::ObTabletID> &tablet_ids,
common::ObIArray<ObTabletLSCache> &tablet_ls_caches);
// Gets ObTabletLSPair according to ObTableIDs
//
// @param [in] sql_proxy, ObMySQLProxy or ObMySQLTransaction
// @param [in] tenant_id, tenant for query
// @param [in] tablet_ids, ObTabletIDs for query (no duplicate values)
// @param [out] tablet_ls_pairs, array of <TabletID, LSID>
// @return OB_SUCCESS if success;
// OB_ITEM_NOT_MATCH if tablet_ids have duplicates or
// tablet_id which is not recorded in __all_tablet_to_ls;
// Other error according to unexpected situation
static int batch_get_tablet_ls_pairs(
common::ObISQLClient &sql_proxy,
const uint64_t tenant_id,
const ObIArray<common::ObTabletID> &tablet_ids,
ObIArray<ObTabletLSPair> &tablet_ls_pairs);
const static int64_t MAX_BATCH_COUNT = 200;
private:
static int inner_batch_get_(
@ -196,6 +212,13 @@ private:
const int64_t start_idx,
const int64_t end_idx,
common::ObIArray<ObTabletLSCache> &tablet_ls_caches);
static int inner_batch_get_(
common::ObISQLClient &sql_proxy,
const uint64_t tenant_id,
const ObIArray<common::ObTabletID> &tablet_ids,
const int64_t start_idx,
const int64_t end_idx,
ObIArray<ObTabletLSPair> &tablet_ls_pairs);
static int inner_batch_update_by_sql_(
common::ObISQLClient &sql_proxy,