[CP] opt the ScheObSchemAren
This commit is contained in:
committed by
ant-ob-hengtang
parent
29eb19ee7f
commit
59b1175bac
44
deps/oblib/src/lib/container/ob_array.h
vendored
44
deps/oblib/src/lib/container/ob_array.h
vendored
@ -155,18 +155,18 @@ public:
|
|||||||
//prepare allocate can avoid declaring local data
|
//prepare allocate can avoid declaring local data
|
||||||
int prepare_allocate(int64_t capacity)
|
int prepare_allocate(int64_t capacity)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
return inner_prepare_allocate(capacity, false);
|
||||||
ret = reserve(capacity);
|
}
|
||||||
if (OB_SUCC(ret)) {
|
template<typename ... Args>
|
||||||
for (int64_t index = valid_count_; index < capacity; ++index) {
|
inline int prepare_allocate(int64_t capacity, Args && ... args)
|
||||||
new(&data_[index]) T();
|
{
|
||||||
}
|
return inner_prepare_allocate(capacity, false, args...);
|
||||||
count_ = (capacity > count_) ? capacity : count_;
|
}
|
||||||
valid_count_ = (capacity > valid_count_) ? capacity : valid_count_;
|
|
||||||
} else {
|
template<typename ... Args>
|
||||||
OB_LOG(WARN, "Reserve capacity error", K(ret));
|
inline int prepare_allocate_and_keep_count(int64_t capacity, Args && ... args)
|
||||||
}
|
{
|
||||||
return ret;
|
return inner_prepare_allocate(capacity, true, args...);
|
||||||
}
|
}
|
||||||
int64_t to_string(char *buffer, int64_t length) const;
|
int64_t to_string(char *buffer, int64_t length) const;
|
||||||
inline int64_t get_data_size() const {return data_size_;}
|
inline int64_t get_data_size() const {return data_size_;}
|
||||||
@ -213,6 +213,26 @@ protected:
|
|||||||
using ObIArray<T>::count_;
|
using ObIArray<T>::count_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
template<typename ... Args>
|
||||||
|
inline int inner_prepare_allocate(int64_t capacity,
|
||||||
|
const bool keep_count,
|
||||||
|
Args && ... args)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ret = reserve(capacity);
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
|
for (int64_t index = valid_count_; index < capacity; ++index) {
|
||||||
|
new(&data_[index]) T(args...);
|
||||||
|
}
|
||||||
|
if (!keep_count) {
|
||||||
|
count_ = (capacity > count_) ? capacity : count_;
|
||||||
|
}
|
||||||
|
valid_count_ = (capacity > valid_count_) ? capacity : valid_count_;
|
||||||
|
} else {
|
||||||
|
OB_LOG(WARN, "Reserve capacity error", K(ret));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
inline int extend_buf()
|
inline int extend_buf()
|
||||||
{
|
{
|
||||||
int64_t new_size = MAX(2 * data_size_, block_size_);
|
int64_t new_size = MAX(2 * data_size_, block_size_);
|
||||||
|
|||||||
@ -24225,6 +24225,7 @@ int ObDDLService::create_normal_tenant(
|
|||||||
LOG_INFO("[CREATE_TENANT] STEP 2. start create tenant", K(tenant_id), K(tenant_schema), K(source_tenant_id));
|
LOG_INFO("[CREATE_TENANT] STEP 2. start create tenant", K(tenant_id), K(tenant_schema), K(source_tenant_id));
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
ObSArray<ObTableSchema> tables;
|
ObSArray<ObTableSchema> tables;
|
||||||
|
ObArenaAllocator arena_allocator("InnerTableSchem", OB_MALLOC_MIDDLE_BLOCK_SIZE);
|
||||||
if (OB_FAIL(check_inner_stat())) {
|
if (OB_FAIL(check_inner_stat())) {
|
||||||
LOG_WARN("variable is not init", KR(ret));
|
LOG_WARN("variable is not init", KR(ret));
|
||||||
} else if (OB_UNLIKELY(!recovery_until_scn.is_valid_and_not_min())) {
|
} else if (OB_UNLIKELY(!recovery_until_scn.is_valid_and_not_min())) {
|
||||||
@ -24239,7 +24240,7 @@ int ObDDLService::create_normal_tenant(
|
|||||||
LOG_WARN("fail to create tenant sys log stream", KR(ret), K(tenant_schema), K(pool_list), K(palf_base_info), K(source_tenant_id));
|
LOG_WARN("fail to create tenant sys log stream", KR(ret), K(tenant_schema), K(pool_list), K(palf_base_info), K(source_tenant_id));
|
||||||
} else if (is_user_tenant(tenant_id) && !tenant_role.is_primary()) {
|
} else if (is_user_tenant(tenant_id) && !tenant_role.is_primary()) {
|
||||||
//standby cluster no need create sys tablet and init tenant schema
|
//standby cluster no need create sys tablet and init tenant schema
|
||||||
} else if (OB_FAIL(ObSchemaUtils::construct_inner_table_schemas(tenant_id, tables))) {
|
} else if (OB_FAIL(ObSchemaUtils::construct_inner_table_schemas(tenant_id, tables, arena_allocator))) {
|
||||||
LOG_WARN("fail to get inner table schemas in tenant space", KR(ret), K(tenant_id));
|
LOG_WARN("fail to get inner table schemas in tenant space", KR(ret), K(tenant_id));
|
||||||
} else if (OB_FAIL(broadcast_sys_table_schemas(tenant_id, tables))) {
|
} else if (OB_FAIL(broadcast_sys_table_schemas(tenant_id, tables))) {
|
||||||
LOG_WARN("fail to broadcast sys table schemas", KR(ret), K(tenant_id));
|
LOG_WARN("fail to broadcast sys table schemas", KR(ret), K(tenant_id));
|
||||||
|
|||||||
@ -9263,7 +9263,8 @@ const ObLSInfo &ObDetectMasterRsLSResult::get_ls_info() const
|
|||||||
ObBatchBroadcastSchemaArg::ObBatchBroadcastSchemaArg()
|
ObBatchBroadcastSchemaArg::ObBatchBroadcastSchemaArg()
|
||||||
: tenant_id_(common::OB_INVALID_TENANT_ID),
|
: tenant_id_(common::OB_INVALID_TENANT_ID),
|
||||||
sys_schema_version_(common::OB_INVALID_VERSION),
|
sys_schema_version_(common::OB_INVALID_VERSION),
|
||||||
tables_()
|
tables_(),
|
||||||
|
allocator_("BroadcastSchema", OB_MALLOC_MIDDLE_BLOCK_SIZE)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ObBatchBroadcastSchemaArg::~ObBatchBroadcastSchemaArg()
|
ObBatchBroadcastSchemaArg::~ObBatchBroadcastSchemaArg()
|
||||||
@ -9275,8 +9276,8 @@ int ObBatchBroadcastSchemaArg::init(
|
|||||||
const common::ObIArray<share::schema::ObTableSchema> &tables)
|
const common::ObIArray<share::schema::ObTableSchema> &tables)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (OB_FAIL(tables_.assign(tables))) {
|
if (OB_FAIL(deep_copy_tables(tables))) {
|
||||||
LOG_WARN("fail to assign tables", KR(ret), K(tenant_id), K(sys_schema_version));
|
LOG_WARN("fail to assign tables", KR(ret), K(tables));
|
||||||
} else {
|
} else {
|
||||||
tenant_id_ = tenant_id;
|
tenant_id_ = tenant_id;
|
||||||
sys_schema_version_ = sys_schema_version;
|
sys_schema_version_ = sys_schema_version;
|
||||||
@ -9288,7 +9289,7 @@ int ObBatchBroadcastSchemaArg::assign(const ObBatchBroadcastSchemaArg &other)
|
|||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (this == &other) {
|
if (this == &other) {
|
||||||
} else if (OB_FAIL(tables_.assign(other.tables_))) {
|
} else if (OB_FAIL(deep_copy_tables(other.tables_))) {
|
||||||
LOG_WARN("fail to assign tables", KR(ret), K(other));
|
LOG_WARN("fail to assign tables", KR(ret), K(other));
|
||||||
} else {
|
} else {
|
||||||
tenant_id_ = other.tenant_id_;
|
tenant_id_ = other.tenant_id_;
|
||||||
@ -9297,6 +9298,21 @@ int ObBatchBroadcastSchemaArg::assign(const ObBatchBroadcastSchemaArg &other)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObBatchBroadcastSchemaArg::deep_copy_tables(const common::ObIArray<share::schema::ObTableSchema> &tables)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
int64_t count = tables.count();
|
||||||
|
tables_.reset();
|
||||||
|
if (OB_FAIL(tables_.prepare_allocate_and_keep_count(count, &allocator_))) {
|
||||||
|
LOG_WARN("fail to prepare allocate table schemas", KR(ret));
|
||||||
|
}
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && i < count; ++i) {
|
||||||
|
if (OB_FAIL(tables_.push_back(tables.at(i)))) {
|
||||||
|
LOG_WARN("fail to push back table schema", KR(ret));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
void ObBatchBroadcastSchemaArg::reset()
|
void ObBatchBroadcastSchemaArg::reset()
|
||||||
{
|
{
|
||||||
tenant_id_ = common::OB_INVALID_TENANT_ID;
|
tenant_id_ = common::OB_INVALID_TENANT_ID;
|
||||||
|
|||||||
@ -9565,6 +9565,7 @@ public:
|
|||||||
const int64_t sys_schema_version,
|
const int64_t sys_schema_version,
|
||||||
const common::ObIArray<share::schema::ObTableSchema> &tables);
|
const common::ObIArray<share::schema::ObTableSchema> &tables);
|
||||||
int assign(const ObBatchBroadcastSchemaArg &other);
|
int assign(const ObBatchBroadcastSchemaArg &other);
|
||||||
|
int deep_copy_tables(const common::ObIArray<share::schema::ObTableSchema> &tables);
|
||||||
void reset();
|
void reset();
|
||||||
bool is_valid() const;
|
bool is_valid() const;
|
||||||
|
|
||||||
@ -9576,6 +9577,8 @@ private:
|
|||||||
uint64_t tenant_id_;
|
uint64_t tenant_id_;
|
||||||
int64_t sys_schema_version_;
|
int64_t sys_schema_version_;
|
||||||
common::ObSArray<share::schema::ObTableSchema> tables_;
|
common::ObSArray<share::schema::ObTableSchema> tables_;
|
||||||
|
public:
|
||||||
|
common::ObArenaAllocator allocator_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ObBatchBroadcastSchemaResult
|
struct ObBatchBroadcastSchemaResult
|
||||||
|
|||||||
@ -442,7 +442,8 @@ int ObSchemaUtils::add_sys_table_lob_aux_table(
|
|||||||
// construct inner table schemas in tenant space
|
// construct inner table schemas in tenant space
|
||||||
int ObSchemaUtils::construct_inner_table_schemas(
|
int ObSchemaUtils::construct_inner_table_schemas(
|
||||||
const uint64_t tenant_id,
|
const uint64_t tenant_id,
|
||||||
ObIArray<ObTableSchema> &tables)
|
ObSArray<ObTableSchema> &tables,
|
||||||
|
ObIAllocator &allocator)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (is_sys_tenant(tenant_id)) {
|
if (is_sys_tenant(tenant_id)) {
|
||||||
@ -456,6 +457,16 @@ int ObSchemaUtils::construct_inner_table_schemas(
|
|||||||
virtual_table_schema_creators,
|
virtual_table_schema_creators,
|
||||||
sys_view_schema_creators
|
sys_view_schema_creators
|
||||||
};
|
};
|
||||||
|
int64_t capacity = 0;
|
||||||
|
for (int64_t i = 0; OB_SUCC(ret) && i < ARRAYSIZEOF(creator_ptr_arrays); ++i) {
|
||||||
|
for (const schema_create_func *creator_ptr = creator_ptr_arrays[i];
|
||||||
|
OB_SUCC(ret) && OB_NOT_NULL(*creator_ptr); ++creator_ptr) {
|
||||||
|
++capacity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (FAILEDx(tables.prepare_allocate_and_keep_count(capacity, &allocator))) {
|
||||||
|
LOG_WARN("fail to prepare allocate table schemas", KR(ret), K(tenant_id), K(capacity));
|
||||||
|
}
|
||||||
HEAP_VARS_2((ObTableSchema, table_schema), (ObTableSchema, data_schema)) {
|
HEAP_VARS_2((ObTableSchema, table_schema), (ObTableSchema, data_schema)) {
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < ARRAYSIZEOF(creator_ptr_arrays); ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < ARRAYSIZEOF(creator_ptr_arrays); ++i) {
|
||||||
for (const schema_create_func *creator_ptr = creator_ptr_arrays[i];
|
for (const schema_create_func *creator_ptr = creator_ptr_arrays[i];
|
||||||
|
|||||||
@ -115,7 +115,8 @@ public:
|
|||||||
share::schema::ObTableSchema &table);
|
share::schema::ObTableSchema &table);
|
||||||
static int construct_inner_table_schemas(
|
static int construct_inner_table_schemas(
|
||||||
const uint64_t tenant_id,
|
const uint64_t tenant_id,
|
||||||
common::ObIArray<share::schema::ObTableSchema> &tables);
|
common::ObSArray<share::schema::ObTableSchema> &tables,
|
||||||
|
common::ObIAllocator &allocator);
|
||||||
static int add_sys_table_lob_aux_table(
|
static int add_sys_table_lob_aux_table(
|
||||||
uint64_t tenant_id,
|
uint64_t tenant_id,
|
||||||
uint64_t data_table_id,
|
uint64_t data_table_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user