提交 528a51f7 编写于 作者: S saltonz 提交者: ob-robot

[bugfix ] fix encoding under estimate upper store size for var-length data

上级 08a372ab
......@@ -82,6 +82,12 @@ OB_INLINE bool store_class_might_contain_lob_locator(const ObObjTypeStoreClass s
return (sc == ObTextSC || sc == ObLobSC || sc == ObJsonSC || sc == ObGeometrySC);
}
OB_INLINE bool is_var_length_type(const ObObjTypeStoreClass sc)
{
return (sc == ObNumberSC || sc == ObStringSC || sc == ObTextSC
|| sc == ObLobSC || sc == ObJsonSC || sc == ObGeometrySC);
}
OB_INLINE ObObjTypeStoreClass *get_store_class_map()
{
static ObObjTypeStoreClass store_class_map[] = {
......
......@@ -994,6 +994,13 @@ int ObMicroBlockEncoder::copy_cell(
LOG_WARN("unsupported store extend datum type", K(ret), K(src));
} else {
datum_size = is_int_sc ? sizeof(uint64_t) : dest.len_;
if (ctx_.major_working_cluster_version_ >= DATA_VERSION_4_1_0_0) {
if (is_var_length_type(store_class)) {
// For var-length type column, we need to add extra 8 bytes for estimate safety
// e.g: ref size for dictionary, meta data for encoding etc.
datum_size += sizeof(uint64_t);
}
}
}
if (OB_FAIL(ret)) {
......@@ -1024,6 +1031,7 @@ int ObMicroBlockEncoder::process_large_row(
// store_size represents for the serialized data size on disk,
const int64_t datums_len = sizeof(ObDatum) * src.get_column_count();
int64_t copy_size = datums_len;
int64_t var_len_column_cnt = 0;
for (int64_t col_idx = 0; col_idx < src.get_column_count(); ++col_idx) {
const ObColDesc &col_desc = ctx_.col_descs_->at(col_idx);
ObObjTypeStoreClass store_class = get_store_class_map()[col_desc.col_type_.get_type_class()];
......@@ -1033,12 +1041,19 @@ int ObMicroBlockEncoder::process_large_row(
copy_size += sizeof(uint64_t);
} else {
copy_size += datum.len_;
if (is_var_length_type(store_class)) {
++var_len_column_cnt;
}
}
} else {
copy_size += sizeof(uint64_t);
}
}
store_size = copy_size - datums_len;
if (ctx_.major_working_cluster_version_ >= DATA_VERSION_4_1_0_0) {
store_size = copy_size - datums_len + var_len_column_cnt * sizeof(uint64_t);
} else {
store_size = copy_size - datums_len;
}
if (OB_FAIL(row_buf_holder_.try_alloc(copy_size))) {
LOG_WARN("Fail to alloc large row buffer", K(ret), K(copy_size));
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册