[SCN] modify with review comments
This commit is contained in:
@ -133,18 +133,24 @@ int ObConflictRowMapCtx::destroy()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObConflictRowMapCtx::init_conflict_map(int64_t replace_row_cnt, int64_t rowkey_cnt)
|
||||
int ObConflictRowMapCtx::init_conflict_map(int64_t replace_row_cnt, int64_t rowkey_cnt, common::ObIAllocator *allocator)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (!conflict_map_.created()) {
|
||||
if (OB_ISNULL(allocator)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Allocator used to init conflict map is null", K(ret));
|
||||
} else {
|
||||
allocator_ = allocator;
|
||||
}
|
||||
if (OB_SUCC(ret) && !conflict_map_.created()) {
|
||||
ObObj *objs = NULL;
|
||||
int64_t bucket_num = 0;
|
||||
bucket_num = replace_row_cnt < MAX_ROW_BATCH_SIZE ? replace_row_cnt : MAX_ROW_BATCH_SIZE;
|
||||
// map 没创建的场景下才需要创建, 这里可能被重复调用
|
||||
if (NULL == (rowkey_ = static_cast<ObRowkey*>(allocator_.alloc(sizeof(ObRowkey))))) {
|
||||
if (NULL == (rowkey_ = static_cast<ObRowkey*>(allocator_->alloc(sizeof(ObRowkey))))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to alloc memory", K(ret));
|
||||
} else if (NULL == (objs = static_cast<ObObj*>(allocator_.alloc(sizeof(ObObj)* rowkey_cnt)))){
|
||||
} else if (NULL == (objs = static_cast<ObObj*>(allocator_->alloc(sizeof(ObObj)* rowkey_cnt)))){
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("fail to alloc memory", K(ret));
|
||||
} else if (OB_FAIL(conflict_map_.create(bucket_num, ObModIds::OB_HASH_BUCKET))) {
|
||||
@ -178,7 +184,7 @@ int ObConflictChecker::create_conflict_map(int64_t replace_row_cnt)
|
||||
ObRowkeyCstCtdef *rowkey_cst_ctdef = checker_ctdef_.cst_ctdefs_.at(i);
|
||||
int64_t rowkey_cnt = rowkey_cst_ctdef->rowkey_expr_.count();
|
||||
// 在init_conflict_map 函数内保证了map不会被重复created
|
||||
if (OB_FAIL(conflict_map_array_.at(i).init_conflict_map(replace_row_cnt, rowkey_cnt))) {
|
||||
if (OB_FAIL(conflict_map_array_.at(i).init_conflict_map(replace_row_cnt, rowkey_cnt, &allocator_))) {
|
||||
LOG_WARN("fail to init conflict_map", K(ret), K(rowkey_cnt));
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,12 +74,12 @@ public:
|
||||
ObConflictRowMapCtx()
|
||||
: conflict_map_(),
|
||||
rowkey_(NULL),
|
||||
allocator_(CURRENT_CONTEXT->get_arena_allocator())
|
||||
allocator_(nullptr)
|
||||
{
|
||||
}
|
||||
~ObConflictRowMapCtx() {};
|
||||
|
||||
int init_conflict_map(int64_t bucket_num, int64_t obj_cnt);
|
||||
int init_conflict_map(int64_t bucket_num, int64_t obj_cnt, common::ObIAllocator *allocator);
|
||||
int reuse();
|
||||
int destroy();
|
||||
|
||||
@ -87,7 +87,7 @@ public:
|
||||
static const int64_t MAX_ROW_BATCH_SIZE = 500;
|
||||
ObConflictRowMap conflict_map_;
|
||||
ObRowkey *rowkey_; // 临时的ObRowkey,用于map的compare,循环使用
|
||||
common::ObIAllocator &allocator_; // allocator用来创建hash map
|
||||
common::ObIAllocator *allocator_; // allocator用来创建hash map
|
||||
};
|
||||
|
||||
typedef common::ObFixedArray<ObRowkeyCstCtdef *, common::ObIAllocator> ObRowkeyCstCtdefArray;
|
||||
|
||||
@ -294,6 +294,7 @@ int ObExprCast::calc_result_type2(ObExprResType &type,
|
||||
ObRawExpr *cast_raw_expr = NULL;
|
||||
const sql::ObSQLSessionInfo *session = NULL;
|
||||
bool is_explicit_cast = false;
|
||||
bool is_to_column_cs_level = false;
|
||||
if (OB_ISNULL(session = type_ctx.get_session()) ||
|
||||
OB_ISNULL(cast_raw_expr = get_raw_expr())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -310,6 +311,7 @@ int ObExprCast::calc_result_type2(ObExprResType &type,
|
||||
"dst", ob_obj_type_str(dst_type.get_type()));
|
||||
} else if (FALSE_IT(is_explicit_cast = CM_IS_EXPLICIT_CAST(cast_raw_expr->get_extra()))) {
|
||||
// check cast supported in cast_map but not support here.
|
||||
} else if (FALSE_IT(is_to_column_cs_level = CM_IS_TO_COLUMN_CS_LEVEL(cast_raw_expr->get_extra()))) {
|
||||
} else if (!check_cast_allowed(type1.get_type(), type1.get_collation_type(),
|
||||
dst_type.get_type(), dst_type.get_collation_type(),
|
||||
is_explicit_cast)) {
|
||||
@ -355,7 +357,7 @@ int ObExprCast::calc_result_type2(ObExprResType &type,
|
||||
type1.set_calc_type(get_calc_cast_type(type1.get_type(), dst_type.get_type()));
|
||||
int32_t length = 0;
|
||||
if (ob_is_string_or_lob_type(dst_type.get_type()) || ob_is_raw(dst_type.get_type()) || ob_is_json(dst_type.get_type())) {
|
||||
type.set_collation_level(is_explicit_cast
|
||||
type.set_collation_level((is_explicit_cast || is_to_column_cs_level)
|
||||
? CS_LEVEL_IMPLICIT
|
||||
: type1.get_collation_level());
|
||||
int32_t len = dst_type.get_length();
|
||||
|
||||
Reference in New Issue
Block a user