Construct IndexBlockDataTransformer on stack which is used to be thread local storage.
This commit is contained in:
@ -77,16 +77,14 @@ void TestIndexBlockRowScanner::TearDown()
|
||||
|
||||
TEST_F(TestIndexBlockRowScanner, transform)
|
||||
{
|
||||
ObIndexBlockDataTransformer *index_block_transformer = nullptr;
|
||||
index_block_transformer = GET_TSI_MULT(ObIndexBlockDataTransformer, 1);
|
||||
ASSERT_NE(nullptr, index_block_transformer);
|
||||
ObIndexBlockDataTransformer index_block_transformer;
|
||||
const ObMicroBlockHeader *micro_header
|
||||
= reinterpret_cast<const ObMicroBlockHeader *>(root_block_data_buf_.get_buf());
|
||||
int64_t extra_size = ObIndexBlockDataTransformer::get_transformed_block_mem_size(
|
||||
root_block_data_buf_);
|
||||
char * extra_buf = reinterpret_cast<char *>(allocator_.alloc(extra_size));
|
||||
ASSERT_NE(nullptr, extra_buf);
|
||||
ASSERT_EQ(OB_SUCCESS, index_block_transformer->transform(
|
||||
ASSERT_EQ(OB_SUCCESS, index_block_transformer.transform(
|
||||
tablet_handle_.get_obj()->get_index_read_info(), root_block_data_buf_, extra_buf, extra_size));
|
||||
const ObIndexBlockDataHeader *idx_blk_header
|
||||
= reinterpret_cast<const ObIndexBlockDataHeader *>(extra_buf);
|
||||
@ -108,7 +106,7 @@ TEST_F(TestIndexBlockRowScanner, transform)
|
||||
ASSERT_NE(nullptr, new_buf);
|
||||
char *new_extra_buf = new_buf + root_block_data_buf_.get_buf_size();
|
||||
MEMCPY(new_buf, root_block_data_buf_.get_buf(), root_block_data_buf_.get_buf_size());
|
||||
ASSERT_EQ(OB_SUCCESS, index_block_transformer->update_index_block(
|
||||
ASSERT_EQ(OB_SUCCESS, index_block_transformer.update_index_block(
|
||||
*idx_blk_header,
|
||||
new_buf,
|
||||
root_block_data_buf_.get_buf_size(),
|
||||
@ -150,16 +148,14 @@ TEST_F(TestIndexBlockRowScanner, prefetch_and_scan)
|
||||
ObArray<ObColumnSchemaV2> agg_column_schema;
|
||||
ObQueryFlag query_flag;
|
||||
query_flag.set_use_block_cache();
|
||||
ObIndexBlockDataTransformer *transformer = nullptr;
|
||||
transformer = GET_TSI_MULT(ObIndexBlockDataTransformer, 1);
|
||||
ASSERT_NE(nullptr, transformer);
|
||||
ObIndexBlockDataTransformer transformer;
|
||||
const ObMicroBlockHeader *micro_header
|
||||
= reinterpret_cast<const ObMicroBlockHeader *>(root_block_data_buf_.get_buf());
|
||||
int64_t extra_size = ObIndexBlockDataTransformer::get_transformed_block_mem_size(
|
||||
root_block_data_buf_);
|
||||
char * extra_buf = reinterpret_cast<char *>(allocator_.alloc(extra_size));
|
||||
ASSERT_NE(nullptr, extra_buf);
|
||||
ASSERT_EQ(OB_SUCCESS, transformer->transform(
|
||||
ASSERT_EQ(OB_SUCCESS, transformer.transform(
|
||||
tablet_handle_.get_obj()->get_index_read_info(), root_block_data_buf_, extra_buf, extra_size));
|
||||
const ObIndexBlockDataHeader *root_blk_header
|
||||
= reinterpret_cast<const ObIndexBlockDataHeader *>(extra_buf);
|
||||
|
@ -165,16 +165,8 @@ int ObMicroBlockCacheValue::deep_copy(char *buf, const int64_t buf_len, ObIKVCac
|
||||
case ObMicroBlockData::Type::INDEX_BLOCK: {
|
||||
const ObIndexBlockDataHeader *src_idx_header
|
||||
= reinterpret_cast<const ObIndexBlockDataHeader *>(block_data_.get_extra_buf());
|
||||
ObIndexBlockDataTransformer *transformer = nullptr;
|
||||
ObDecoderAllocator *allocator = nullptr;
|
||||
if (OB_ISNULL(allocator = get_decoder_allocator())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to allocate decoder allocator", K(ret));
|
||||
} else if (OB_ISNULL(transformer = GET_TSI_MULT(ObIndexBlockDataTransformer, 1))) {
|
||||
// There must be get_decoder_allocator before GET_TSI_MULT(ObIndexBlockDataTransformer)
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("Fail to get thread local index block data transformer", K(ret));
|
||||
} else if (OB_FAIL(transformer->update_index_block(
|
||||
ObIndexBlockDataTransformer transformer;
|
||||
if (OB_FAIL(transformer.update_index_block(
|
||||
*src_idx_header,
|
||||
new_buf,
|
||||
block_data_.get_buf_size(),
|
||||
@ -1263,16 +1255,8 @@ int ObIndexMicroBlockCache::write_extra_buf(const ObTableReadInfo &read_info,
|
||||
UNUSEDx(block_buf, block_size);
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
ObIndexBlockDataTransformer *transformer = nullptr;
|
||||
ObDecoderAllocator* allocator = nullptr;
|
||||
if (OB_ISNULL(allocator = get_decoder_allocator())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to allocate decoder allocator", K(ret));
|
||||
} else if (OB_ISNULL(transformer = GET_TSI_MULT(ObIndexBlockDataTransformer, 1))) {
|
||||
// There must be get_decoder_allocator before GET_TSI_MULT(ObIndexBlockDataTransformer)
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("Fail to allocate ObIndexBlockDataTransformer", K(ret));
|
||||
} else if (OB_FAIL(transformer->transform(read_info, micro_data, extra_buf, extra_size))) {
|
||||
ObIndexBlockDataTransformer transformer;
|
||||
if (OB_FAIL(transformer.transform(read_info, micro_data, extra_buf, extra_size))) {
|
||||
LOG_WARN("Fail to transform index block data", K(ret));
|
||||
} else {
|
||||
micro_data.extra_buf_ = extra_buf;
|
||||
|
@ -222,25 +222,17 @@ int ObRootBlockInfo::transform_root_block_data(const ObTableReadInfo &read_info)
|
||||
if (ObMicroBlockData::INDEX_BLOCK == block_data_.type_
|
||||
&& OB_ISNULL(block_data_.get_extra_buf())
|
||||
&& OB_NOT_NULL(block_data_.get_buf())) {
|
||||
ObIndexBlockDataTransformer *transformer = nullptr;
|
||||
ObDecoderAllocator *allocator = nullptr;
|
||||
ObIndexBlockDataTransformer transformer;
|
||||
if (OB_UNLIKELY(!read_info.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid read_info", K(ret));
|
||||
} else if (OB_ISNULL(allocator = get_decoder_allocator())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to allocate decoder allocator", K(ret));
|
||||
} else if (OB_ISNULL(transformer = GET_TSI_MULT(ObIndexBlockDataTransformer, 1))) {
|
||||
// There must be get_decoder_allocator before GET_TSI_MULT(ObIndexBlockDataTransformer)
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to allocate transformer", K(ret));
|
||||
} else {
|
||||
char *extra_buf = nullptr;
|
||||
int64_t extra_size = ObIndexBlockDataTransformer::get_transformed_block_mem_size(block_data_);
|
||||
if (OB_ISNULL(extra_buf = static_cast<char *>(block_data_allocator_->alloc(extra_size)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("Allocate root block memory format failed", K(ret), K(extra_size));
|
||||
} else if (OB_FAIL(transformer->transform(read_info, block_data_, extra_buf, extra_size))) {
|
||||
} else if (OB_FAIL(transformer.transform(read_info, block_data_, extra_buf, extra_size))) {
|
||||
LOG_WARN("Fail to transform root block to memory format", K(ret), K(read_info),
|
||||
K(block_data_), KP(extra_buf), K(extra_size));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user