本文整理汇总了C++中ObScanner::rollback方法的典型用法代码示例。如果您正苦于以下问题:C++ ObScanner::rollback方法的具体用法?C++ ObScanner::rollback怎么用?C++ ObScanner::rollback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObScanner
的用法示例。
在下文中一共展示了ObScanner::rollback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fill_compact_data
int ObGetScanProxy::fill_compact_data(ObIterator& iterator,ObScanner& scanner)
{
int ret = OB_SUCCESS;
ObCellInfo* cell = NULL;
bool is_row_changed = false;
while (OB_SUCCESS == (ret = iterator.next_cell()))
{
ret = iterator.get_cell(&cell,&is_row_changed);
if (OB_SUCCESS != ret || NULL == cell)
{
TBSYS_LOG(WARN, "failed to get cell, cell=%p, err=%d", cell, ret);
}
else
{
ret = scanner.add_cell(*cell, false, is_row_changed);
if (OB_SIZE_OVERFLOW == ret)
{
//TODO
TBSYS_LOG(INFO, "ObScanner size full, cannot add any cell.");
scanner.rollback();
ret = OB_SUCCESS;
break;
}
else if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "failed to add cell to scanner, ret=%d", ret);
}
}
if (OB_SUCCESS != ret)
{
break;
}
}
if (OB_ITER_END == ret)
{
ret = OB_SUCCESS;
}
else if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "retor occurs while iterating, ret=%d", ret);
}
return ret;
}
示例2: fill_result
int ObMergerGetRequest::fill_result(ObScanner & scanner, ObGetParam &org_param,
bool &got_all_result)
{
int err = OB_SUCCESS;
ObInnerCellInfo *cur_cell = NULL;
bool size_over_flow = false;
bool row_changed = false;
int64_t got_cell_count = 0;
if (!sealed_)
{
TBSYS_LOG(WARN,"request not finished yet");
err = OB_INVALID_ARGUMENT;
}
for (int64_t i = 0; (i < cur_row_cell_cnt_) && (OB_SUCCESS == err); i ++, poped_cell_count_ ++)
{
if ((OB_SUCCESS != (err = scanner.add_cell(row_cells_[i]))))
{
TBSYS_LOG(WARN,"fail to add cell to scanner [err:%d]", err);
}
}
while ((OB_SUCCESS == err) && (!size_over_flow))
{
if ((OB_SUCCESS != (err = merger_operator_.next_cell())) && (OB_ITER_END != err))
{
TBSYS_LOG(WARN,"fail to call next_cell [err:%d]", err);
}
if ((OB_SUCCESS == err) && (OB_SUCCESS != (err = merger_operator_.get_cell(&cur_cell, &row_changed))))
{
TBSYS_LOG(WARN,"fail to get cell from ObGetMerger [err:%d]", err);
}
if (OB_SUCCESS == err)
{
got_cell_count ++;
}
if ((OB_SUCCESS == err) && row_changed)
{
cur_row_cell_cnt_ = 0;
last_not_exist_cell_.table_id_ = OB_INVALID_ID;
}
if ((OB_SUCCESS == err)
&& ((cur_cell->value_.get_ext() == ObActionFlag::OP_ROW_DOES_NOT_EXIST)
|| (cur_cell->value_.get_ext() == ObActionFlag::OP_DEL_TABLE)))
{
if ((OB_INVALID_ID != last_not_exist_cell_.table_id_) && (last_not_exist_cell_.table_id_ == cur_cell->table_id_)
&& (last_not_exist_cell_.row_key_ == cur_cell->row_key_))
{
poped_cell_count_ ++;
continue ;
}
else
{
last_not_exist_cell_ = *cur_cell;
}
}
if ((OB_SUCCESS == err) && (cur_row_cell_cnt_ >= MAX_ROW_COLUMN_COUNT))
{
TBSYS_LOG(WARN,"row cell count is too large [cur_row_cell_cnt_:%ld, MAX_ROW_COLUMN_COUNT:%ld]",
cur_row_cell_cnt_, MAX_ROW_COLUMN_COUNT);
//err = OB_ARRAY_OUT_OF_RANGE;
cur_row_cell_cnt_ = 0;
}
if (OB_SUCCESS == err)
{
row_cells_[cur_row_cell_cnt_].table_id_ = OB_INVALID_ID;
row_cells_[cur_row_cell_cnt_].table_name_ = org_param[poped_cell_count_]->table_name_;
row_cells_[cur_row_cell_cnt_].column_name_ = org_param[poped_cell_count_]->column_name_;
row_cells_[cur_row_cell_cnt_].column_id_ = OB_INVALID_ID;
row_cells_[cur_row_cell_cnt_].row_key_ = cur_cell->row_key_;
row_cells_[cur_row_cell_cnt_].value_ = cur_cell->value_;
++cur_row_cell_cnt_;
}
if (OB_SUCCESS == err)
{
if ((OB_SUCCESS != (err = scanner.add_cell(row_cells_[cur_row_cell_cnt_ - 1]))) && (OB_SIZE_OVERFLOW != err))
{
TBSYS_LOG(WARN,"fail to add cell to result [err:%d]", err);
}
else if (OB_SIZE_OVERFLOW == err)
{
if (OB_SUCCESS != (err = scanner.rollback()))
{
TBSYS_LOG(WARN,"fail to rollback ObScanner [err:%d]", err);
}
else
{
size_over_flow = true;
poped_cell_count_ -= cur_row_cell_cnt_ - 1;
got_cell_count -= cur_row_cell_cnt_;
}
}
else if (OB_SUCCESS == err)
{
poped_cell_count_ ++;
}
}
}
if (OB_ITER_END == err)
{
//.........这里部分代码省略.........
示例3: fopen
//.........这里部分代码省略.........
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);
oci.column_name_.assign((char*)"column1", 7);
oci.value_.set_int(0xdd);
ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));
oci.table_name_.assign((char*)"table2", 6);
sprintf(row_key_buffer, "row2");
oci.row_key_.assign(row_key_buffer, 4);
oci.column_name_.assign((char*)"column1", 7);
oci.value_.set_int(0xcc);
ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));
oci.table_name_.assign((char*)"table3", 6);
sprintf(row_key_buffer, "row2");
oci.row_key_.assign(row_key_buffer, 4);
oci.column_name_.assign((char*)"column1", 7);
oci.value_.set_int(0xbb);
ASSERT_EQ(OB_SUCCESS, os.add_cell(oci));
fprintf(stdout, "size=%ld\n", os.get_serialize_size());
char buffer[2048];
int64_t pos = 0;
ASSERT_EQ(OB_SUCCESS, os.serialize(buffer, 1024, pos));
ASSERT_EQ(pos, os.get_serialize_size());
fd = fopen("./test.data.before_rollback", "w+");
fwrite(buffer, 1, 1024, fd);
fclose(fd);
for (iter = os.begin(); iter != os.end(); iter++)
{
ObCellInfo ci;
ASSERT_EQ(OB_SUCCESS, iter.get_cell(ci));
fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s]\n",
ci.table_name_.length(), ci.table_name_.ptr(),
ci.row_key_.length(), ci.row_key_.ptr(),
ci.column_name_.length(), ci.column_name_.ptr());
}
fprintf(stdout, "==============================\n");
while (OB_SUCCESS == os.next_cell())
{
ObCellInfo *ci = NULL;
bool is_row_changed;
ASSERT_EQ(OB_SUCCESS, os.get_cell(&ci, &is_row_changed));
fprintf(stdout, "table_name=[%.*s] row_key=[%.*s] column_name=[%.*s] "
"table_id=[%lu] column_id=[%lu] row_changed=[%d]\n",
ci->table_name_.length(), ci->table_name_.ptr(),
ci->row_key_.length(), ci->row_key_.ptr(),
ci->column_name_.length(),ci->column_name_.ptr(),
ci->table_id_, ci->column_id_, is_row_changed);
}
os.reset_iter();
fprintf(stdout, "==============================\n");
ASSERT_EQ(OB_SUCCESS, os.rollback());
fprintf(stdout, "size=%ld\n", os.get_serialize_size());
pos = 0;
示例4: buf
//.........这里部分代码省略.........
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)
{
scanner.rollback();
}
for (int i = 0; i < j; i++)
{
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());
buf.length() = 0;
scanner.serialize(buf.ptre(), buf.capacity(), buf.length());
printf("%ld\n", buf.length());
dscanner.reset();
pos = 0;
dscanner.deserialize(buf.ptre(), buf.length(), pos);
printf("row_num=%ld\n", dscanner.get_row_num());
for (int i = 0; i < j; i++)
{
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());
}