int ObPermInfoKey::build_get_param(ObGetParam & get_param) { int ret = OB_SUCCESS; ObCellInfo cell_info; ObRowkey rowkey; ObObj rowkey_obj; ObVersionRange ver_range; int64_t pos = 0; if (NULL == buffer_) { buffer_ = reinterpret_cast<char*>(ob_malloc(BUF_SIZE, ObModIds::OB_PERM_INFO)); } if (NULL != buffer_) { int64_t encode_pos = pos; ret = serialization::encode_i64(buffer_, BUF_SIZE, encode_pos, table_id_); if (OB_SUCCESS != ret) { TBSYS_LOG(ERROR, "encode failed table_id=%ld", table_id_); } else { memcpy(buffer_ + encode_pos, user_name_, length_); encode_pos += length_; rowkey_obj.set_varchar( ObString(0, static_cast<int32_t>(encode_pos - pos), buffer_ + pos)); rowkey.assign(&rowkey_obj, 1); get_param.set_is_result_cached(true); cell_info.table_id_ = PERM_TABLE_ID; cell_info.row_key_ = rowkey; cell_info.column_id_ = PERM_COL_ID; ret = get_param.add_cell(cell_info); if (OB_SUCCESS != ret) { TBSYS_LOG(ERROR, "Get param add cell failed table_id[%lu]", cell_info.table_id_); } else { ver_range.start_version_ = 0; ver_range.end_version_ = INT64_MAX - 1; ver_range.border_flag_.set_inclusive_start(); ver_range.border_flag_.set_inclusive_end(); get_param.set_version_range(ver_range); } } } else { TBSYS_LOG(ERROR, "malloc key buffer failed"); ret = OB_ERROR; } return ret; }
int ObSKeyInfoKey::build_get_param(ObGetParam& get_param) { int ret = OB_SUCCESS; ObCellInfo cell_info; ObRowkey rowkey; ObObj rowkey_obj; ObVersionRange ver_range; int64_t pos = 0; if (NULL == buffer_) { buffer_ = reinterpret_cast<char*>(ob_malloc(BUF_SIZE, ObModIds::OB_SKEY_INFO_KEY)); } ret = serialization::encode_i64(buffer_, BUF_SIZE, pos, skey_version_); if (OB_SUCCESS != ret) { TBSYS_LOG(ERROR, "encode failed pkey_version=%ld", skey_version_); } else { rowkey_obj.set_varchar(ObString(0, static_cast<int32_t>(pos), buffer_)); rowkey.assign(&rowkey_obj, 1); get_param.reset(); get_param.set_is_result_cached(true); cell_info.table_id_ = SKEY_TABLE_ID; cell_info.row_key_ = rowkey; cell_info.column_id_ = SKEY_COL_ID; ret = get_param.add_cell(cell_info); if (OB_SUCCESS != ret) { TBSYS_LOG(ERROR, "Get param add cell failed table_id[%lu]", cell_info.table_id_); } else { ver_range.start_version_ = 0; ver_range.end_version_ = INT64_MAX - 1; ver_range.border_flag_.set_inclusive_start(); ver_range.border_flag_.set_inclusive_end(); get_param.set_version_range(ver_range); } } return ret; }
int ObMergerPrefetchData::modify_prefetch_param(ObGetParam & param) { ObVersionRange range; int ret = version_.get_version(range.end_version_.version_); if ((ret != OB_SUCCESS) || (range.end_version_ <= 0)) { TBSYS_LOG(WARN, "get last version failed:version[%ld], ret[%d]", (int64_t)range.end_version_, ret); } else { cur_version_ = range.end_version_; range.border_flag_.set_min_value(); range.border_flag_.set_inclusive_end(); // maybe not need someday param.set_is_result_cached(true); param.set_is_read_consistency(true); param.set_version_range(range); } return ret; }
int ObUserInfoKey:: build_get_param(ObGetParam& get_param) { int ret = OB_SUCCESS; ObCellInfo cell_info; ObString rowkey; ObVersionRange ver_range; if (NULL == buffer_) { buffer_ = reinterpret_cast<char*>(ob_malloc(BUF_SIZE)); } if (NULL != buffer_) { memcpy(buffer_, user_name_, length_); rowkey.assign(buffer_, static_cast<int32_t>(length_)); get_param.set_is_result_cached(true); cell_info.table_id_ = USER_TABLE_ID; cell_info.row_key_ = rowkey; cell_info.column_id_ = USER_COL_ID; ret = get_param.add_cell(cell_info); if (OB_SUCCESS != ret) { TBSYS_LOG(ERROR, "Get param add cell failed table_id[%lu]", cell_info.table_id_); } else { ver_range.start_version_ = 0; ver_range.end_version_ = INT64_MAX - 1; ver_range.border_flag_.set_inclusive_start(); ver_range.border_flag_.set_inclusive_end(); get_param.set_version_range(ver_range); } } else { TBSYS_LOG(ERROR, "malloc key buffer failed"); ret = OB_ERROR; } return ret; }
int MutatorBuilder::build_get_param(ObGetParam &get_param, PageArena<char> &allocer, const int64_t table_start_version, const bool using_id, const int64_t row_num, const int64_t cell_num_per_row) { int ret = OB_SUCCESS; get_param.reset(); UNUSED(table_start_version); static int64_t row_info_array[OB_MAX_TABLE_NUMBER]; static int64_t suffix_num_array[OB_MAX_TABLE_NUMBER]; static int64_t counter = 0; static const int64_t ROW_INFO_CACHE_FLUSH_PERIOD = 100; //static const int64_t ROW_INFO_CACHE_FLUSH_PERIOD = 1000000000; if (0 == (counter++ % ROW_INFO_CACHE_FLUSH_PERIOD)) { memset(row_info_array, 0, sizeof(row_info_array)); memset(suffix_num_array, 0, sizeof(suffix_num_array)); } for (int64_t i = 0; i < row_num; i++) { int64_t rand = 0; lrand48_r(&table_rand_seed_, &rand); int64_t table_pos = range_rand(0, table_num_ - 1, rand); const ObSchema &cur_schema = schema_mgr_.begin()[table_pos]; if (0 == row_info_array[table_pos] && 0 == (row_info_array[table_pos] = get_cur_rowkey_info_(cur_schema, using_id, rb_array_[table_pos]->get_prefix_start()))) { assert(OB_SUCCESS == ret); ret = OB_ERROR; break; } if (0 == suffix_num_array[table_pos] && 0 == (suffix_num_array[table_pos] = get_suffix_num_(cur_schema, using_id, rb_array_[table_pos]->get_prefix_start()))) { assert(OB_SUCCESS == ret); ret = OB_ERROR; break; } ObCellInfo ci; ci.row_key_ = rb_array_[table_pos]->get_random_rowkey(row_info_array[table_pos], suffix_num_array[table_pos], allocer); if (using_id) { ci.table_id_ = cur_schema.get_table_id(); } else { ci.table_name_.assign_ptr(const_cast<char*>(cur_schema.get_table_name()), static_cast<int32_t>(strlen(cur_schema.get_table_name()))); } if (using_id) { ci.column_id_ = SEED_COLUMN_ID; ci.column_name_.assign_ptr(NULL, 0); } else { ci.column_id_ = OB_INVALID_ID; ci.column_name_.assign_ptr((char*)SEED_COLUMN_NAME, static_cast<int32_t>(strlen(SEED_COLUMN_NAME))); } get_param.add_cell(ci); if (using_id) { ci.column_id_ = CELL_NUM_COLUMN_ID; ci.column_name_.assign_ptr(NULL, 0); } else { ci.column_id_ = OB_INVALID_ID; ci.column_name_.assign_ptr((char*)CELL_NUM_COLUMN_NAME, static_cast<int32_t>(strlen(CELL_NUM_COLUMN_NAME))); } get_param.add_cell(ci); lrand48_r(&table_rand_seed_, &rand); int64_t cell_num = range_rand(1, cell_num_per_row, rand); int64_t column_num = cur_schema.column_end() - cur_schema.column_begin(); for (int64_t j = 0; j < cell_num; j++) { lrand48_r(&table_rand_seed_, &rand); int64_t column_pos = range_rand(0, column_num - 1, rand); //int64_t column_pos = 0; const ObColumnSchema &column_schema = cur_schema.column_begin()[column_pos]; if (using_id) { ci.column_id_ = column_schema.get_id(); ci.column_name_.assign_ptr(NULL, 0); } else { ci.column_id_ = OB_INVALID_ID; ci.column_name_.assign_ptr(const_cast<char*>(column_schema.get_name()), static_cast<int32_t>(strlen(column_schema.get_name()))); } get_param.add_cell(ci); } } ObVersionRange version_range; version_range.start_version_ = table_start_version_; version_range.border_flag_.set_max_value(); version_range.border_flag_.set_inclusive_start(); get_param.set_version_range(version_range); char* is_read_consistency_cfg = getenv("is_read_consistency"); bool is_read_consistency = (NULL != is_read_consistency_cfg && 0 == strcmp(is_read_consistency_cfg, "true")); get_param.set_is_read_consistency(is_read_consistency); assert(get_param.get_cell_size() > 0); return ret; }