patch 4.0
This commit is contained in:
@ -1,59 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "ob_fake_partition_location_cache.h"
|
||||
using namespace oceanbase::common;
|
||||
namespace oceanbase {
|
||||
namespace share {
|
||||
|
||||
ObFakePartitionLocationCache::ObFakePartitionLocationCache()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_SUCCESS != (ret = partition_loc_map_.create(10000, ObModIds::OB_SQL_EXECUTOR))) {
|
||||
SQL_ENG_LOG(WARN, "fail to create location map", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
ObFakePartitionLocationCache::~ObFakePartitionLocationCache()
|
||||
{}
|
||||
|
||||
int ObFakePartitionLocationCache::get(const uint64_t table_id, const int64_t partition_id,
|
||||
ObPartitionLocation& location, const int64_t expire_renew_time, bool&)
|
||||
{
|
||||
UNUSED(expire_renew_time);
|
||||
int ret = OB_SUCCESS;
|
||||
ObFakePartitionKey key;
|
||||
key.table_id_ = table_id;
|
||||
key.partition_id_ = partition_id;
|
||||
if (hash::HASH_EXIST == (ret = partition_loc_map_.get(key, location))) {
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObFakePartitionLocationCache::add_location(ObFakePartitionKey key, ObPartitionLocation location)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
location.set_table_id(key.table_id_);
|
||||
location.set_partition_id(key.partition_id_);
|
||||
if (location.get_partition_cnt() <= key.partition_id_) {
|
||||
location.set_partition_cnt(key.partition_id_ + 1);
|
||||
}
|
||||
location.is_valid();
|
||||
if (hash::HASH_INSERT_SUCC == (ret = partition_loc_map_.set(key, location))) {
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace share
|
||||
} // namespace oceanbase
|
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_FAKE_PARTITION_LOCATION_CACHE_
|
||||
#define OCEANBASE_FAKE_PARTITION_LOCATION_CACHE_
|
||||
|
||||
#include "share/partition_table/ob_partition_location_cache.h"
|
||||
#include "lib/hash/ob_hashmap.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace share {
|
||||
|
||||
class ObFakePartitionKey {
|
||||
public:
|
||||
uint64_t table_id_;
|
||||
int64_t partition_id_;
|
||||
inline int64_t hash() const
|
||||
{
|
||||
return table_id_ + partition_id_;
|
||||
}
|
||||
inline bool operator==(const ObFakePartitionKey& other) const
|
||||
{
|
||||
return table_id_ == other.table_id_ && partition_id_ == other.partition_id_;
|
||||
}
|
||||
};
|
||||
|
||||
class ObFakePartitionLocationCache : public ObPartitionLocationCache {
|
||||
public:
|
||||
ObFakePartitionLocationCache();
|
||||
virtual ~ObFakePartitionLocationCache();
|
||||
|
||||
// get partition location of a partition
|
||||
virtual int get(const uint64_t table_id, const int64_t partition_id, ObPartitionLocation& location,
|
||||
const int64_t expire_renew_time, bool&);
|
||||
|
||||
int add_location(ObFakePartitionKey key, ObPartitionLocation location);
|
||||
|
||||
private:
|
||||
common::hash::ObHashMap<ObFakePartitionKey, ObPartitionLocation> partition_loc_map_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObFakePartitionLocationCache);
|
||||
};
|
||||
} // namespace share
|
||||
} // namespace oceanbase
|
||||
#endif /* OCEANBASE_FAKE_PARTITION_LOCATION_CACHE_ */
|
@ -1,513 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "ob_fake_partition_service.h"
|
||||
#include "storage/transaction/ob_trans_service.h"
|
||||
#include "clog/ob_clog_mgr.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
namespace oceanbase {
|
||||
|
||||
namespace sql {
|
||||
int ObFakeTableScanIterator::get_next_row(common::ObNewRow*& row)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
common::ObNewRow* cur_row = OB_NEW(ObNewRow, ObModIds::TEST);
|
||||
ObObj* objs = (ObObj*)ob_malloc(sizeof(ObObj) * col_num_, ObModIds::TEST);
|
||||
if (!cur_row || !objs) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
SQL_ENG_LOG(WARN, "no memory");
|
||||
if (cur_row) {
|
||||
OB_DELETE(ObNewRow, ObModIds::TEST, cur_row);
|
||||
}
|
||||
if (objs) {
|
||||
ob_free(objs);
|
||||
}
|
||||
} else {
|
||||
for (int64_t i = 0; i < col_num_; ++i) {
|
||||
new (objs + i) ObObj();
|
||||
}
|
||||
cur_row->count_ = col_num_;
|
||||
cur_row->cells_ = objs;
|
||||
if (OB_SUCCESS != (ret = row_store_it_.get_next_row(*cur_row))) {
|
||||
if (OB_ITER_END != ret) {
|
||||
SQL_ENG_LOG(WARN, "fail to get next row", K(ret));
|
||||
}
|
||||
} else {
|
||||
row = cur_row;
|
||||
}
|
||||
}
|
||||
if (NULL == cur_row->cells_) {
|
||||
SQL_ENG_LOG(WARN, "cur_row->cells_ is NULL");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace sql
|
||||
|
||||
namespace storage {
|
||||
|
||||
ObFakePartitionService::ObFakePartitionService()
|
||||
{}
|
||||
|
||||
ObFakePartitionService::~ObFakePartitionService()
|
||||
{}
|
||||
|
||||
int ObFakePartitionService::table_scan(ObTableScanParam& param, ObNewRowIterator*& result)
|
||||
{
|
||||
ObFakeTableScanIterator* iter = OB_NEW(ObFakeTableScanIterator, ObModIds::TEST);
|
||||
iter->init(scanner_.begin(), col_num_);
|
||||
result = static_cast<ObNewRowIterator*>(iter);
|
||||
SQL_ENG_LOG(INFO, "table scan", K(param));
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::revert_scan_iter(ObNewRowIterator* iter)
|
||||
{
|
||||
OB_DELETE(ObNewRowIterator, ObModIds::TEST, iter);
|
||||
SQL_ENG_LOG(INFO, "revert_scan_iter");
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
bool ObFakePartitionService::is_empty() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::init(const blocksstable::ObStorageEnv& env, const common::ObAddr& self_addr,
|
||||
ObIPartitionComponentFactory* cp_fty, share::schema::ObMultiVersionSchemaService* schema_service,
|
||||
share::ObIPartitionLocationCache* location_cache, common::ObIRSCb* rs_cb, rpc::frame::ObReqTransport* req_transport)
|
||||
{
|
||||
UNUSED(env);
|
||||
UNUSED(self_addr);
|
||||
UNUSED(cp_fty);
|
||||
UNUSED(schema_service);
|
||||
UNUSED(location_cache);
|
||||
UNUSED(rs_cb);
|
||||
UNUSED(req_transport);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::start()
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::destroy()
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
void ObFakePartitionService::set_component_service(ObIPartitionComponentFactory& cp_fty)
|
||||
{
|
||||
UNUSED(cp_fty);
|
||||
}
|
||||
|
||||
int ObFakePartitionService::load_partition(const char* buf, const int64_t buf_len, int64_t& pos)
|
||||
{
|
||||
UNUSED(buf);
|
||||
UNUSED(buf_len);
|
||||
UNUSED(pos);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::replay_base_storage_log(
|
||||
const int64_t log_seq_num, const int64_t subcmd, const char* buf, const int64_t len, int64_t& pos)
|
||||
{
|
||||
UNUSED(log_seq_num);
|
||||
UNUSED(subcmd);
|
||||
UNUSED(buf);
|
||||
UNUSED(len);
|
||||
UNUSED(pos);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::create_partition(const ObPartitionKey& key, const common::ObVersion data_version,
|
||||
const int64_t replica_num, const common::ObMemberList& mem_list)
|
||||
{
|
||||
UNUSED(key);
|
||||
UNUSED(data_version);
|
||||
UNUSED(replica_num);
|
||||
UNUSED(mem_list);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::online_partition()
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::offline_partition(const common::ObPartitionKey& leader_key, const common::ObAddr& server)
|
||||
{
|
||||
UNUSED(leader_key);
|
||||
UNUSED(server);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::remove_partition(const common::ObPartitionKey& key)
|
||||
{
|
||||
UNUSED(key);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::remove_orphans()
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::freeze()
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::on_leader_revoke(const common::ObPartitionKey& partition_key)
|
||||
{
|
||||
UNUSED(partition_key);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::on_leader_takeover(const common::ObPartitionKey& partition_key)
|
||||
{
|
||||
UNUSED(partition_key);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int64_t ObFakePartitionService::get_min_using_file_id() const
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
ObBaseStorage* ObFakePartitionService::get_base_storage()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
share::schema::ObMultiVersionSchemaService* ObFakePartitionService::get_schema_service()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ObIPartitionComponentFactory* ObFakePartitionService::get_cp_fty()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// transaction service interfaces
|
||||
int ObFakePartitionService::start_trans(
|
||||
const uint64_t tenant_id, const transaction::ObStartTransParam& req, transaction::ObTransDesc& trans_desc)
|
||||
{
|
||||
UNUSED(tenant_id);
|
||||
UNUSED(req);
|
||||
UNUSED(trans_desc);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::end_trans(bool is_rollback, const transaction::ObTransDesc& trans_desc)
|
||||
{
|
||||
UNUSED(is_rollback);
|
||||
UNUSED(trans_desc);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::start_stmt(
|
||||
const uint64_t tenant_id, transaction::ObTransDesc& trans_desc, const common::ObPartitionArray& participants)
|
||||
{
|
||||
UNUSED(tenant_id);
|
||||
UNUSED(trans_desc);
|
||||
UNUSED(participants);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::end_stmt(bool is_rollback, const transaction::ObTransDesc& trans_desc)
|
||||
{
|
||||
UNUSED(is_rollback);
|
||||
UNUSED(trans_desc);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// partition storage interfaces
|
||||
#if 0
|
||||
int ObFakePartitionService::table_scan(ObTableScanParam ¶m,
|
||||
common::ObNewRowIterator *&result)
|
||||
{
|
||||
UNUSED(param);
|
||||
UNUSED(result);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::revert_scan_iter(common::ObNewRowIterator *iter)
|
||||
{
|
||||
UNUSED(iter);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
int ObFakePartitionService::delete_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, const common::ObIArray<uint64_t>& column_ids,
|
||||
common::ObNewRowIterator* row_iter, int64_t& affected_rows)
|
||||
{
|
||||
UNUSED(trans_desc);
|
||||
UNUSED(timeout);
|
||||
UNUSED(pkey);
|
||||
UNUSED(column_ids);
|
||||
UNUSED(row_iter);
|
||||
UNUSED(affected_rows);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::insert_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, const common::ObIArray<uint64_t>& column_ids,
|
||||
common::ObNewRowIterator* row_iter, int64_t& affected_rows)
|
||||
{
|
||||
UNUSED(trans_desc);
|
||||
UNUSED(timeout);
|
||||
UNUSED(pkey);
|
||||
UNUSED(column_ids);
|
||||
UNUSED(row_iter);
|
||||
UNUSED(affected_rows);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::update_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, const common::ObIArray<uint64_t>& column_ids,
|
||||
const common::ObIArray<uint64_t>& updated_column_ids, common::ObNewRowIterator* row_iter, int64_t& affected_rows)
|
||||
{
|
||||
UNUSED(trans_desc);
|
||||
UNUSED(timeout);
|
||||
UNUSED(pkey);
|
||||
UNUSED(column_ids);
|
||||
UNUSED(updated_column_ids);
|
||||
UNUSED(row_iter);
|
||||
UNUSED(affected_rows);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::lock_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, common::ObNewRowIterator* row_iter, const ObLockFlag lock_flag,
|
||||
int64_t& affected_rows)
|
||||
{
|
||||
UNUSED(trans_desc);
|
||||
UNUSED(timeout);
|
||||
UNUSED(pkey);
|
||||
UNUSED(row_iter);
|
||||
UNUSED(lock_flag);
|
||||
UNUSED(affected_rows);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// partition manager interfaces
|
||||
int ObFakePartitionService::get_all_partitions(common::ObIArray<ObIPartition*>& partition_list)
|
||||
{
|
||||
UNUSED(partition_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::get_partition(const common::ObPartitionKey& pkey, ObIPartitionGroup*& partition)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(partition);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::get_partition_count(int64_t& partition_count) const
|
||||
{
|
||||
UNUSED(partition_count);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
void revert_replay_status(ObReplayStatus* replay_status)
|
||||
{
|
||||
UNUSED(replay_status);
|
||||
}
|
||||
|
||||
ObIPartitionIter* ObFakePartitionService::alloc_pg_iter()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObFakePartitionService::revert_pg_iter(ObIPartitionIter* iter)
|
||||
{
|
||||
UNUSED(iter);
|
||||
}
|
||||
ObPGPartitionIterator* ObFakePartitionService::alloc_pg_partition_iter()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObFakePartitionService::revert_pg_partition_iter(ObPGPartitionIterator* iter)
|
||||
{
|
||||
UNUSED(iter);
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// replay interfaces
|
||||
int ObFakePartitionService::replay_redo_log(
|
||||
const common::ObPartitionKey& pkey, const ObStoreCtx& ctx, const int64_t ts, const char* buf, const int64_t size)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(ctx);
|
||||
UNUSED(ts);
|
||||
UNUSED(buf);
|
||||
UNUSED(size);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
transaction::ObITransService* ObFakePartitionService::get_trans_service()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
clog::ObICLogMgr* ObFakePartitionService::get_clog_mgr()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// major freeze
|
||||
int ObFakePartitionService::set_major_freeze_cb(ObIMajorFreezeCb* cb)
|
||||
{
|
||||
UNUSED(cb);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::prepare_major_freeze(
|
||||
const obrpc::ObPartitionList& partitions, const int64_t frozen_version, const int64_t frozen_timestamp)
|
||||
{
|
||||
UNUSED(partitions);
|
||||
UNUSED(frozen_version);
|
||||
UNUSED(frozen_timestamp);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::commit_major_freeze(
|
||||
const obrpc::ObPartitionList& partitions, const int64_t frozen_version, const int64_t frozen_timestamp)
|
||||
{
|
||||
UNUSED(partitions);
|
||||
UNUSED(frozen_version);
|
||||
UNUSED(frozen_timestamp);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::abort_major_freeze(
|
||||
const obrpc::ObPartitionList& partitions, const int64_t frozen_version, const int64_t frozen_timestamp)
|
||||
{
|
||||
UNUSED(partitions);
|
||||
UNUSED(frozen_version);
|
||||
UNUSED(frozen_timestamp);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::set_major_freeze_status(
|
||||
const common::ObPartitionKey& pkey, const int64_t frozen_version, const int64_t major_freeze_status)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(frozen_version);
|
||||
UNUSED(major_freeze_status);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::get_major_freeze_status(
|
||||
const common::ObPartitionKey& pkey, int64_t& frozen_version, int64_t& major_freeze_status)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(frozen_version);
|
||||
UNUSED(major_freeze_status);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::replay(const ObPartitionKey& partition, const char* log, const int64_t size)
|
||||
{
|
||||
UNUSED(partition);
|
||||
UNUSED(log);
|
||||
UNUSED(size);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::finish_replay(const ObPartitionKey& partition)
|
||||
{
|
||||
UNUSED(partition);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::leader_freeze_success(const ObPartitionKey& pkey, const int64_t freeze_cmd)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(freeze_cmd);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::leader_freeze_fail(const ObPartitionKey& pkey, const int64_t freeze_cmd)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(freeze_cmd);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::follower_freeze_success(const ObPartitionKey& pkey, const int64_t freeze_cmd)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(freeze_cmd);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::follower_freeze_fail(const ObPartitionKey& pkey, const int64_t freeze_cmd)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(freeze_cmd);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::submit_freeze_log_success(const int64_t cmd_type, const ObPartitionKey& pkey)
|
||||
{
|
||||
UNUSED(cmd_type);
|
||||
UNUSED(pkey);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::get_role(const common::ObPartitionKey& pkey, common::ObRole& role) const
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(role);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::get_leader_curr_member_list(
|
||||
const common::ObPartitionKey& pkey, common::ObMemberList& member_list) const
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(member_list);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::on_member_change_success(const common::ObPartitionKey& partition_key,
|
||||
const int64_t mc_timestamp, const common::ObMemberList& prev_member_list,
|
||||
const common::ObMemberList& curr_member_list)
|
||||
{
|
||||
UNUSED(partition_key);
|
||||
UNUSED(mc_timestamp);
|
||||
UNUSED(prev_member_list);
|
||||
UNUSED(curr_member_list);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int ObFakePartitionService::get_active_memtable_version(const ObPartitionKey& pkey, int64_t& version)
|
||||
{
|
||||
UNUSED(pkey);
|
||||
UNUSED(version);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace storage
|
||||
} // namespace oceanbase
|
@ -1,195 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_UNITTEST_ENGINE_TABLE_OB_FAKE_PARTITION_SERVICE_
|
||||
#define OCEANBASE_UNITTEST_ENGINE_TABLE_OB_FAKE_PARTITION_SERVICE_
|
||||
|
||||
#include "storage/ob_partition_service.h"
|
||||
#include "share/ob_scanner.h"
|
||||
#include "common/row/ob_row.h"
|
||||
|
||||
namespace oceanbase {
|
||||
|
||||
namespace sql {
|
||||
class ObFakeTableScanIterator : public common::ObNewRowIterator {
|
||||
public:
|
||||
ObFakeTableScanIterator()
|
||||
{}
|
||||
virtual ~ObFakeTableScanIterator()
|
||||
{}
|
||||
|
||||
virtual int get_next_row(common::ObNewRow*& row);
|
||||
|
||||
inline virtual void reset()
|
||||
{
|
||||
row_store_it_.reset();
|
||||
}
|
||||
|
||||
inline void init(const common::ObRowStore::Iterator& iter, int64_t col_num)
|
||||
{
|
||||
row_store_it_ = iter;
|
||||
col_num_ = col_num;
|
||||
}
|
||||
|
||||
private:
|
||||
common::ObRowStore::Iterator row_store_it_;
|
||||
int64_t col_num_;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObFakeTableScanIterator);
|
||||
};
|
||||
} // namespace sql
|
||||
|
||||
namespace storage {
|
||||
class ObFakePartitionService : public ObPartitionService {
|
||||
public:
|
||||
ObFakePartitionService();
|
||||
virtual ~ObFakePartitionService();
|
||||
|
||||
//
|
||||
virtual int init(const blocksstable::ObStorageEnv& env, const common::ObAddr& self_addr,
|
||||
ObIPartitionComponentFactory* cp_fty, share::schema::ObMultiVersionSchemaService* schema_service,
|
||||
share::ObIPartitionLocationCache* location_cache, common::ObIRSCb* rs_cb,
|
||||
rpc::frame::ObReqTransport* req_transport);
|
||||
virtual int start();
|
||||
virtual int destroy();
|
||||
virtual void set_component_service(ObIPartitionComponentFactory& cp_fty);
|
||||
//
|
||||
virtual int load_partition(const char* buf, const int64_t buf_len, int64_t& pos);
|
||||
virtual int replay_base_storage_log(
|
||||
const int64_t log_seq_num, const int64_t subcmd, const char* buf, const int64_t len, int64_t& pos);
|
||||
virtual int create_partition(const common::ObPartitionKey& key, const common::ObVersion data_version,
|
||||
const int64_t replica_num, const common::ObMemberList& mem_list);
|
||||
virtual int online_partition();
|
||||
virtual int offline_partition(const common::ObPartitionKey& leader_key, const common::ObAddr& server);
|
||||
virtual int remove_partition(const common::ObPartitionKey& key);
|
||||
virtual int remove_orphans();
|
||||
virtual int freeze();
|
||||
virtual int on_leader_revoke(const common::ObPartitionKey& partition_key);
|
||||
virtual int on_leader_takeover(const common::ObPartitionKey& partition_key);
|
||||
virtual int64_t get_min_using_file_id() const;
|
||||
virtual ObBaseStorage* get_base_storage();
|
||||
virtual share::schema::ObMultiVersionSchemaService* get_schema_service();
|
||||
virtual ObIPartitionComponentFactory* get_cp_fty();
|
||||
virtual int on_member_change_success(const common::ObPartitionKey& partition_key, const int64_t mc_timestamp,
|
||||
const common::ObMemberList& prev_member_list, const common::ObMemberList& curr_member_list);
|
||||
|
||||
// ==========================================================================
|
||||
// transaction service interfaces
|
||||
virtual int start_trans(
|
||||
const uint64_t tenant_id, const transaction::ObStartTransParam& req, transaction::ObTransDesc& trans_desc);
|
||||
virtual int end_trans(bool is_rollback, const transaction::ObTransDesc& trans_desc);
|
||||
virtual int start_stmt(
|
||||
const uint64_t tenant_id, transaction::ObTransDesc& trans_desc, const common::ObPartitionArray& participants);
|
||||
virtual int end_stmt(bool is_rollback, const transaction::ObTransDesc& trans_desc);
|
||||
|
||||
// ==========================================================================
|
||||
// partition storage interfaces
|
||||
virtual int table_scan(ObTableScanParam& param, common::ObNewRowIterator*& result);
|
||||
virtual int revert_scan_iter(common::ObNewRowIterator* iter);
|
||||
virtual int delete_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, const common::ObIArray<uint64_t>& column_ids,
|
||||
common::ObNewRowIterator* row_iter, int64_t& affected_rows);
|
||||
virtual int insert_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, const common::ObIArray<uint64_t>& column_ids,
|
||||
common::ObNewRowIterator* row_iter, int64_t& affected_rows);
|
||||
virtual int update_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, const common::ObIArray<uint64_t>& column_ids,
|
||||
const common::ObIArray<uint64_t>& updated_column_ids, common::ObNewRowIterator* row_iter, int64_t& affected_rows);
|
||||
virtual int lock_rows(const transaction::ObTransDesc& trans_desc, const int64_t timeout,
|
||||
const common::ObPartitionKey& pkey, common::ObNewRowIterator* row_iter, const ObLockFlag lock_flag,
|
||||
int64_t& affected_rows);
|
||||
|
||||
// ==========================================================================
|
||||
// partition manager interfaces
|
||||
virtual int get_all_partitions(common::ObIArray<ObIPartition*>& partition_list);
|
||||
virtual int get_partition(const common::ObPartitionKey& pkey, ObIPartitionGroup*& partition);
|
||||
|
||||
virtual int get_partition_count(int64_t& partition_count) const;
|
||||
virtual void revert_replay_status(ObReplayStatus* replay_status) const;
|
||||
virtual ObIPartitionIter* alloc_pg_iter();
|
||||
virtual void revert_pg_iter(ObIPartitionIter* iter);
|
||||
virtual ObPGPartitionIterator* alloc_pg_partition_iter();
|
||||
virtual void revert_pg_partition_iter(ObPGPartitionIterator* iter);
|
||||
virtual bool is_empty() const;
|
||||
|
||||
// ==========================================================================
|
||||
// replay interfaces
|
||||
virtual int replay_redo_log(
|
||||
const common::ObPartitionKey& pkey, const ObStoreCtx& ctx, const int64_t ts, const char* buf, const int64_t size);
|
||||
|
||||
virtual transaction::ObITransService* get_trans_service();
|
||||
virtual clog::ObICLogMgr* get_clog_mgr();
|
||||
|
||||
// ==========================================================================
|
||||
// major freeze
|
||||
virtual int set_major_freeze_cb(ObIMajorFreezeCb* cb);
|
||||
virtual int prepare_major_freeze(
|
||||
const obrpc::ObPartitionList& partitions, const int64_t frozen_version, const int64_t frozen_timestamp);
|
||||
virtual int commit_major_freeze(
|
||||
const obrpc::ObPartitionList& partitions, const int64_t frozen_version, const int64_t frozen_timestamp);
|
||||
virtual int abort_major_freeze(
|
||||
const obrpc::ObPartitionList& partitions, const int64_t frozen_version, const int64_t frozen_timestamp);
|
||||
virtual int set_major_freeze_status(
|
||||
const common::ObPartitionKey& pkey, const int64_t frozen_version, const int64_t major_freeze_status);
|
||||
virtual int get_major_freeze_status(
|
||||
const common::ObPartitionKey& pkey, int64_t& frozen_version, int64_t& major_freeze_status);
|
||||
virtual int replay(const ObPartitionKey& partition, const char* log, const int64_t size);
|
||||
virtual int finish_replay(const ObPartitionKey& partition);
|
||||
virtual int leader_freeze_success(const ObPartitionKey& pkey, const int64_t freeze_cmd);
|
||||
virtual int leader_freeze_fail(const ObPartitionKey& pkey, const int64_t freeze_cmd);
|
||||
virtual int follower_freeze_success(const ObPartitionKey& pkey, const int64_t freeze_cmd);
|
||||
virtual int follower_freeze_fail(const ObPartitionKey& pkey, const int64_t freeze_cmd);
|
||||
virtual int submit_freeze_log_success(const int64_t cmd_type, const ObPartitionKey& pkey);
|
||||
|
||||
// ==========================================================================
|
||||
// misc functions
|
||||
virtual int get_role(const common::ObPartitionKey& pkey, common::ObRole& role) const;
|
||||
virtual int get_leader_curr_member_list(const common::ObPartitionKey& pkey, common::ObMemberList& member_list) const;
|
||||
virtual int get_active_memtable_version(const ObPartitionKey& pkey, int64_t& version);
|
||||
virtual int activate_tenant(const uint64_t tenant_id)
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
virtual int inactivate_tenant(const uint64_t tenant_id)
|
||||
{
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
inline int add_row(const common::ObNewRow& row)
|
||||
{
|
||||
return scanner_.add_row(row);
|
||||
}
|
||||
inline void set_col_num(int64_t col_num)
|
||||
{
|
||||
col_num_ = col_num;
|
||||
}
|
||||
virtual ObBaseStorage* get_base_storage()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
virtual int migrate_replica_batch(const obrpc::ObMigrateReplicaBatchArg& arg)
|
||||
{
|
||||
UNUSED(arg);
|
||||
return OB_ERROR;
|
||||
}
|
||||
|
||||
private:
|
||||
common::ObScanner scanner_;
|
||||
int64_t col_num_;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObFakePartitionService);
|
||||
};
|
||||
|
||||
} // namespace storage
|
||||
} // namespace oceanbase
|
||||
#endif /* OCEANBASE_UNITTEST_ENGINE_TABLE_OB_FAKE_PARTITION_SERVICE_ */
|
@ -26,71 +26,71 @@ using namespace oceanbase::sql;
|
||||
#define null static_cast<const char*>(NULL)
|
||||
#define timestamp(val) convert_to_timestamp(val)
|
||||
|
||||
#define COL(val) \
|
||||
({ \
|
||||
ObObj* _obj = new ObObj(); \
|
||||
int err = OB_SUCCESS; \
|
||||
#define COL(val) \
|
||||
({\
|
||||
ObObj *_obj = new ObObj(); \
|
||||
int err = OB_SUCCESS; \
|
||||
if (OB_SUCCESS != (err = set_value(*_obj, val))) { \
|
||||
_OB_LOG(WARN, "fail to set value, err=%d", err); \
|
||||
} \
|
||||
_obj; \
|
||||
} \
|
||||
_obj; \
|
||||
})
|
||||
|
||||
#define COL_T(type, val) \
|
||||
({ \
|
||||
ObObj* _obj = new ObObj(); \
|
||||
_obj->set_##type(val); \
|
||||
_obj; \
|
||||
#define COL_T(type, val) \
|
||||
({ \
|
||||
ObObj *_obj = new ObObj(); \
|
||||
_obj->set_##type(val); \
|
||||
_obj; \
|
||||
})
|
||||
|
||||
#define ADD_ROW(table_op, args...) \
|
||||
if (OB_SUCC(ret)) { \
|
||||
ObObj _cells[OB_MAX_COLUMN_NUMBER]; \
|
||||
ObNewRow _row; \
|
||||
_row.cells_ = _cells; \
|
||||
_row.count_ = table_op.get_column_count(); \
|
||||
if (OB_SUCCESS != (ret = fill_row(_row, ##args))) { \
|
||||
_OB_LOG(WARN, "fail to fill row, ret=%d", ret); \
|
||||
#define ADD_ROW(table_op, args...) \
|
||||
if (OB_SUCC(ret)) { \
|
||||
ObObj _cells[OB_MAX_COLUMN_NUMBER]; \
|
||||
ObNewRow _row; \
|
||||
_row.cells_ = _cells; \
|
||||
_row.count_ = table_op.get_column_count(); \
|
||||
if (OB_SUCCESS != (ret = fill_row(_row, ##args))) { \
|
||||
_OB_LOG(WARN, "fail to fill row, ret=%d", ret); \
|
||||
} else if (OB_SUCCESS != (ret = table_op.add_row(_row))) { \
|
||||
_OB_LOG(WARN, "fail to add row, ret=%d", ret); \
|
||||
} \
|
||||
_OB_LOG(WARN, "fail to add row, ret=%d", ret); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define EXCEPT_RESULT(_ctx, _result_table, op, collation) \
|
||||
EXCEPT_RESULT_WITH_IDX(_ctx, _result_table, op, 0, 0, collation)
|
||||
EXCEPT_RESULT_WITH_IDX(_ctx, _result_table, op, 0, 0, collation)
|
||||
|
||||
#define EXCEPT_RESULT_SET(_ctx, _result_table, op, start_idx, end_idx, collation) \
|
||||
EXCEPT_RESULT_WITH_IDX(_ctx, _result_table, op, start_idx, end_idx, collation)
|
||||
EXCEPT_RESULT_WITH_IDX(_ctx, _result_table, op, start_idx, end_idx, collation)
|
||||
|
||||
#define EXCEPT_RESULT_WITH_IDX(_ctx, _result_table, op, start_idx, end_idx, collation) \
|
||||
if (OB_SUCC(ret)) { \
|
||||
int _ret = OB_SUCCESS; \
|
||||
const ObNewRow* result_row = NULL; \
|
||||
while (OB_SUCCESS == (_ret = op.get_next_row(_ctx, result_row))) { \
|
||||
const ObNewRow* except_row = NULL; \
|
||||
printf("row=%s\n", to_cstring(*result_row)); \
|
||||
ASSERT_EQ(OB_SUCCESS, _result_table.get_next_row(_ctx, except_row)); \
|
||||
printf("except_row=%s\n", to_cstring(*except_row)); \
|
||||
ASSERT_TRUE(except_row->count_ == result_row->count_); \
|
||||
for (int64_t i = start_idx; i < end_idx; ++i) { \
|
||||
printf("index=%ld, cell=%s, respect_cell=%s\n", \
|
||||
i, \
|
||||
to_cstring(result_row->cells_[i]), \
|
||||
to_cstring(except_row->cells_[i])); \
|
||||
#define EXCEPT_RESULT_WITH_IDX(_ctx, _result_table, op, start_idx, end_idx, collation) \
|
||||
if (OB_SUCC(ret)) { \
|
||||
int _ret = OB_SUCCESS; \
|
||||
const ObNewRow *result_row = NULL; \
|
||||
while(OB_SUCCESS == (_ret = op.get_next_row(_ctx, result_row))) { \
|
||||
const ObNewRow *except_row = NULL; \
|
||||
printf("row=%s\n", to_cstring(*result_row)); \
|
||||
ASSERT_EQ(OB_SUCCESS, _result_table.get_next_row(_ctx, except_row)); \
|
||||
printf("except_row=%s\n", to_cstring(*except_row)); \
|
||||
ASSERT_TRUE(except_row->count_ == result_row->count_); \
|
||||
for (int64_t i = start_idx; i < end_idx; ++i) { \
|
||||
printf("index=%ld, cell=%s, respect_cell=%s\n", i, to_cstring(result_row->cells_[i]), to_cstring(except_row->cells_[i])); \
|
||||
ASSERT_TRUE(0 == except_row->cells_[i].compare(result_row->cells_[i], collation)); \
|
||||
} \
|
||||
result_row = NULL; \
|
||||
} \
|
||||
ASSERT_EQ(OB_ITER_END, _ret); \
|
||||
} \
|
||||
result_row = NULL; \
|
||||
} \
|
||||
ASSERT_EQ(OB_ITER_END, _ret); \
|
||||
}
|
||||
|
||||
namespace oceanbase {
|
||||
namespace common {
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
extern void init_global_memory_pool();
|
||||
} // namespace common
|
||||
} // namespace oceanbase
|
||||
|
||||
typedef struct TimeStampWrap {
|
||||
typedef struct TimeStampWrap
|
||||
{
|
||||
int64_t usec_;
|
||||
} TimeStampWrap;
|
||||
|
||||
@ -101,55 +101,65 @@ TimeStampWrap convert_to_timestamp(int64_t usec)
|
||||
return time_stamp;
|
||||
}
|
||||
|
||||
TimeStampWrap convert_to_timestamp(const char* str)
|
||||
TimeStampWrap convert_to_timestamp(const char *str)
|
||||
{
|
||||
TimeStampWrap time_stamp;
|
||||
ObString date = ObString::make_string(str);
|
||||
|
||||
// ObTimeUtility::str_to_usec(date, time_stamp.usec_);
|
||||
//ObTimeUtility::str_to_usec(date, time_stamp.usec_);
|
||||
ObTimeConvertCtx cvrt_ctx(NULL, false);
|
||||
(void)ObTimeConverter::str_to_datetime(date, cvrt_ctx, time_stamp.usec_, NULL);
|
||||
|
||||
return time_stamp;
|
||||
}
|
||||
|
||||
int set_value(ObObj& obj, int val)
|
||||
int set_value(ObObj &obj, int val)
|
||||
{
|
||||
obj.set_int(static_cast<int64_t>(val));
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int set_value(ObObj& obj, int64_t val)
|
||||
int set_value(ObObj &obj, int64_t val)
|
||||
{
|
||||
obj.set_int(val);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int set_value(ObObj& obj, float val)
|
||||
int set_value(ObObj &obj, float val)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObObj obj1;
|
||||
obj1.set_float(val);
|
||||
ObCastCtx cast_ctx(global_default_allocator, NULL, 0, CM_NONE, CS_TYPE_INVALID, NULL);
|
||||
ObCastCtx cast_ctx(global_default_allocator,
|
||||
NULL,
|
||||
0,
|
||||
CM_NONE,
|
||||
CS_TYPE_INVALID,
|
||||
NULL);
|
||||
if (OB_FAIL(ObObjCaster::to_type(ObNumberType, cast_ctx, obj1, obj))) {
|
||||
_OB_LOG(WARN, "fail to cast obj, ret=%d", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int set_value(ObObj& obj, double val)
|
||||
int set_value(ObObj &obj, double val)
|
||||
{
|
||||
ObObj obj1;
|
||||
int ret = OB_SUCCESS;
|
||||
obj1.set_double(val);
|
||||
ObCastCtx cast_ctx(global_default_allocator, NULL, 0, CM_NONE, CS_TYPE_INVALID, NULL);
|
||||
ObCastCtx cast_ctx(global_default_allocator,
|
||||
NULL,
|
||||
0,
|
||||
CM_NONE,
|
||||
CS_TYPE_INVALID,
|
||||
NULL);
|
||||
if (OB_FAIL(ObObjCaster::to_type(ObNumberType, cast_ctx, obj1, obj))) {
|
||||
_OB_LOG(WARN, "fail to cast obj, ret=%d", ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int set_value(ObObj& obj, const char* val)
|
||||
int set_value(ObObj &obj, const char *val)
|
||||
{
|
||||
if (NULL == val) {
|
||||
obj.set_null();
|
||||
@ -159,21 +169,21 @@ int set_value(ObObj& obj, const char* val)
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int set_value(ObObj& obj, const ObObj& val)
|
||||
int set_value(ObObj &obj, const ObObj &val)
|
||||
{
|
||||
obj = val;
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
int set_value(ObObj& obj, TimeStampWrap val)
|
||||
int set_value(ObObj &obj, TimeStampWrap val)
|
||||
{
|
||||
obj.set_timestamp(val.usec_);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
int fill_row(ObNewRow& row, ...)
|
||||
int fill_row(ObNewRow &row, ...)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObObj* ptr = NULL;
|
||||
ObObj *ptr = NULL;
|
||||
va_list ap;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
@ -198,12 +208,16 @@ int fill_row(ObNewRow& row, ...)
|
||||
return ret;
|
||||
}
|
||||
static ObArenaAllocator alloc_;
|
||||
class ObFakeTable : public ObNoChildrenPhyOperator {
|
||||
class ObFakeTable : public ObNoChildrenPhyOperator
|
||||
{
|
||||
private:
|
||||
class ObFakeTableCtx : public ObPhyOperatorCtx {
|
||||
class ObFakeTableCtx : public ObPhyOperatorCtx
|
||||
{
|
||||
public:
|
||||
ObFakeTableCtx(ObExecContext& ctx) : ObPhyOperatorCtx(ctx)
|
||||
{}
|
||||
ObFakeTableCtx(ObExecContext &ctx)
|
||||
: ObPhyOperatorCtx(ctx)
|
||||
{
|
||||
}
|
||||
int init(int64_t projector_size)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -219,12 +233,9 @@ private:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
virtual void destroy()
|
||||
{
|
||||
return ObPhyOperatorCtx::destroy_base();
|
||||
}
|
||||
virtual void destroy() { return ObPhyOperatorCtx::destroy_base(); }
|
||||
int64_t projector_size_;
|
||||
int32_t* projector_;
|
||||
int32_t *projector_;
|
||||
|
||||
private:
|
||||
ObRowStore::Iterator row_store_it_;
|
||||
@ -232,38 +243,35 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
ObFakeTable(ObIAllocator& alloc) : ObNoChildrenPhyOperator(alloc), no_rescan_(false)
|
||||
{}
|
||||
ObFakeTable(ObIAllocator &alloc) : ObNoChildrenPhyOperator(alloc), no_rescan_(false)
|
||||
{
|
||||
}
|
||||
|
||||
ObFakeTable() : ObNoChildrenPhyOperator(alloc_), no_rescan_(false)
|
||||
{}
|
||||
~ObFakeTable()
|
||||
{}
|
||||
|
||||
void set_no_rescan()
|
||||
{
|
||||
no_rescan_ = true;
|
||||
}
|
||||
~ObFakeTable()
|
||||
{
|
||||
}
|
||||
|
||||
void set_no_rescan() { no_rescan_ = true; }
|
||||
void reset()
|
||||
{
|
||||
row_store_.reset();
|
||||
ObNoChildrenPhyOperator::reset();
|
||||
}
|
||||
|
||||
int add_row(const ObNewRow& row)
|
||||
int add_row(const ObNewRow &row)
|
||||
{
|
||||
return row_store_.add_row(row);
|
||||
}
|
||||
|
||||
ObPhyOperatorType get_type() const
|
||||
{
|
||||
return PHY_FAKE_TABLE;
|
||||
}
|
||||
ObPhyOperatorType get_type() const { return PHY_FAKE_TABLE; }
|
||||
|
||||
int inner_open(ObExecContext& ctx) const
|
||||
int inner_open(ObExecContext &ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObFakeTableCtx* table_ctx = NULL;
|
||||
ObFakeTableCtx *table_ctx = NULL;
|
||||
|
||||
if (OB_SUCCESS != (ret = init_op_ctx(ctx))) {
|
||||
_OB_LOG(WARN, "fail to init operator context, ret=%d", ret);
|
||||
@ -278,25 +286,24 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rescan(ObExecContext& ctx) const
|
||||
int rescan(ObExecContext &ctx) const
|
||||
{
|
||||
if (no_rescan_) {
|
||||
return OB_SUCCESS;
|
||||
} else {
|
||||
ObFakeTableCtx* fake_table_ctx = NULL;
|
||||
fake_table_ctx = GET_PHY_OPERATOR_CTX(ObFakeTableCtx, ctx, get_id());
|
||||
OB_ASSERT(fake_table_ctx);
|
||||
fake_table_ctx->row_store_it_ = row_store_.begin();
|
||||
return ObNoChildrenPhyOperator::rescan(ctx);
|
||||
}
|
||||
if (no_rescan_) {
|
||||
return OB_SUCCESS;
|
||||
} else {
|
||||
ObFakeTableCtx *fake_table_ctx = NULL;
|
||||
fake_table_ctx = GET_PHY_OPERATOR_CTX(ObFakeTableCtx, ctx, get_id());
|
||||
OB_ASSERT(fake_table_ctx);
|
||||
fake_table_ctx->row_store_it_ = row_store_.begin();
|
||||
return ObNoChildrenPhyOperator::rescan(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
int inner_close(ObExecContext& ctx) const
|
||||
int inner_close(ObExecContext &ctx) const
|
||||
{
|
||||
UNUSED(ctx);
|
||||
return OB_SUCCESS;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief create operator context, only child operator can know it's specific operator type,
|
||||
@ -305,11 +312,15 @@ private:
|
||||
* @param op_ctx[out], the pointer of operator context
|
||||
* @return if success, return OB_SUCCESS, otherwise, return errno
|
||||
*/
|
||||
virtual int init_op_ctx(ObExecContext& ctx) const
|
||||
virtual int init_op_ctx(ObExecContext &ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPhyOperatorCtx* op_ctx = NULL;
|
||||
if (OB_SUCCESS != (ret = CREATE_PHY_OPERATOR_CTX(ObFakeTableCtx, ctx, get_id(), get_type(), op_ctx))) {
|
||||
ObPhyOperatorCtx *op_ctx = NULL;
|
||||
if (OB_SUCCESS != (ret = CREATE_PHY_OPERATOR_CTX(ObFakeTableCtx,
|
||||
ctx,
|
||||
get_id(),
|
||||
get_type(),
|
||||
op_ctx))) {
|
||||
SQL_EXE_LOG(WARN, "create physical operator context failed", K(ret));
|
||||
} else if (OB_SUCCESS != (ret = op_ctx->create_cur_row(get_column_count(), projector_, projector_size_))) {
|
||||
SQL_EXE_LOG(WARN, "create current row failed", K(ret));
|
||||
@ -321,27 +332,28 @@ private:
|
||||
* @param ctx[in], execute context
|
||||
* @param row[out], ObSqlRow an obj array and row_size
|
||||
*/
|
||||
virtual int inner_get_next_row(ObExecContext& ctx, const ObNewRow*& row) const
|
||||
virtual int inner_get_next_row(ObExecContext &ctx, const ObNewRow *&row) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObFakeTableCtx* table_ctx = NULL;
|
||||
ObFakeTableCtx *table_ctx = NULL;
|
||||
|
||||
if (NULL == (table_ctx = GET_PHY_OPERATOR_CTX(ObFakeTableCtx, ctx, get_id()))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
_OB_LOG(WARN, "fail to get physical operator context");
|
||||
} else if (OB_SUCCESS != (ret = table_ctx->row_store_it_.get_next_row(table_ctx->get_cur_row()))) {
|
||||
} else if (OB_SUCCESS != (ret = table_ctx->row_store_it_.get_next_row(
|
||||
table_ctx->get_cur_row()))) {
|
||||
if (OB_ITER_END != ret) {
|
||||
_OB_LOG(WARN, "fail to get next row, ret=%d", ret);
|
||||
}
|
||||
} else {
|
||||
row = &table_ctx->get_cur_row();
|
||||
const_cast<ObNewRow*>(row)->projector_ = table_ctx->projector_;
|
||||
const_cast<ObNewRow*>(row)->projector_size_ = table_ctx->projector_size_;
|
||||
const_cast<ObNewRow *>(row)->projector_ = table_ctx->projector_;
|
||||
const_cast<ObNewRow *>(row)->projector_size_ = table_ctx->projector_size_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual int64_t to_string_kv(char* buf, const int64_t buf_len) const
|
||||
virtual int64_t to_string_kv(char *buf, const int64_t buf_len) const
|
||||
{
|
||||
int64_t pos = 0;
|
||||
J_KV(N_ROW_STORE, row_store_);
|
||||
@ -349,7 +361,6 @@ private:
|
||||
}
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ObFakeTable);
|
||||
|
||||
private:
|
||||
ObRowStore row_store_;
|
||||
bool no_rescan_;
|
||||
|
301
unittest/sql/engine/table/test_table_scan.cpp
Normal file
301
unittest/sql/engine/table/test_table_scan.cpp
Normal file
@ -0,0 +1,301 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <stdarg.h>
|
||||
#include "sql/executor/ob_executor.h"
|
||||
#include "sql/executor/ob_distributed_scheduler.h"
|
||||
#include "sql/engine/sort/ob_sort.h"
|
||||
#include "sql/engine/table/ob_table_scan.h"
|
||||
#include "sql/executor/ob_root_transmit.h"
|
||||
#include "sql/executor/ob_distributed_transmit.h"
|
||||
#include "sql/executor/ob_direct_receive.h"
|
||||
#include "sql/executor/ob_fifo_receive.h"
|
||||
#include "sql/executor/ob_distributed_job_control.h"
|
||||
#include "sql/executor/ob_job_parser.h"
|
||||
#include "sql/executor/ob_task_spliter_factory.h"
|
||||
#include "sql/engine/ob_physical_plan_ctx.h"
|
||||
#include "sql/engine/ob_physical_plan.h"
|
||||
#include "sql/ob_sql_init.h"
|
||||
#include "lib/utility/ob_tracepoint.h"
|
||||
|
||||
using namespace oceanbase;
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::storage;
|
||||
using namespace oceanbase::share;
|
||||
using namespace oceanbase::share::schema;
|
||||
|
||||
class ObTableScanTest : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
|
||||
const static int64_t TEST_COL_NUM = 2;
|
||||
const static int64_t TEST_SPLIT_TASK_COUNT = 7;
|
||||
const static int64_t TEST_PARA_SERVER_COUNT = 2;
|
||||
const static int64_t TEST_SERVER_PARA_THREAD_COUNT = 3;
|
||||
|
||||
const static int64_t TEST_TABLE_ID = 1;
|
||||
const static int64_t TEST_INDEX_ID = 1;
|
||||
const static uint64_t COLUMN_ID_1 = 16;
|
||||
const static uint64_t COLUMN_ID_2 = 17;
|
||||
|
||||
const static int64_t TEST_LIMIT = 10;
|
||||
const static int64_t TEST_OFFSET = 0;
|
||||
|
||||
|
||||
ObTableScanTest();
|
||||
virtual ~ObTableScanTest();
|
||||
virtual void SetUp();
|
||||
virtual void TearDown();
|
||||
|
||||
ObPhysicalPlan *local_phy_plan_;
|
||||
|
||||
int create_local_plan_tree(ObExecContext &ctx);
|
||||
private:
|
||||
// disallow copy
|
||||
ObTableScanTest(const ObTableScanTest &other);
|
||||
ObTableScanTest& operator=(const ObTableScanTest &other);
|
||||
private:
|
||||
// data members
|
||||
};
|
||||
ObTableScanTest::ObTableScanTest()
|
||||
{
|
||||
}
|
||||
|
||||
ObTableScanTest::~ObTableScanTest()
|
||||
{
|
||||
}
|
||||
|
||||
void ObTableScanTest::SetUp()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 1; OB_SUCC(ret) && i <= 5; ++i) {
|
||||
for (int64_t j = 1; OB_SUCC(ret) && j <= 10; ++j) {
|
||||
ObFakePartitionKey key;
|
||||
key.table_id_ = i;
|
||||
key.partition_id_ = j;
|
||||
ObPartitionLocation location;
|
||||
ObReplicaLocation replica_loc;
|
||||
replica_loc.server_.set_ip_addr("127.0.0.1", (int32_t)j);
|
||||
replica_loc.role_ = common::LEADER;
|
||||
if (OB_SUCCESS != (ret = location.add(replica_loc))) {
|
||||
SQL_ENG_LOG(WARN, "fail to add replica location", K(ret), K(i), K(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObTableScanTest::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
int ObTableScanTest::create_local_plan_tree(ObExecContext &ctx)
|
||||
{
|
||||
UNUSED(ctx);
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
partition_service_.set_col_num(TEST_COL_NUM);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < 100; ++i) {
|
||||
ObNewRow row;
|
||||
ObObj objs[TEST_COL_NUM];
|
||||
row.count_ = TEST_COL_NUM;
|
||||
row.cells_ = objs;
|
||||
for (int64_t j = 0; j < TEST_COL_NUM; ++j) {
|
||||
row.cells_[j].set_int(i);
|
||||
}
|
||||
partition_service_.add_row(row);
|
||||
}
|
||||
|
||||
local_phy_plan_ = ObPhysicalPlan::alloc();
|
||||
ObPhyOperator *cur_op = NULL;
|
||||
ObPhyOperator *tmp_op = NULL;
|
||||
int err_code = OB_SUCCESS;
|
||||
|
||||
ObSqlExpression *limit_expr = NULL;
|
||||
EXPECT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(local_phy_plan_, limit_expr));
|
||||
EXPECT_FALSE(NULL == limit_expr);
|
||||
ObPostExprItem limit_expr_item;
|
||||
limit_expr_item.set_int(TEST_LIMIT);
|
||||
limit_expr_item.set_item_type(T_INT);
|
||||
EXPECT_EQ(OB_SUCCESS, limit_expr->add_expr_item(limit_expr_item));
|
||||
|
||||
ObSqlExpression *offset_expr = NULL;
|
||||
EXPECT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(local_phy_plan_, offset_expr));
|
||||
EXPECT_FALSE(NULL == offset_expr);
|
||||
ObPostExprItem offset_expr_item;
|
||||
offset_expr_item.set_int(TEST_OFFSET);
|
||||
offset_expr_item.set_item_type(T_INT);
|
||||
EXPECT_EQ(OB_SUCCESS, offset_expr->add_expr_item(offset_expr_item));
|
||||
|
||||
/*
|
||||
* calculate c0 % TEST_SPLIT_TASK_COUNT
|
||||
* */
|
||||
ObSqlExpression *hash_expr = NULL;
|
||||
EXPECT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(local_phy_plan_, hash_expr));
|
||||
EXPECT_FALSE(NULL == hash_expr);
|
||||
ObPostExprItem expr_item;
|
||||
expr_item.set_column(0);
|
||||
EXPECT_EQ(OB_SUCCESS, hash_expr->add_expr_item(expr_item));
|
||||
expr_item.set_int(TEST_SPLIT_TASK_COUNT);
|
||||
expr_item.set_item_type(T_INT);
|
||||
EXPECT_EQ(OB_SUCCESS, hash_expr->add_expr_item(expr_item));
|
||||
expr_item.set_op("%", 2);
|
||||
EXPECT_EQ(OB_SUCCESS, hash_expr->add_expr_item(expr_item));
|
||||
|
||||
/*
|
||||
* calculate c0 % 1
|
||||
* */
|
||||
ObSqlExpression *iden_hash_expr = NULL;
|
||||
EXPECT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(local_phy_plan_, iden_hash_expr));
|
||||
EXPECT_FALSE(NULL == iden_hash_expr);
|
||||
ObPostExprItem iden_expr_item;
|
||||
iden_expr_item.set_column(0);
|
||||
EXPECT_EQ(OB_SUCCESS, iden_hash_expr->add_expr_item(iden_expr_item));
|
||||
iden_expr_item.set_int(1);
|
||||
iden_expr_item.set_item_type(T_INT);
|
||||
EXPECT_EQ(OB_SUCCESS, iden_hash_expr->add_expr_item(iden_expr_item));
|
||||
iden_expr_item.set_op("%", 2);
|
||||
EXPECT_EQ(OB_SUCCESS, iden_hash_expr->add_expr_item(iden_expr_item));
|
||||
|
||||
ObPhysicalPlanCtx *plan_ctx = ctx.get_physical_plan_ctx();
|
||||
common::ObIArray<common::ObObj> ¶m_store = plan_ctx->get_param_store();
|
||||
ObObj value1;
|
||||
value1.set_int(3);
|
||||
param_store.push_back(value1);
|
||||
ObObj value2;
|
||||
value2.set_int(1);
|
||||
param_store.push_back(value2);
|
||||
ObObj value3;
|
||||
value3.set_int(2);
|
||||
param_store.push_back(value3);
|
||||
|
||||
|
||||
/*
|
||||
* calculate a + ?
|
||||
* */
|
||||
ObSqlExpression *partition_func = NULL;
|
||||
EXPECT_EQ(OB_SUCCESS, ObSqlExpressionUtil::make_sql_expr(local_phy_plan_, partition_func));
|
||||
EXPECT_FALSE(NULL == partition_func);
|
||||
ObPostExprItem partition_func_item;
|
||||
partition_func_item.set_column(0);
|
||||
EXPECT_EQ(OB_SUCCESS, partition_func->add_expr_item(partition_func_item));
|
||||
ObObj index_value;
|
||||
index_value.set_int(2);
|
||||
partition_func_item.assign(T_QUESTIONMARK, index_value);
|
||||
EXPECT_EQ(OB_SUCCESS, partition_func->add_expr_item(partition_func_item));
|
||||
partition_func_item.set_op("+", 2);
|
||||
EXPECT_EQ(OB_SUCCESS, partition_func->add_expr_item(partition_func_item));
|
||||
|
||||
ObColumnRefRawExpr ref_col(TEST_TABLE_ID, COLUMN_ID_1, T_REF_COLUMN);
|
||||
ObArray<ColumnItem> single_range_columns;
|
||||
ColumnItem col;
|
||||
col.column_id_ = COLUMN_ID_1;
|
||||
col.table_id_ = TEST_TABLE_ID;
|
||||
col.data_type_ = ObIntType;
|
||||
col.column_name_ = ObString::make_string("a");
|
||||
EXPECT_EQ(OB_SUCCESS, single_range_columns.push_back(col));
|
||||
ref_col.add_flag(IS_COLUMN);
|
||||
// 构造 (a = ?)
|
||||
ObObj index1;
|
||||
index1.set_unknown(0);
|
||||
ObConstRawExpr const_col1(index1, T_QUESTIONMARK);
|
||||
const_col1.add_flag(IS_PARAM);
|
||||
ObOpRawExpr condition1(&ref_col, &const_col1, T_OP_EQ); // a = ?构造完毕
|
||||
// 构造 (a > ?)
|
||||
ObObj index2;
|
||||
index2.set_unknown(1);
|
||||
ObConstRawExpr const_col2(index2, T_QUESTIONMARK);
|
||||
const_col2.add_flag(IS_PARAM);
|
||||
ObOpRawExpr condition2(&ref_col, &const_col2, T_OP_GT); // a > ?构造完毕
|
||||
ObQueryRange *scan_query_range = OB_NEW(ObQueryRange, ObModIds::TEST);
|
||||
EXPECT_EQ(OB_SUCCESS, scan_query_range->preliminary_extract_query_range(single_range_columns, &condition2));
|
||||
|
||||
ASSERT_EQ(OB_SUCCESS, local_phy_plan_->alloc_operator_by_type(PHY_TABLE_SCAN, tmp_op));
|
||||
tmp_op->set_column_count(TEST_COL_NUM);
|
||||
static_cast<ObTableScan*>(tmp_op)->set_table_id(TEST_TABLE_ID);
|
||||
static_cast<ObTableScan*>(tmp_op)->set_ref_table_id(TEST_TABLE_ID);
|
||||
static_cast<ObTableScan*>(tmp_op)->set_index_table_id(TEST_INDEX_ID);
|
||||
static_cast<ObTableScan*>(tmp_op)->add_range_column(COLUMN_ID_1);
|
||||
static_cast<ObTableScan*>(tmp_op)->add_output_column(COLUMN_ID_1);
|
||||
static_cast<ObTableScan*>(tmp_op)->add_output_column(COLUMN_ID_2);
|
||||
static_cast<ObTableScan*>(tmp_op)->set_limit_offset(*limit_expr, *offset_expr);
|
||||
static_cast<ObTableScan*>(tmp_op)->set_query_range(*scan_query_range);
|
||||
cur_op = tmp_op;
|
||||
SQL_ENG_LOG(INFO, "op info", "op_id", cur_op->get_id(), "op_type", cur_op->get_type());
|
||||
|
||||
ASSERT_EQ(OB_SUCCESS, local_phy_plan_->alloc_operator_by_type(PHY_ROOT_TRANSMIT, tmp_op));
|
||||
tmp_op->set_column_count(TEST_COL_NUM);
|
||||
tmp_op->set_child(0, *cur_op);
|
||||
static_cast<ObTransmit*>(tmp_op)->get_job_conf().set_scan_table_id(TEST_TABLE_ID, TEST_INDEX_ID);
|
||||
static_cast<ObTransmit*>(tmp_op)->get_job_conf().set_task_split_type(ObTaskSpliter::IDENTITY_SPLIT);
|
||||
static_cast<ObTransmit*>(tmp_op)->set_split_task_count(TEST_SPLIT_TASK_COUNT);
|
||||
static_cast<ObTransmit*>(tmp_op)->set_parallel_server_count(TEST_PARA_SERVER_COUNT);
|
||||
static_cast<ObTransmit*>(tmp_op)->set_server_parallel_thread_count(TEST_SERVER_PARA_THREAD_COUNT);
|
||||
static_cast<ObTransmit*>(tmp_op)->set_shuffle_func(hash_expr);
|
||||
cur_op = tmp_op;
|
||||
SQL_ENG_LOG(INFO, "op info", "op_id", cur_op->get_id(), "op_type", cur_op->get_type());
|
||||
|
||||
local_phy_plan_->set_main_query(cur_op);
|
||||
local_phy_plan_->set_execute_type(OB_LOCAL_SINGLE_PARTITION_PLAN);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEST_F(ObTableScanTest, basic_test)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPhyTableLocationSEArray table_locs;
|
||||
ObPhyTableLocation table_loc;
|
||||
ObPartitionLocation partition_loc;
|
||||
partition_loc.set_table_id(TEST_TABLE_ID);
|
||||
partition_loc.set_partition_id(9);
|
||||
table_loc.set_table_id(TEST_TABLE_ID);
|
||||
ASSERT_EQ(OB_SUCCESS, table_loc.add_partition_location(partition_loc));
|
||||
ASSERT_EQ(OB_SUCCESS, table_locs.push_back(table_loc));
|
||||
ObAddr server;
|
||||
server.set_ip_addr("127.0.0.1", 8888);
|
||||
ObExecuteResult exe_result;
|
||||
ObExecContext exec_ctx;
|
||||
exec_ctx.init_phy_op(100);
|
||||
exec_ctx.create_physical_plan_ctx();
|
||||
ObPhysicalPlanCtx *plan_ctx = exec_ctx.get_physical_plan_ctx();
|
||||
//plan_ctx->set_executor_rpc(rpc);
|
||||
//plan_ctx->set_task_response_handler(resp_handler);
|
||||
plan_ctx->set_server(server);
|
||||
plan_ctx->set_timeout_timestamp(::oceanbase::common::ObTimeUtility::current_time() + 2000L * 1000L);
|
||||
ObTaskExecutorCtx *task_exe_ctx = exec_ctx.get_task_executor_ctx();
|
||||
task_exe_ctx->set_partition_service(&partition_service_);
|
||||
task_exe_ctx->set_execute_result(&exe_result);
|
||||
task_exe_ctx->set_table_locations(table_locs);
|
||||
|
||||
ASSERT_EQ(OB_SUCCESS, create_local_plan_tree(exec_ctx));
|
||||
|
||||
ObExecutor ob_exe;
|
||||
ASSERT_EQ(OB_SUCCESS, ob_exe.execute_plan(exec_ctx, local_phy_plan_));
|
||||
ASSERT_EQ(OB_SUCCESS, exe_result.open(exec_ctx));
|
||||
const ObNewRow *tmp_row = NULL;
|
||||
while(OB_SUCCESS == (ret = exe_result.get_next_row(exec_ctx, tmp_row))) {
|
||||
SQL_ENG_LOG(INFO, "get a row", K(*tmp_row));
|
||||
}
|
||||
ASSERT_EQ(OB_ITER_END, ret);
|
||||
ASSERT_EQ(OB_SUCCESS, exe_result.close(exec_ctx));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
OB_LOGGER.set_log_level("INFO");
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
|
||||
init_sql_factories();
|
||||
::testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
Reference in New Issue
Block a user