本文整理汇总了C++中ObScanner::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ ObScanner::clear方法的具体用法?C++ ObScanner::clear怎么用?C++ ObScanner::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObScanner
的用法示例。
在下文中一共展示了ObScanner::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scan
int ObRootServerRpcStub::scan(const ObServer & server, const int64_t timeout,
const ObScanParam & param, ObScanner & result)
{
ObDataBuffer data_buff;
int ret = get_frame_buffer(data_buff);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "check get rpc buffer failed:ret[%d]", ret);
}
else
{
// step 1. serialize ObGetParam to the data_buff
ret = param.serialize(data_buff.get_data(), data_buff.get_capacity(),
data_buff.get_position());
if (OB_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "serialize get param failed:ret[%d]", ret);
}
}
// step 2. send request for get data
if (OB_SUCCESS == ret)
{
ret = rpc_frame_->send_request(server, OB_SCAN_REQUEST, DEFAULT_VERSION,
timeout, data_buff);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(WARN, "get data failed from server:ret[%d]", ret);
}
}
// step 3. deserialize the response result
int64_t pos = 0;
if (OB_SUCCESS == ret)
{
ObResultCode result_code;
ret = result_code.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "deserialize result failed:pos[%ld], ret[%d]", pos, ret);
}
else if ((ret = result_code.result_code_) != OB_SUCCESS)
{
TBSYS_LOG(ERROR,"scan failed,ret[%d]",ret);
}
}
// step 4. deserialize the scanner
if (OB_SUCCESS == ret)
{
result.clear();
ret = result.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "deserialize scanner from buff failed:pos[%ld], ret[%d]", pos, ret);
}
}
return ret;
}
示例2: buf
TEST(TestObScanner, get_row)
{
ObScanner scanner;
const int table_num = 10;
const int row_num = 20;
const int column_num = 10;
buffer table_name[table_num];
buffer row_key[row_num];
buffer column_name[column_num];
for (int i = 0; i < table_num; i++)
{
table_name[i].assigne("T").appende(i);
}
for (int i = 0; i < row_num; i++)
{
row_key[i].assigne("R").appende(i);
}
for (int i = 0; i < column_num; i++)
{
column_name[i].assigne("C").appende(i);
}
for (int i = 0; i < table_num; i++)
{
for (int j = 0; j < row_num; j++)
{
for (int k = 0; k < column_num; k++)
{
ObCellInfo cell;
cell.table_name_ = table_name[i].get_obstring();
cell.row_key_ = row_key[j].get_obstring();
cell.column_name_ = column_name[k].get_obstring();
cell.value_.set_int(1);
scanner.add_cell(cell);
}
}
}
ObScanner::RowIterator it = scanner.row_begin();
ASSERT_EQ(it == scanner.row_begin(), true);
for (int i = 0; i < table_num; i++)
{
for (int j = 0; j < row_num; j++)
{
ObCellInfo *row;
int64_t num = 0;
ASSERT_EQ(OB_SUCCESS, scanner.next_row());
ASSERT_EQ(OB_SUCCESS, scanner.get_row(&row, &num));
ASSERT_EQ(column_num, num);
}
}
ASSERT_EQ(OB_ITER_END, scanner.next_row());
buffer buf(1 << 21);
scanner.serialize(buf.ptre(), buf.capacity(), buf.length());
printf("%ld\n", buf.length());
ObScanner dscanner;
int64_t pos = 0;
dscanner.deserialize(buf.ptre(), buf.length(), pos);
for (int i = 0; i < table_num; i++)
{
for (int j = 0; j < row_num; j++)
{
ObCellInfo *row;
int64_t num = 0;
ASSERT_EQ(OB_SUCCESS, dscanner.next_row());
ASSERT_EQ(OB_SUCCESS, dscanner.get_row(&row, &num));
ASSERT_EQ(column_num, num);
}
}
ASSERT_EQ(OB_ITER_END, dscanner.next_row());
scanner.clear();
scanner.set_mem_size_limit(256);
int j = 0, k = 0;
int err = OB_SUCCESS;
for (; j < row_num; j++)
{
for (k = 0; k < column_num; k++)
{
ObCellInfo cell;
cell.table_name_ = table_name[0].get_obstring();
cell.row_key_ = row_key[j].get_obstring();
cell.column_name_ = column_name[k].get_obstring();
cell.value_.set_int(1);
if (OB_SUCCESS != (err = scanner.add_cell(cell)))
{
break;
}
}
if (OB_SUCCESS != err)
{
break;
}
}
if (OB_SUCCESS != err)
{
//.........这里部分代码省略.........