本文整理汇总了C++中ObScanner::get_cell方法的典型用法代码示例。如果您正苦于以下问题:C++ ObScanner::get_cell方法的具体用法?C++ ObScanner::get_cell怎么用?C++ ObScanner::get_cell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObScanner
的用法示例。
在下文中一共展示了ObScanner::get_cell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: total_scan
void total_scan(const char *fname, PageArena<char> &allocer, MockClient &client, const char *version_range)
{
ObScanner scanner;
ObScanParam scan_param;
read_scan_param(fname, SCAN_PARAM_SECTION, allocer, scan_param);
scan_param.set_version_range(str2range(version_range));
scan_param.set_is_read_consistency(false);
int64_t total_fullfilled_num = 0;
int64_t total_row_counter = 0;
int64_t total_timeu = 0;
while (true)
{
int64_t timeu = tbsys::CTimeUtil::getTime();
int err = client.ups_scan(scan_param, scanner, timeout);
timeu = tbsys::CTimeUtil::getTime() - timeu;
if (OB_SUCCESS != err)
{
fprintf(stdout, "[%s] err=%d\n", __FUNCTION__, err);
break;
}
else
{
int64_t row_counter = 0;
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo *ci = NULL;
bool is_row_changed = false;
scanner.get_cell(&ci, &is_row_changed);
//fprintf(stdout, "%s\n", updateserver::print_cellinfo(ci, "CLI_SCAN"));
if (is_row_changed)
{
row_counter++;
}
}
bool is_fullfilled = false;
int64_t fullfilled_num = 0;
ObRowkey last_rk;
scanner.get_last_row_key(last_rk);
scanner.get_is_req_fullfilled(is_fullfilled, fullfilled_num);
fprintf(stdout, "[SINGLE_SCAN] is_fullfilled=%s fullfilled_num=%ld row_counter=%ld timeu=%ld last_row_key=[%s]\n",
STR_BOOL(is_fullfilled), fullfilled_num, row_counter, timeu, to_cstring(last_rk));
total_fullfilled_num += fullfilled_num;
total_row_counter += row_counter;
total_timeu += timeu;
if (is_fullfilled)
{
break;
}
else
{
const_cast<ObNewRange*>(scan_param.get_range())->start_key_ = last_rk;
const_cast<ObNewRange*>(scan_param.get_range())->border_flag_.unset_min_value();
const_cast<ObNewRange*>(scan_param.get_range())->border_flag_.unset_inclusive_start();
}
}
}
fprintf(stdout, "[TOTAL_SCAN] total_fullfilled_num=%ld total_row_counter=%ld total_timeu=%ld\n",
total_fullfilled_num, total_row_counter, total_timeu);
}
示例2: print_scanner
int print_scanner(const char * buffer, const int64_t len, int64_t & pos, FILE * file)
{
int ret = OB_SUCCESS;
if ((NULL == buffer) || (NULL == file))
{
TBSYS_LOG(ERROR, "check buffer failed:buff[%p], file[%p]", buffer, file);
ret = OB_ERROR;
}
else
{
ObScanner result;
ret = result.deserialize(buffer, len, pos);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "check deserialize scanner failed:pos[%ld], ret[%d]", pos, ret);
}
else
{
bool first_cell = true;
ObCellInfo * cur_cell = NULL;
ObCellInfo * pre_cell = NULL;
while (result.next_cell() == OB_SUCCESS)
{
ret = result.get_cell(&cur_cell);
if (OB_SUCCESS == ret)
{
pre_cell = cur_cell;
if (first_cell)
{
first_cell = false;
fprintf(file, "table_name:%.*s, rowkey:%.*s\n", cur_cell->table_name_.length(), cur_cell->table_name_.ptr(),
cur_cell->row_key_.length(), cur_cell->row_key_.ptr());
}
/*
fprintf(file, "table_name:%.*s, rowkey:%.*s, column_name:%.*s, ext:%ld, type:%d\n",
cur_cell->table_name_.length(), cur_cell->table_name_.ptr(),
cur_cell->row_key_.length(), cur_cell->row_key_.ptr(),
cur_cell->column_name_.length(), cur_cell->column_name_.ptr(),
cur_cell->value_.get_ext(),cur_cell->value_.get_type());
//cur_cell->value_.dump();
*/
}
else
{
ret = OB_ERROR;
TBSYS_LOG(ERROR, "get cell failed:ret[%d]", ret);
break;
}
}
if (OB_SUCCESS == ret)
{
fprintf(file, "table_name:%.*s, rowkey:%.*s\n", pre_cell->table_name_.length(), pre_cell->table_name_.ptr(),
pre_cell->row_key_.length(), pre_cell->row_key_.ptr());
}
}
}
return ret;
}
示例3: get_check_row
bool get_check_row(const ObSchema &schema, const ObString &row_key, CellinfoBuilder &cb,
MockClient &client, const int64_t table_start_version, const bool using_id)
{
bool bret = false;
ObGetParam get_param;
const ObColumnSchema *iter = NULL;
for (iter = schema.column_begin(); iter != schema.column_end(); iter++)
{
ObCellInfo ci;
ci.row_key_ = row_key;
if (using_id)
{
ci.table_id_ = schema.get_table_id();
ci.column_id_ = iter->get_id();
}
else
{
ci.table_name_.assign_ptr(const_cast<char*>(schema.get_table_name()), strlen(schema.get_table_name()));
ci.column_name_.assign_ptr(const_cast<char*>(iter->get_name()), strlen(iter->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);
ObScanner scanner;
int ret = client.ups_get(get_param, scanner, TIMEOUT_MS);
if (OB_SUCCESS == ret)
{
RowChecker rc;
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo *ci = NULL;
if (OB_SUCCESS == scanner.get_cell(&ci))
{
if (!using_id)
{
trans_name2id(*ci, schema);
}
rc.add_cell(ci);
}
}
bret = rc.check_row(cb, schema);
}
else
{
TBSYS_LOG(WARN, "get ret=%d", ret);
}
return bret;
return true;
}
示例4: check_result
bool MultiGetP::check_result(const uint32_t min_key_include, const uint32_t max_key_include, ObScanner &result,
void *arg)
{
bool res = true;
int err = OB_SUCCESS;
UNUSED(min_key_include);
UNUSED(max_key_include);
ObGetParam *get_param = reinterpret_cast<ObGetParam*>(arg);
ObCellInfo *cur_cell = NULL;
if ((OB_SUCCESS == err) && (result.get_cell_num() != get_param->get_cell_size()))
{
TBSYS_LOG(WARN,"result cell count not correct [got_cell_count:%ld,request_cell_count:%ld]", result.get_cell_num(),
get_param->get_cell_size());
err = OB_ERR_UNEXPECTED;
}
for (int64_t i = 0; (i < get_param->get_cell_size()) && (OB_SUCCESS == err); i++)
{
if ((OB_SUCCESS == err) && (OB_SUCCESS != (err = result.next_cell())))
{
TBSYS_LOG(WARN,"fail to get next cell [err:%d]", err);
}
if ((OB_SUCCESS == err) && (OB_SUCCESS != (err = result.get_cell(&cur_cell))))
{
TBSYS_LOG(WARN,"fail to get next cell [err:%d]", err);
}
if (OB_SUCCESS == err)
{
if ((cur_cell->table_name_ != (*get_param)[i]->table_name_)
|| (cur_cell->column_name_ != (*get_param)[i]->column_name_)
|| (cur_cell->row_key_ != (*get_param)[i]->row_key_)
|| !(msolap::olap_check_cell(*cur_cell)))
{
TBSYS_LOG(WARN,"cell error");
err = OB_ERR_UNEXPECTED;
}
}
}
if ((OB_SUCCESS == err) && (result.next_cell() != OB_ITER_END))
{
TBSYS_LOG(WARN,"result not ended as expected");
err = OB_ERR_UNEXPECTED;
}
if (OB_SUCCESS != err)
{
res = false;
}
return res;
}
示例5: check_result
bool GetNotExistRows::check_result(const uint32_t min_key_include, const uint32_t max_key_include, ObScanner &result,
void *arg)
{
bool res = true;
int err = OB_SUCCESS;
UNUSED(min_key_include);
UNUSED(max_key_include);
ObGetParam *get_param = reinterpret_cast<ObGetParam*>(arg);
if(result.get_cell_num() != get_param->get_cell_size())
{
TBSYS_LOG(WARN,"result cell number error [got:%ld,expcted:%ld]", result.get_cell_num(), get_param->get_cell_size());
err = OB_ERR_UNEXPECTED;
}
int64_t got_cell_num = 0;
ObCellInfo *cur_cell = NULL;
for (got_cell_num = 0; (got_cell_num < get_param->get_cell_size()) && (OB_SUCCESS == err); got_cell_num++)
{
if (OB_SUCCESS != (err = result.next_cell()))
{
TBSYS_LOG(WARN,"fail to get next cell from result [err:%d]", err);
}
if ((OB_SUCCESS == err) && (OB_SUCCESS != (err = result.get_cell(&cur_cell))))
{
TBSYS_LOG(WARN,"fail to get next cell from result [err:%d]", err);
}
if ((OB_SUCCESS == err)
&& ((cur_cell->table_name_ != msolap::target_table_name)
|| (cur_cell->row_key_ != (*get_param)[got_cell_num]->row_key_)
|| (ObActionFlag::OP_ROW_DOES_NOT_EXIST != cur_cell->value_.get_ext())))
{
TBSYS_LOG(WARN,"cell content error");
err = OB_ERR_UNEXPECTED;
}
}
if ((OB_SUCCESS == err) && (OB_ITER_END != result.next_cell()))
{
TBSYS_LOG(WARN,"fail to get enough cells from result");
err = OB_ERR_UNEXPECTED;
}
if (OB_SUCCESS != err)
{
res = false;
}
return res;
}
示例6: print_root_table
void print_root_table(FILE* fd, ObScanner &scanner)
{
ObCellInfo* cell = NULL;
bool is_row_changed = false;
while(OB_SUCCESS == scanner.next_cell())
{
if (OB_SUCCESS == scanner.get_cell(&cell, &is_row_changed))
{
if (is_row_changed)
{
fprintf(fd, "\n");
print_rowkey(fd, cell->row_key_);
fprintf(fd, "|");
}
fprintf(fd, "%.*s ", cell->column_name_.length(), cell->column_name_.ptr());
cell->value_.print_value(fd);
fprintf(fd, "|");
}
}
fprintf(fd, "\n");
}
示例7: print_scanner
void print_scanner(ObScanner &scanner)
{
int64_t row_counter = 0;
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo *ci = NULL;
bool is_row_changed = false;
scanner.get_cell(&ci, &is_row_changed);
fprintf(stdout, "%s\n", common::print_cellinfo(ci, "CLI_SCAN"));
if (is_row_changed)
{
row_counter++;
}
}
bool is_fullfilled = false;
int64_t fullfilled_num = 0;
ObRowkey last_rk;
scanner.get_last_row_key(last_rk);
scanner.get_is_req_fullfilled(is_fullfilled, fullfilled_num);
fprintf(stdout, "is_fullfilled=%s fullfilled_num=%ld row_counter=%ld last_row_key=[%s]\n",
STR_BOOL(is_fullfilled), fullfilled_num, row_counter, to_cstring(last_rk));
}
示例8: param_get
int param_get(const char *fname, MockClient &client)
{
int err = OB_SUCCESS;
int fd = open(fname, O_RDONLY);
if (-1 == fd)
{
fprintf(stdout, "open [%s] fail errno=%u\n", fname, errno);
err = OB_ERROR;
}
else
{
struct stat st;
fstat(fd, &st);
char *buf = (char*)malloc(st.st_size);
if (NULL == buf)
{
fprintf(stdout, "malloc buf fail size=%ld\n", st.st_size);
err = OB_ERROR;
}
else
{
ssize_t __attribute__((unused)) ret = read(fd, buf, st.st_size);
int64_t pos = 0;
ObGetParam get_param;
if (OB_SUCCESS != get_param.deserialize(buf, st.st_size, pos))
{
fprintf(stdout, "deserialize get_param fail\n");
err = OB_ERROR;
}
else
{
get_param.set_is_read_consistency(false);
ObScanner scanner;
int err = client.ups_get(get_param, scanner, timeout);
fprintf(stdout, "[%s] err=%d\n", __FUNCTION__, err);
if (OB_SUCCESS == err)
{
int64_t row_counter = 0;
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo *ci = NULL;
bool is_row_changed = false;
scanner.get_cell(&ci, &is_row_changed);
fprintf(stdout, "%s\n", common::print_cellinfo(ci, "CLI_GET"));
if (is_row_changed)
{
row_counter++;
}
}
bool is_fullfilled = false;
int64_t fullfilled_num = 0;
ObRowkey last_rk;
scanner.get_last_row_key(last_rk);
scanner.get_is_req_fullfilled(is_fullfilled, fullfilled_num);
fprintf(stdout, "is_fullfilled=%s fullfilled_num=%ld row_counter=%ld last_row_key=[%s]\n",
STR_BOOL(is_fullfilled), fullfilled_num, row_counter, to_cstring(last_rk));
}
}
free(buf);
}
close(fd);
}
return err;
}
示例9: fopen
TEST(TestObScanner, add_cell)
{
ObScanner fem;
fem.set_is_req_fullfilled(true, 1011);
fem.set_data_version(170);
char buf[BUFSIZ];
int64_t pospos = 0;
fem.serialize(buf, BUFSIZ, pospos);
FILE *fd;
fd = fopen("tmptest", "w+");
fwrite(buf, 1, pospos, fd);
fclose(fd);
ObScanner os;
ObScanner ost;
/*** added by wushi ***/
int64_t fullfilled_item = 0;
int64_t tmp = 0;
bool is_fullfilled = true;
bool tmp_bool = false;
/// initialize
ASSERT_EQ(os.get_is_req_fullfilled(tmp_bool, fullfilled_item),0);
EXPECT_FALSE(tmp_bool);
ASSERT_EQ(fullfilled_item,0);
/// set fullfilled
is_fullfilled = true;
fullfilled_item = 1000;
os.set_is_req_fullfilled(is_fullfilled,fullfilled_item);
ASSERT_EQ(os.get_is_req_fullfilled(tmp_bool, tmp),0);
ASSERT_EQ(tmp_bool,is_fullfilled);
ASSERT_EQ(tmp,fullfilled_item);
/*** added by wushi ***/
ObCellInfo oci;
oci.table_name_.assign((char*)"table1", 6);
oci.row_key_.assign((char*)"row1", 4);
oci.column_name_.assign((char*)"column1", 7);
oci.value_.set_int(0xff);
ost.set_mem_size_limit(20);
ASSERT_EQ(OB_SIZE_OVERFLOW, ost.add_cell(oci));
os.set_mem_size_limit(1024 * 1024 * 2);
ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));
oci.column_name_.assign((char*)"column2", 7);
oci.value_.set_int(0xfe);
ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));
ObScannerIterator iter = os.begin();
ObCellInfo tci;
ASSERT_EQ(OB_SUCCESS, iter.get_cell(tci));
ASSERT_EQ(string("table1"), string(tci.table_name_.ptr(), tci.table_name_.length()));
ASSERT_EQ(string("row1"), string(tci.row_key_.ptr(), tci.row_key_.length()));
ASSERT_EQ(string("column1"), string(tci.column_name_.ptr(), tci.column_name_.length()));
ASSERT_EQ(OB_SUCCESS, tci.value_.get_int(tmp));
ASSERT_EQ(0xff, tmp);
iter++;
ASSERT_EQ(OB_SUCCESS, iter.get_cell(tci));
ASSERT_EQ(string("table1"), string(tci.table_name_.ptr(), tci.table_name_.length()));
ASSERT_EQ(string("row1"), string(tci.row_key_.ptr(), tci.row_key_.length()));
ASSERT_EQ(string("column2"), string(tci.column_name_.ptr(), tci.column_name_.length()));
ASSERT_EQ(OB_SUCCESS, tci.value_.get_int(tmp));
ASSERT_EQ(0xfe, tmp);
iter++;
ASSERT_EQ(true, os.end() == iter);
//ObCellInfo oci;
char row_key_buffer[1024];
oci.table_name_.assign((char*)"table1", 6);
sprintf(row_key_buffer, "row1");
oci.row_key_.assign(row_key_buffer, 4);
oci.column_name_.assign((char*)"column1", 7);
oci.value_.set_int(0xff);
ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));
oci.table_name_.assign((char*)"table1", 6);
sprintf(row_key_buffer, "row1");
oci.row_key_.assign(row_key_buffer, 4);
oci.column_name_.assign((char*)"column2", 7);
oci.value_.set_int(0xee);
os.set_mem_size_limit(20);
ASSERT_EQ(OB_SIZE_OVERFLOW, os.add_cell(oci));
os.set_mem_size_limit(1024 * 1024 * 2);
ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));
oci.table_name_.assign((char*)"table1", 6);
sprintf(row_key_buffer, "row2");
oci.row_key_.assign(row_key_buffer, 4);
//.........这里部分代码省略.........
示例10: test_helper
//.........这里部分代码省略.........
ASSERT_EQ(0, err);
err = mgr.set_schemas(schema_mgr);
ASSERT_EQ(0, err);
TestUpsTableMgrHelper test_helper(mgr);
TableMgr& table_mgr = test_helper.get_table_mgr();
table_mgr.sstable_scan_finished(10);
TableItem* active_memtable_item = table_mgr.get_active_memtable();
MemTable& active_memtable = active_memtable_item->get_memtable();
// construct multi-row mutator
static const int64_t ROW_NUM = 1;
static const int64_t COL_NUM = 10;
ObCellInfo cell_infos[ROW_NUM][COL_NUM];
char row_key_strs[ROW_NUM][50];
uint64_t table_id = 10;
// init cell infos
for (int64_t i = 0; i < ROW_NUM; ++i)
{
sprintf(row_key_strs[i], "row_key_%08ld", i);
for (int64_t j = 0; j < COL_NUM; ++j)
{
cell_infos[i][j].table_id_ = table_id;
cell_infos[i][j].row_key_.assign(row_key_strs[i], strlen(row_key_strs[i]));
cell_infos[i][j].column_id_ = j + 1;
cell_infos[i][j].value_.set_int(1000 + i * COL_NUM + j);
}
}
ObUpsMutator ups_mutator;
ObMutator &mutator = ups_mutator.get_mutator();
// add cell to array
for (int64_t i = 0; i < ROW_NUM; ++i)
{
for (int64_t j = 0; j < COL_NUM; ++j)
{
ObMutatorCellInfo mutator_cell;
mutator_cell.cell_info = cell_infos[i][j];
mutator_cell.op_type.set_ext(ObActionFlag::OP_UPDATE);
err = mutator.add_cell(mutator_cell);
EXPECT_EQ(0, err);
}
}
// write row to active memtable
MemTableTransHandle write_handle;
err = active_memtable.start_transaction(WRITE_TRANSACTION, write_handle);
ASSERT_EQ(0, err);
ups_mutator.set_mutate_timestamp(0);
err = active_memtable.set(write_handle, ups_mutator);
EXPECT_EQ(0, err);
err = active_memtable.end_transaction(write_handle);
ASSERT_EQ(0, err);
/*
ObString text;
text.assign("/tmp", strlen("/tmp"));
active_memtable.dump2text(text);
*/
for (int64_t i = 0; i < ROW_NUM; ++i)
{
ObScanner scanner;
ObGetParam get_param;
//get_param.set_timestamp(version);
ObVersionRange version_range;
//version_range.start_version_ = version;
//version_range.end_version_ = version;
version_range.start_version_ = 2;
version_range.end_version_ = 2;
version_range.border_flag_.set_inclusive_start();
version_range.border_flag_.set_inclusive_end();
get_param.set_version_range(version_range);
for (int64_t j = 0; j < COL_NUM; ++j)
{
get_param.add_cell(cell_infos[i][j]);
}
int64_t count = 0;
err = mgr.get(get_param, scanner, tbsys::CTimeUtil::getTime(), 2000000000 * 1000L * 1000L);
EXPECT_EQ(0, err);
// check result
count = 0;
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo* p_cell = NULL;
scanner.get_cell(&p_cell);
ASSERT_TRUE(p_cell != NULL);
ObCellInfo expected = cell_infos[count / COL_NUM + i][count % COL_NUM];
check_cell(expected, *p_cell);
++count;
}
EXPECT_EQ(COL_NUM, count);
}
}
示例11: get_cur_seed_
int64_t MutatorBuilder::get_cur_seed_(const seed_map_t &seed_map, const ObSchema &schema, const ObString &row_key, const bool using_id)
{
int64_t cur_seed = 0;
TEKey te_key;
te_key.table_id = schema.get_table_id();
te_key.row_key = row_key;
int hash_ret = 0;
if (HASH_EXIST != (hash_ret = seed_map.get(te_key, cur_seed)))
{
ObGetParam get_param;
ObScanner scanner;
ObCellInfo cell_info;
cell_info.row_key_ = row_key;
if (using_id)
{
cell_info.table_id_ = schema.get_table_id();
cell_info.column_id_ = SEED_COLUMN_ID;
}
else
{
cell_info.table_name_.assign_ptr(const_cast<char*>(schema.get_table_name()), static_cast<int32_t>(strlen(schema.get_table_name())));
cell_info.column_name_.assign_ptr((char*)SEED_COLUMN_NAME, static_cast<int32_t>(strlen(SEED_COLUMN_NAME)));
}
get_param.add_cell(cell_info);
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);
if (OB_SUCCESS == client_.get(get_param, scanner))
{
CellinfoBuilder::result_set_t result_set;
MemTank mem_tank;
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo *ci = NULL;
if (OB_SUCCESS != scanner.get_cell(&ci))
{
break;
}
if (!using_id)
{
::trans_name2id(*ci, schema);
}
ObCellInfo *new_ci = copy_cell(mem_tank, ci);
CellinfoBuilder::merge_obj(new_ci, result_set);
}
if (0 != result_set.size())
{
ObCellInfo *ret_ci = NULL;
result_set.get(SEED_COLUMN_ID, ret_ci);
if (NULL != ret_ci)
{
ret_ci->value_.get_int(cur_seed);
}
TBSYS_LOG(DEBUG, "seed get from oceanbase %s", print_cellinfo(ret_ci));
}
}
else
{
abort();
}
}
if (0 == cur_seed)
{
cur_seed = SEED_START;
TBSYS_LOG(DEBUG, "first seed from cur_seed=%ld row_key=[%.*s]", cur_seed, row_key.length(), row_key.ptr());
}
else
{
cur_seed += 1;
}
TBSYS_LOG(DEBUG, "get cur_seed=%ld hash_ret=%d row_key=[%.*s]", cur_seed, hash_ret, row_key.length(), row_key.ptr());
return cur_seed;
}
示例12: query_prefix_meta_
int64_t MutatorBuilder::query_prefix_meta_(const ObSchema &schema, const bool using_id, const int64_t prefix_start, const char *column_name)
{
int64_t ret = 0;
ObGetParam get_param;
ObScanner scanner;
ObCellInfo cell_info;
if (using_id)
{
cell_info.table_id_ = schema.get_table_id();
cell_info.column_id_ = schema.find_column_info(column_name)->get_id();
}
else
{
cell_info.table_name_.assign_ptr(const_cast<char*>(schema.get_table_name()), static_cast<int32_t>(strlen(schema.get_table_name())));
cell_info.column_name_.assign_ptr(const_cast<char*>(column_name), static_cast<int32_t>(strlen(column_name)));
}
char rowkey_info_buffer[1024];
sprintf(rowkey_info_buffer, "%s%020ld", ROWKEY_INFO_ROWKEY, prefix_start);
cell_info.row_key_.assign_ptr(rowkey_info_buffer, static_cast<int32_t>(strlen(rowkey_info_buffer)));
get_param.add_cell(cell_info);
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);
if (OB_SUCCESS == (ret = client_.get(get_param, scanner)))
{
CellinfoBuilder::result_set_t result_set;
::MemTank mem_tank;
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo *ci = NULL;
if (OB_SUCCESS != scanner.get_cell(&ci))
{
break;
}
if (!using_id)
{
::trans_name2id(*ci, schema);
}
ObCellInfo *new_ci = copy_cell(mem_tank, ci);
CellinfoBuilder::merge_obj(new_ci, result_set);
}
if (0 != result_set.size())
{
ObCellInfo *ret_ci = NULL;
result_set.get(schema.find_column_info(column_name)->get_id(), ret_ci);
if (NULL != ret_ci)
{
ret_ci->value_.get_int(ret);
}
}
}
else
{
abort();
}
return ret;
}
示例13: scan_check_all
void scan_check_all(MutatorBuilder &mb, MockClient &client, const int64_t table_start_version, const bool using_id, const bool check)
{
for (int64_t i = 0; i < mb.get_schema_num(); ++i)
{
ObScanParam scan_param;
prepare_scan_param(scan_param, mb.get_schema(i), table_start_version, using_id);
int ret = OB_SUCCESS;
bool is_fullfilled = false;
int64_t fullfilled_item_num = 0;
RowChecker rc;
int64_t row_counter = 0;
ObScanner scanner;
while (!is_fullfilled
&& OB_SUCCESS == ret)
{
int64_t timeu = tbsys::CTimeUtil::getTime();
ret = client.ups_scan(scan_param, scanner, TIMEOUT_MS);
TBSYS_LOG(INFO, "scan ret=%d timeu=%ld", ret, tbsys::CTimeUtil::getTime() - timeu);
if (check
&& OB_SUCCESS == ret)
{
while (OB_SUCCESS == scanner.next_cell())
{
ObCellInfo *ci = NULL;
bool is_row_changed = false;
if (OB_SUCCESS == scanner.get_cell(&ci, &is_row_changed))
{
if (!using_id)
{
trans_name2id(*ci, mb.get_schema(i));
}
if (is_row_changed && 0 != rc.cell_num())
{
std::string row_key_str(rc.get_cur_rowkey().ptr(), 0, rc.get_cur_rowkey().length());
//fprintf(stderr, "[%.*s] ", rc.get_cur_rowkey().length(), rc.get_cur_rowkey().ptr());
bool get_row_bret = get_check_row(mb.get_schema(i), rc.get_cur_rowkey(), mb.get_cellinfo_builder(i), client, table_start_version, using_id);
//fprintf(stderr, "[get_row check_ret=%d] ", bret);
bool cell_info_bret = rc.check_row(mb.get_cellinfo_builder(i), mb.get_schema(i));
//fprintf(stderr, "[cell_info check_ret=%d]\n", bret);
TBSYS_LOG(INFO, "[%s] [get_row check_ret=%d] [cell_info check_ret=%d]", row_key_str.c_str(), get_row_bret, cell_info_bret);
}
if (is_row_changed
&& 0 != rc.rowkey_num()
&& rc.is_prefix_changed(ci->row_key_))
{
std::string row_key_str(rc.get_last_rowkey().ptr(), 0, rc.get_last_rowkey().length());
//fprintf(stderr, "[%.*s] ", rc.get_last_rowkey().length(), rc.get_last_rowkey().ptr());
bool bret = rc.check_rowkey(mb.get_rowkey_builder(i));
//fprintf(stderr, "row_key check_ret=%d\n", bret);
TBSYS_LOG(INFO, "[%s] [row_key check_ret=%d]", row_key_str.c_str(), bret);
}
rc.add_cell(ci);
if (is_row_changed)
{
rc.add_rowkey(ci->row_key_);
row_counter++;
}
}
}
if (0 != rc.cell_num())
{
std::string row_key_str(rc.get_cur_rowkey().ptr(), 0, rc.get_cur_rowkey().length());
//fprintf(stderr, "[%.*s] ", rc.get_cur_rowkey().length(), rc.get_cur_rowkey().ptr());
bool get_row_bret = get_check_row(mb.get_schema(i), rc.get_cur_rowkey(), mb.get_cellinfo_builder(i), client, table_start_version, using_id);
//fprintf(stderr, "[get_row check_ret=%d] ", bret);
bool cell_info_bret = rc.check_row(mb.get_cellinfo_builder(i), mb.get_schema(i));
//fprintf(stderr, "[cell_info check_ret=%d]\n", bret);
TBSYS_LOG(INFO, "[%s] [get_row check_ret=%d] [cell_info check_ret=%d]", row_key_str.c_str(), get_row_bret, cell_info_bret);
}
}
scanner.get_is_req_fullfilled(is_fullfilled, fullfilled_item_num);
ObRange *range = const_cast<ObRange*>(scan_param.get_range());
scanner.get_last_row_key(range->start_key_);
range->border_flag_.unset_min_value();
range->border_flag_.unset_inclusive_start();
}
if (check
&& 0 != rc.rowkey_num())
{
std::string row_key_str(rc.get_last_rowkey().ptr(), 0, rc.get_last_rowkey().length());
//fprintf(stderr, "[%.*s] ", rc.get_last_rowkey().length(), rc.get_last_rowkey().ptr());
bool bret = rc.check_rowkey(mb.get_rowkey_builder(i));
//fprintf(stderr, "row_key check_ret=%d\n", bret);
TBSYS_LOG(INFO, "[%s] [row_key check_ret=%d]", row_key_str.c_str(), bret);
}
TBSYS_LOG(INFO, "table_id=%lu row_counter=%ld", mb.get_schema(i).get_table_id(), row_counter);
}
}
示例14: check_result
bool check_result(const ObScanParam &scan_param, ObScanner &ob_scanner,
ObFinalResult & local_result)
{
int err = OB_SUCCESS;
bool res = true;
ObScanner local_scanner;
ObCellInfo *ob_cell = NULL;
ObCellInfo *local_cell = NULL;
err = local_result.scan(scan_param,local_scanner);
if (OB_SUCCESS != err)
{
TBSYS_LOG(WARN,"fail to scan local result");
}
int64_t row_number = 0;
bool ob_end = false;
ObString rowkey;
while (OB_SUCCESS == err)
{
for (int64_t scan_idx = 0; scan_idx < scan_param.get_column_name_size(); scan_idx ++)
{
if (OB_SUCCESS == err)
{
err = ob_scanner.next_cell();
}
if (OB_ITER_END == err && scan_idx == 0)
{
ob_end = true;
err = OB_SUCCESS;
}
else if (OB_SUCCESS == err)
{
err = ob_scanner.get_cell(&ob_cell);
}
if (OB_SUCCESS != err)
{
TBSYS_LOG(WARN,"fail to get cell from ob result [row_idx:%lld,idx:%lld]",
row_number, scan_idx);
}
if (OB_SUCCESS == err)
{
err = local_scanner.next_cell();
if (ob_end && OB_ITER_END != err)
{
TBSYS_LOG(WARN,"local result return more cells than ob result");
err = OB_INVALID_ARGUMENT;
}
if ( !ob_end && OB_ITER_END == err)
{
TBSYS_LOG(WARN,"ob result return more cells than local result");
err = OB_INVALID_ARGUMENT;
}
if (ob_end && OB_ITER_END == err)
{
err = OB_ITER_END;
break;
}
if (OB_SUCCESS == err)
{
err = local_scanner.get_cell(&local_cell);
}
if (OB_SUCCESS != err)
{
TBSYS_LOG(WARN,"fail to get cell from local result [row_idx:%lld,idx:%lld]",
row_number, scan_idx);
}
}
if (OB_SUCCESS == err)
{
if (0 == scan_idx)
{
rowkey = ob_cell->row_key_;
}
/// check ob result
if (ob_cell->table_name_ != scan_param.get_table_name())
{
TBSYS_LOG(WARN,"ob result table name error [row_idx:%lld,idx:%lld,ob.table_name_:%.*s,"
"param.table_name_:%.*s]", row_number, scan_idx,ob_cell->table_name_.length(),
ob_cell->table_name_.ptr(), scan_param.get_table_name().length(),
scan_param.get_table_name().ptr());
err = OB_INVALID_ARGUMENT;
}
if (ob_cell->column_name_ != scan_param.get_column_name()[scan_idx])
{
TBSYS_LOG(WARN,"ob result rowkey error [row_idx:%lld,idx:%lld,ob.column_name_:%.*s,"
"param.column_name_:%.*s]", row_number, scan_idx,ob_cell->column_name_.length(),
ob_cell->column_name_.ptr(), scan_param.get_column_name()[scan_idx].length(),
scan_param.get_column_name()[scan_idx].ptr());
err = OB_INVALID_ARGUMENT;
}
/// check local result
if (local_cell->table_name_ != scan_param.get_table_name())
{
TBSYS_LOG(WARN,"ob result table name error [row_idx:%lld,idx:%lld,ob.table_name_:%.*s,"
"param.table_name_:%.*s]", row_number, scan_idx,local_cell->table_name_.length(),
local_cell->table_name_.ptr(), scan_param.get_table_name().length(),
scan_param.get_table_name().ptr());
err = OB_INVALID_ARGUMENT;
}
//.........这里部分代码省略.........
示例15: check_result
bool GetSingleRowAllColumn::check_result(const uint32_t min_key_include, const uint32_t max_key_include, ObScanner &result,
void *arg)
{
bool res = true;
int err = OB_SUCCESS;
UNUSED(min_key_include);
UNUSED(max_key_include);
ObGetParam *get_param = reinterpret_cast<ObGetParam*>(arg);
uint32_t big_endian_rowkey_val = *(uint32_t*)(((*get_param)[0])->row_key_.ptr());
uint32_t rowkey_val = ntohl(big_endian_rowkey_val);
ObCellInfo target_cell;
target_cell.row_key_.assign((char*)&big_endian_rowkey_val, sizeof(big_endian_rowkey_val));
target_cell.table_name_ = msolap::target_table_name;
if (result.get_cell_num() != msolap::max_column_id - msolap::min_column_id + 1)
{
TBSYS_LOG(WARN,"result cell number error [got:%ld,expcted:%ld]", result.get_cell_num(),
msolap::max_column_id - msolap::min_column_id + 1);
err = OB_ERR_UNEXPECTED;
}
int64_t got_cell_num = 0;
ObCellInfo *cur_cell = NULL;
int64_t intval = 0;
for (got_cell_num = 0; (got_cell_num < result.get_cell_num()) && (OB_SUCCESS == err); got_cell_num++)
{
if (OB_SUCCESS != (err = result.next_cell()))
{
TBSYS_LOG(WARN,"fail to get next cell from result [err:%d]", err);
}
if ((OB_SUCCESS == err) && (OB_SUCCESS != (err = result.get_cell(&cur_cell))))
{
TBSYS_LOG(WARN,"fail to get next cell from result [err:%d]", err);
}
if ((OB_SUCCESS == err)
&& ((cur_cell->table_name_ != msolap::target_table_name)
|| (cur_cell->row_key_ != target_cell.row_key_)
|| (cur_cell->column_name_.length() != 1)
|| (OB_SUCCESS != cur_cell->value_.get_int(intval))))
{
TBSYS_LOG(WARN,"cell content error");
err = OB_ERR_UNEXPECTED;
}
if ((OB_SUCCESS == err) && ((cur_cell->column_name_.ptr()[0] < 'a') || (cur_cell->column_name_.ptr()[0] > 'z')))
{
TBSYS_LOG(WARN,"cell content error");
err = OB_ERR_UNEXPECTED;
}
if (OB_SUCCESS == err)
{
int64_t expect_intval = 0;
char c_name = cur_cell->column_name_.ptr()[0];
switch (c_name)
{
case 'a':
case 'b':
case 'c':
case 'd':
expect_intval = ((unsigned char*)&big_endian_rowkey_val)[c_name - 'a'];
break;
default:
expect_intval = rowkey_val;
}
if (expect_intval != intval)
{
TBSYS_LOG(WARN,"intvalue error [column_name:%c,expect_val:%ld,got_val:%ld,rowkey:%u]", c_name,
expect_intval, intval, rowkey_val);
err = OB_ERR_UNEXPECTED;
}
}
}
if ((OB_SUCCESS == err) && (got_cell_num != msolap::max_column_id - msolap::min_column_id + 1))
{
TBSYS_LOG(WARN,"fail to get enough cells from result");
err = OB_ERR_UNEXPECTED;
}
if ((OB_SUCCESS == err) && (OB_ITER_END != result.next_cell()))
{
TBSYS_LOG(WARN,"fail to get enough cells from result");
err = OB_ERR_UNEXPECTED;
}
if (OB_SUCCESS != err)
{
res = false;
}
return res;
}