Merge branch 'column_store'
Co-authored-by: wangt1xiuyi <13547954130@163.com> Co-authored-by: yangqise7en <877793735@qq.com> Co-authored-by: Zach41 <zach_41@163.com>
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#include "storage/ob_storage_struct.h"
|
||||
#include "storage/ob_relative_table.h"
|
||||
#include "storage/ob_storage_schema.h"
|
||||
#include "ob_store_row_iterator.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -36,6 +37,7 @@ ObRowsInfo::ExistHelper::~ExistHelper()
|
||||
int ObRowsInfo::ExistHelper::init(const ObRelativeTable &table,
|
||||
ObStoreCtx &store_ctx,
|
||||
const ObITableReadInfo &rowkey_read_info,
|
||||
ObStorageReserveAllocator &stmt_allocator,
|
||||
ObStorageReserveAllocator &allocator)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -49,13 +51,16 @@ int ObRowsInfo::ExistHelper::init(const ObRelativeTable &table,
|
||||
common::ObVersionRange trans_version_range;
|
||||
query_flag.read_latest_ = ObQueryFlag::OBSF_MASK_READ_LATEST;
|
||||
query_flag.use_row_cache_ = ObQueryFlag::DoNotUseCache;
|
||||
if (table.is_storage_index_table()) {
|
||||
query_flag.index_invalid_ = !table.can_read_index();
|
||||
}
|
||||
|
||||
trans_version_range.snapshot_version_ = EXIST_READ_SNAPSHOT_VERSION;
|
||||
trans_version_range.base_version_ = 0;
|
||||
trans_version_range.multi_version_start_ = 0;
|
||||
|
||||
if (OB_FAIL(table_access_context_.init(query_flag, store_ctx, allocator,
|
||||
trans_version_range))) {
|
||||
if (OB_FAIL(table_access_context_.init(query_flag, store_ctx, allocator, stmt_allocator,
|
||||
trans_version_range, true /*+ for_exist */))) {
|
||||
STORAGE_LOG(WARN, "failed to init table access ctx", K(ret));
|
||||
} else {
|
||||
table_iter_param_.table_id_ = table.get_table_id();
|
||||
@ -69,17 +74,19 @@ int ObRowsInfo::ExistHelper::init(const ObRelativeTable &table,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
ObRowsInfo::ObRowsInfo()
|
||||
: scan_mem_allocator_(ObMemAttr(MTL_ID(), common::ObModIds::OB_STORE_ROW_EXISTER), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||
exist_allocator_(ObMemAttr(MTL_ID(), common::ObModIds::OB_STORE_ROW_EXISTER), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||
key_allocator_(ObMemAttr(MTL_ID(), common::ObModIds::OB_STORE_ROW_EXISTER), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||
rowkeys_(),
|
||||
permutation_(),
|
||||
rows_(nullptr),
|
||||
exist_helper_(),
|
||||
table_id_(OB_INVALID_ID),
|
||||
tablet_id_(),
|
||||
datum_utils_(nullptr),
|
||||
min_key_(),
|
||||
conflict_rowkey_idx_(-1),
|
||||
error_code_(0),
|
||||
delete_count_(0),
|
||||
rowkey_column_num_(0),
|
||||
is_inited_(false)
|
||||
@ -101,11 +108,10 @@ int ObRowsInfo::init(
|
||||
if (OB_UNLIKELY(is_inited_)) {
|
||||
ret = OB_INIT_TWICE;
|
||||
STORAGE_LOG(WARN, "ObRowsinfo init twice", K(ret));
|
||||
} else if (OB_FAIL(exist_helper_.init(table, store_ctx, rowkey_read_info, scan_mem_allocator_))) {
|
||||
} else if (OB_FAIL(exist_helper_.init(table, store_ctx, rowkey_read_info, exist_allocator_, scan_mem_allocator_))) {
|
||||
STORAGE_LOG(WARN, "Failed to init exist helper", K(ret));
|
||||
} else {
|
||||
datum_utils_ = &rowkey_read_info.get_datum_utils();
|
||||
table_id_ = table.get_table_id();
|
||||
tablet_id_ = table.get_tablet_id();
|
||||
rowkey_column_num_ = table.get_rowkey_column_num();
|
||||
is_inited_ = true;
|
||||
@ -118,6 +124,8 @@ void ObRowsInfo::reuse()
|
||||
min_key_.set_max_rowkey();
|
||||
rows_ = nullptr;
|
||||
delete_count_ = 0;
|
||||
error_code_ = 0;
|
||||
conflict_rowkey_idx_ = -1;
|
||||
scan_mem_allocator_.reuse();
|
||||
rowkeys_.reuse();
|
||||
key_allocator_.reuse();
|
||||
@ -143,17 +151,25 @@ int ObRowsInfo::check_duplicate(ObStoreRow *rows, const int64_t row_count, ObRel
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(rowkeys_.reserve(row_count))) {
|
||||
STORAGE_LOG(WARN, "Failed to reserve rowkeys", K(ret), K(row_count));
|
||||
} else if (OB_FAIL(permutation_.prepare_allocate(row_count))) {
|
||||
STORAGE_LOG(WARN, "Failed to prepare allocate permutation", K(ret), K(row_count));
|
||||
}
|
||||
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < row_count; i++) {
|
||||
if (OB_UNLIKELY(!rows[i].is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
STORAGE_LOG(WARN, "invalid argument", K(rows_[i]), K(ret));
|
||||
} else {
|
||||
ObDatumRowkey datum_rowkey;
|
||||
ObMarkedRowkeyAndLockState marked_rowkey_and_lock_state;
|
||||
marked_rowkey_and_lock_state.row_idx_ = i;
|
||||
ObRowkey rowkey(rows_[i].row_val_.cells_, rowkey_column_num_);
|
||||
if (OB_FAIL(datum_rowkey.from_rowkey(rowkey, key_allocator_))) {
|
||||
if (OB_FAIL(marked_rowkey_and_lock_state.marked_rowkey_.get_rowkey().from_rowkey(rowkey,
|
||||
key_allocator_))) {
|
||||
STORAGE_LOG(WARN, "Failed to transfer rowkey", K(ret), K(rowkey));
|
||||
} else if (OB_FAIL(rowkeys_.push_back(datum_rowkey))) {
|
||||
STORAGE_LOG(WARN, "Failed to push back datum rowkey", K(ret), K(datum_rowkey));
|
||||
} else if (OB_FAIL(rowkeys_.push_back(marked_rowkey_and_lock_state))) {
|
||||
STORAGE_LOG(WARN, "Failed to push back rowkey", K(ret), K(marked_rowkey_and_lock_state));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,10 +178,10 @@ int ObRowsInfo::check_duplicate(ObStoreRow *rows, const int64_t row_count, ObRel
|
||||
RowsCompare rows_cmp(*datum_utils_, min_key_, true, ret);
|
||||
std::sort(rowkeys_.begin(), rowkeys_.end(), rows_cmp);
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
min_key_ = rowkeys_.at(0);
|
||||
STORAGE_LOG(DEBUG, "Duplicate check complete", K(ret), K(row_count), K_(rowkey_column_num));
|
||||
for (int64_t i = 0; i < row_count; i++) {
|
||||
permutation_[rowkeys_[i].row_idx_] = i;
|
||||
}
|
||||
min_key_ = rowkeys_.at(0).marked_rowkey_.get_rowkey();
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,56 +212,33 @@ int ObRowsInfo::check_min_rowkey_boundary(const blocksstable::ObDatumRowkey &max
|
||||
int ObRowsInfo::refine_rowkeys()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
if (!is_valid()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "Unexpected not init rowsinfo", K_(delete_count), KP_(rows), K(ret));
|
||||
} else if (rowkeys_.count() == delete_count_ || rowkeys_.empty()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "Unexpected rowkey status", K(ret), K_(delete_count), K_(rowkeys));
|
||||
} else if (delete_count_ > 0) {
|
||||
if (rowkeys_.count() > 1) {
|
||||
RowsCompare rows_cmp(*datum_utils_, min_key_, false, ret);
|
||||
std::sort(rowkeys_.begin(), rowkeys_.end(), rows_cmp);
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
while (rowkeys_.count() > 0 ){
|
||||
if (rowkeys_.at(rowkeys_.count() - 1).is_max_rowkey()) {
|
||||
rowkeys_.pop_back();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete_count_ = 0;
|
||||
min_key_ = rowkeys_.at(0);
|
||||
STORAGE_LOG(DEBUG, "Duplicate check complete", K(ret), K_(rowkeys), K_(rowkey_column_num));
|
||||
} else {
|
||||
STORAGE_LOG(WARN, "Unexpected duplicate rowkeys", K_(rowkeys), K(ret));
|
||||
} else if (OB_FAIL(exist_helper_.table_access_context_.alloc_iter_pool(false))) {
|
||||
STORAGE_LOG(WARN, "Failed to alloc exist iter pool", K(ret));
|
||||
} else {
|
||||
for (int64_t i = 0; i < rowkeys_.count(); ++i) {
|
||||
rowkeys_[i].marked_rowkey_.clear_row_non_existent();
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObRowsInfo::clear_found_rowkey(const int64_t rowkey_idx)
|
||||
void ObRowsInfo::return_exist_iter(ObStoreRowIterator *exist_iter)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
if (!is_valid()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "Unexpected not init rowsinfo", K_(delete_count), KP_(rows), K(ret));
|
||||
} else if (rowkey_idx < 0 || rowkey_idx >= rowkeys_.count()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
STORAGE_LOG(WARN, "Invalid argument to clear found rowkey", K(rowkey_idx), K_(rowkeys), K(ret));
|
||||
} else if (rowkeys_.at(rowkey_idx).is_max_rowkey()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "Clear found rowkey twice", K(rowkey_idx), K(ret));
|
||||
} else {
|
||||
rowkeys_.at(rowkey_idx).set_max_rowkey();
|
||||
delete_count_++;
|
||||
STORAGE_LOG(ERROR, "Unexpected not init rowsinfo", K_(delete_count), KP_(rows), K(ret));
|
||||
} else if (OB_LIKELY(nullptr != exist_iter)) {
|
||||
if (exist_helper_.table_access_context_.iter_pool_ != nullptr) {
|
||||
exist_helper_.table_access_context_.iter_pool_->return_iter(exist_iter);
|
||||
} else {
|
||||
exist_iter->~ObStoreRowIterator();
|
||||
exist_helper_.table_access_context_.stmt_allocator_->free(exist_iter);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace storage
|
||||
|
||||
Reference in New Issue
Block a user