本文整理汇总了C++中ObRow类的典型用法代码示例。如果您正苦于以下问题:C++ ObRow类的具体用法?C++ ObRow怎么用?C++ ObRow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObRow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_values
void build_values(const int64_t row_count, ObRowDesc &row_desc, ObExprValues &values1, ObValues &values2)
{
for (int64_t i = 0; i < row_count; i++)
{
ObRow row;
row.set_row_desc(row_desc);
for (int64_t j = 0; j < row_desc.get_column_num(); j++)
{
uint64_t table_id = OB_INVALID_ID;
uint64_t column_id = OB_INVALID_ID;
row_desc.get_tid_cid(j, table_id, column_id);
ObObj obj;
obj.set_int(i + j);
row.set_cell(table_id, column_id, obj);
ObSqlExpression se;
se.set_tid_cid(table_id, column_id);
ExprItem ei;
ei.type_ = T_INT;
ei.value_.int_ = i + j;
se.add_expr_item(ei);
//ei.type_ = T_REF_COLUMN;
//ei.value_.cell_.tid = table_id;
//ei.value_.cell_.cid = column_id;
//se.add_expr_item(ei);
se.add_expr_item_end();
values1.add_value(se);
}
//values1.add_values(row);
values2.add_values(row);
}
}
示例2: TEST_F
TEST_F(ObRowUtilTest, basic_test1)
{
char buf[1024];
ObCompactCellWriter cell_writer;
OK(cell_writer.init(buf, 1024, SPARSE));
ObObj value;
ObRowDesc row_desc;
for(int64_t i=0;i<10;i++)
{
row_desc.add_column_desc(TABLE_ID, i);
value.set_int(i);
OK(cell_writer.append(i, value));
}
OK(cell_writer.row_finish());
ObString compact_row;
compact_row.assign_ptr(cell_writer.get_buf(), (int32_t)cell_writer.size());
ObRow row;
row.set_row_desc(row_desc);
OK(ObRowUtil::convert(compact_row, row));
const ObObj *cell = NULL;
uint64_t column_id = OB_INVALID_ID;
uint64_t table_id = OB_INVALID_ID;
int64_t int_value = 0;
for(int64_t i=0;i<10;i++)
{
OK(row.raw_get_cell(i, cell, table_id, column_id));
cell->get_int(int_value);
ASSERT_EQ(i, int_value);
}
}
示例3: equal
bool equal(const ObRow &r1, const ObRow &r2)
{
bool bret = false;
const ObRowDesc *rd1 = r1.get_row_desc();
const ObRowDesc *rd2 = r2.get_row_desc();
if (equal(*rd1, *rd2))
{
bret = true;
for (int64_t i = 0; i < rd1->get_column_num(); i++)
{
const ObObj *c1 = NULL;
uint64_t tid1 = OB_INVALID_ID;
uint64_t cid1 = OB_INVALID_ID;
const ObObj *c2 = NULL;
uint64_t tid2 = OB_INVALID_ID;
uint64_t cid2 = OB_INVALID_ID;
r1.raw_get_cell(i, c1, tid1, cid1);
r2.raw_get_cell(i, c2, tid2, cid2);
if (*c1 != *c2
|| tid1 != tid2
|| cid1 != cid2)
{
bret = false;
break;
}
}
}
return bret;
}
示例4: TEST_F
TEST_F(ObTabletJoinTest, get_right_table_rowkey)
{
ObRowDesc row_desc;
row_desc.add_column_desc(LEFT_TABLE_ID, 1);
const char *rowkey_str = "oceanbase";
ObString row_key_str;
row_key_str.assign_ptr(const_cast<char *>(rowkey_str), (int32_t)strlen(rowkey_str));
ObObj row_key_obj;
row_key_obj.set_varchar(row_key_str);
ObRowkey row_key;
row_key.assign(&row_key_obj, 1);
ObObj value;
value.set_varchar(row_key_str);
ObRow row;
row.set_row_desc(row_desc);
row.raw_set_cell(0, value);
ObObj rowkey_obj[OB_MAX_ROWKEY_COLUMN_NUMBER];
ObRowkey rowkey2;
ObTabletCacheJoin tablet_join;
tablet_join.set_table_join_info(tablet_join_info_);
OK(tablet_join.get_right_table_rowkey(row, rowkey2, rowkey_obj));
ASSERT_TRUE(row_key == rowkey2);
}
示例5: write_row
int ObMultipleScanMerge::write_row(ObRow &row)
{
int ret = OB_SUCCESS;
const ObRowDesc *row_desc = NULL;
const ObObj *cell = NULL;
ObObj value;
uint64_t table_id = OB_INVALID_ID;
uint64_t column_id = OB_INVALID_ID;
row_desc = row.get_row_desc();
if (NULL == row_desc)
{
ret = OB_INVALID_ARGUMENT;
TBSYS_LOG(WARN, "row_desc is null");
}
for (int64_t i = row_desc->get_rowkey_cell_count(); OB_SUCCESS == ret && i < row.get_column_num(); i ++)
{
if (OB_SUCCESS != (ret = row.raw_get_cell(i, cell, table_id, column_id) ))
{
TBSYS_LOG(WARN, "fail to get cell:ret[%d]", ret);
}
else if (OB_SUCCESS != (ret = ob_write_obj(allocator_, *cell, value) ))
{
TBSYS_LOG(WARN, "fail to write obj:ret[%d]", ret);
}
else if (OB_SUCCESS != (ret = row.raw_set_cell(i, value) ))
{
TBSYS_LOG(WARN, "fail to set cell:ret[%d]", ret);
}
}
return ret;
}
示例6: is_same_group
// if there is no group columns, is_same_group returns true
int ObMergeGroupBy::is_same_group(const ObRow &row1, const ObRow &row2, bool &result)
{
int ret = OB_SUCCESS;
result = true;
const ObObj *cell1 = NULL;
const ObObj *cell2 = NULL;
for (int64_t i = 0; i < group_columns_.count(); ++i)
{
const ObGroupColumn &group_col = group_columns_.at(i);
if (OB_SUCCESS != (ret = row1.get_cell(group_col.table_id_, group_col.column_id_, cell1)))
{
TBSYS_LOG(WARN, "failed to get cell, err=%d tid=%lu cid=%lu",
ret, group_col.table_id_, group_col.column_id_);
break;
}
else if (OB_SUCCESS != (ret = row2.get_cell(group_col.table_id_, group_col.column_id_, cell2)))
{
TBSYS_LOG(WARN, "failed to get cell, err=%d tid=%lu cid=%lu",
ret, group_col.table_id_, group_col.column_id_);
break;
}
else if (*cell1 != *cell2)
{
result = false;
break;
}
} // end for
return ret;
}
示例7: TEST_F
TEST_F(ObRowStoreTest, basic_test)
{
ObRowStore row_store;
int64_t cur_size_counter = 0;
ObRowDesc row_desc;
row_desc.add_column_desc(TABLE_ID, 1);
row_desc.add_column_desc(TABLE_ID, 2);
row_desc.add_column_desc(TABLE_ID, 3);
row_desc.add_column_desc(TABLE_ID, 4);
row_desc.add_column_desc(TABLE_ID, 5);
ObRow row;
row.set_row_desc(row_desc);
#define ADD_ROW(num1, num2, num3, num4, num5) \
row.set_cell(TABLE_ID, 1, gen_int_obj(num1, false)); \
row.set_cell(TABLE_ID, 2, gen_int_obj(num2, false)); \
row.set_cell(TABLE_ID, 3, gen_int_obj(num3, false)); \
row.set_cell(TABLE_ID, 4, gen_int_obj(num4, false)); \
row.set_cell(TABLE_ID, 5, gen_int_obj(num5, false)); \
row_store.add_row(row, cur_size_counter);
ObRow get_row;
get_row.set_row_desc(row_desc);
#define CHECK_CELL(column_id, num) \
{ \
const ObObj *cell = NULL; \
int64_t int_value = 0; \
get_row.get_cell(TABLE_ID, column_id, cell); \
cell->get_int(int_value); \
ASSERT_EQ(num, int_value); \
}
#define CHECK_ROW(num1, num2, num3, num4, num5) \
row_store.get_next_row(get_row); \
CHECK_CELL(1, num1); \
CHECK_CELL(2, num2); \
CHECK_CELL(3, num3); \
CHECK_CELL(4, num4); \
CHECK_CELL(5, num5);
ADD_ROW(1, 2, 4, 5, 3);
ADD_ROW(1, 2, 4, 5, 3);
ADD_ROW(1, 2, 4, 5, 3);
ADD_ROW(1, 2, 4, 5, 3);
ADD_ROW(1, 2, 4, 5, 3);
CHECK_ROW(1, 2, 4, 5, 3);
CHECK_ROW(1, 2, 4, 5, 3);
CHECK_ROW(1, 2, 4, 5, 3);
CHECK_ROW(1, 2, 4, 5, 3);
CHECK_ROW(1, 2, 4, 5, 3);
}
示例8: TEST_F
TEST_F(ObRowFuseTest, assign)
{
uint64_t TABLE_ID = 1000;
ObRowDesc row_desc;
for(int i=0;i<8;i++)
{
row_desc.add_column_desc(TABLE_ID, OB_APP_MIN_COLUMN_ID + i);
}
ObRow row;
row.set_row_desc(row_desc);
ObObj value;
for(int i=0;i<8;i++)
{
value.set_int(i);
OK(row.raw_set_cell(i, value));
}
ObRowDesc ups_row_desc;
for(int i=0;i<4;i++)
{
ups_row_desc.add_column_desc(TABLE_ID, OB_APP_MIN_COLUMN_ID + i);
}
ObUpsRow ups_row;
ups_row.set_row_desc(ups_row_desc);
for(int i=0;i<4;i++)
{
value.set_ext(ObActionFlag::OP_NOP);
OK(ups_row.raw_set_cell(i, value));
}
ups_row.set_delete_row(true);
OK(ObRowFuse::assign(ups_row, row));
const ObObj *cell = NULL;
uint64_t table_id = OB_INVALID_ID;
uint64_t column_id = OB_INVALID_ID;
for(int i=0;i<4;i++)
{
OK(row.raw_get_cell(i, cell, table_id, column_id));
ASSERT_EQ(ObNullType, cell->get_type());
}
ASSERT_TRUE(OB_SUCCESS != row.raw_get_cell(4, cell, table_id, column_id));
}
示例9: get_right_table_rowkey
int ObTabletJoin::get_right_table_rowkey(const ObRow &row, uint64_t &right_table_id, ObString &rowkey) const
{
int ret = OB_SUCCESS;
const ObObj *cell = NULL;
JoinInfo join_info;
if(OB_SUCCESS != (ret = table_join_info_.join_condition_.at(0, join_info)))
{
TBSYS_LOG(WARN, "get join condition fail:ret[%d]", ret);
}
if(OB_SUCCESS == ret)
{
right_table_id = join_info.right_table_id_;
if(OB_SUCCESS != (ret = row.get_cell(table_join_info_.left_table_id_, join_info.left_column_id_, cell)))
{
TBSYS_LOG(WARN, "row get cell fail:ret[%d]", ret);
}
else if(OB_SUCCESS != (ret = cell->get_varchar(rowkey)))
{
TBSYS_LOG(WARN, "get_varchar fail:ret[%d]", ret);
}
}
return ret;
}
示例10: TEST_F
TEST_F(ObRowUtilTest, basic_test)
{
char buf[1024];
ObCompactCellWriter cell_writer;
OK(cell_writer.init(buf, 1024, DENSE_SPARSE));
const char *rowkey = "rowkey_00001";
ObString rowkey_str;
rowkey_str.assign_ptr(const_cast<char *>(rowkey), (int32_t)(strlen(rowkey)));
ObObj rowkey_obj;
rowkey_obj.set_varchar(rowkey_str);
OK(cell_writer.append(rowkey_obj));
OK(cell_writer.rowkey_finish());
ObObj value;
ObRowDesc row_desc;
for(int64_t i=0;i<10;i++)
{
row_desc.add_column_desc(TABLE_ID, i);
value.set_int(i);
OK(cell_writer.append(i, value));
}
OK(cell_writer.row_finish());
ObString compact_row;
compact_row.assign_ptr(cell_writer.get_buf(), (int32_t)cell_writer.size());
ObRow row;
ObString rk;
row.set_row_desc(row_desc);
OK(ObRowUtil::convert(compact_row, row, &rk));
ASSERT_EQ(0, strncmp(rowkey, rk.ptr(), rk.length()));
const ObObj *cell = NULL;
uint64_t column_id = OB_INVALID_ID;
uint64_t table_id = OB_INVALID_ID;
int64_t int_value = 0;
for(int64_t i=0;i<10;i++)
{
OK(row.raw_get_cell(i, cell, table_id, column_id));
cell->get_int(int_value);
ASSERT_EQ(i, int_value);
}
}
示例11: build_values
void build_values(const int64_t row_count, ObRowDesc &row_desc, ObValues &values1, ObValues &values2)
{
values1.set_row_desc(row_desc);
values2.set_row_desc(row_desc);
for (int64_t i = 0; i < row_count; i++)
{
ObRow row;
row.set_row_desc(row_desc);
for (int64_t j = 0; j < row_desc.get_column_num(); j++)
{
uint64_t table_id = OB_INVALID_ID;
uint64_t column_id = OB_INVALID_ID;
row_desc.get_tid_cid(j, table_id, column_id);
ObObj obj;
obj.set_int(i + j);
row.set_cell(table_id, column_id, obj);
}
values1.add_values(row);
values2.add_values(row);
}
}
示例12: TEST
TEST(TestObNewScanner, try_all_the_best_to_add_row_to_scanner_as_much_as_possible)
{
ObNewScanner sc;
ObNewRange range, sc_range;
ObObj start_obj, end_obj;
start_obj.set_int(0);
end_obj.set_int(0xffff);
range.start_key_.assign(&start_obj, 1);
range.end_key_.assign(&end_obj, 1);
EXPECT_EQ(OB_SUCCESS, sc.set_range(range));
ObRowDesc row_desc;
row_desc.add_column_desc(TABLE_ID, 1);
row_desc.add_column_desc(TABLE_ID, 2);
row_desc.add_column_desc(TABLE_ID, 3);
row_desc.add_column_desc(TABLE_ID, 4);
row_desc.add_column_desc(TABLE_ID, 5);
ObRow row;
ObRow get_row;
row.set_row_desc(row_desc);
get_row.set_row_desc(row_desc);
int ret;
int n = 1024*1024;
while(n-- > 0)
{
ret = ADD_ROW(sc, 1, 2, 4, 5, 3);
ASSERT_TRUE(OB_SUCCESS == ret || OB_SIZE_OVERFLOW == ret);
if (ret == OB_SIZE_OVERFLOW)
{
TBSYS_LOG(INFO, "total %d rows inserted", n);
break;
}
}
CLEAN(sc);
}
示例13: get_rowkey
int ObTabletJoinTest::get_rowkey(const ObRow &row, ObString &rowkey)
{
int ret = OB_SUCCESS;
const ObObj *cell = NULL;
uint64_t table_id = OB_INVALID_ID;
uint64_t column_id = OB_INVALID_ID;
if(OB_SUCCESS != (ret = row.raw_get_cell(0, cell, table_id, column_id)))
{
TBSYS_LOG(WARN, "raw get cell fail:ret[%d]", ret);
}
else if(OB_SUCCESS != (ret = cell->get_varchar(rowkey)))
{
TBSYS_LOG(WARN, "get varchar:ret[%d]", ret);
}
return ret;
}
示例14: TEST_F
// ObRow.reset
TEST_F(ObRowTest, reset_test)
{
ObRow row;
ObRowDesc row_desc;
const uint64_t TABLE_ID = 1001;
const int64_t COLUMN_NUM = 8;
ObObj cell;
const ObObj *value = NULL;
uint64_t table_id = 0;
uint64_t column_id = 0;
int64_t int_value = 0;
row_desc.set_rowkey_cell_count(2);
for (int i = 0; i < COLUMN_NUM; i ++)
{
row_desc.add_column_desc(TABLE_ID, OB_APP_MIN_COLUMN_ID + i);
}
row.set_row_desc(row_desc);
for (int i = 0; i < COLUMN_NUM; i ++)
{
cell.set_int(i);
row.raw_set_cell(i, cell);
}
row.reset(true, ObRow::DEFAULT_NULL);
for (int i = 0; i < row_desc.get_rowkey_cell_count(); i ++)
{
row.raw_get_cell(i, value, table_id, column_id);
value->get_int(int_value);
ASSERT_EQ(i, int_value);
}
for (int64_t i = row_desc.get_rowkey_cell_count(); i < COLUMN_NUM; i ++)
{
row.raw_get_cell(i, value, table_id, column_id);
ASSERT_TRUE( ObNullType == value->get_type() );
}
row_desc.add_column_desc(OB_INVALID_ID, OB_ACTION_FLAG_COLUMN_ID);
cell.set_ext(ObActionFlag::OP_DEL_ROW);
row.set_cell(OB_INVALID_ID, OB_ACTION_FLAG_COLUMN_ID, cell);
row.reset(true, ObRow::DEFAULT_NOP);
for (int i = 0; i < row_desc.get_rowkey_cell_count(); i ++)
{
row.raw_get_cell(i, value, table_id, column_id);
value->get_int(int_value);
ASSERT_EQ(i, int_value);
}
for (int64_t i = row_desc.get_rowkey_cell_count(); i < COLUMN_NUM; i ++)
{
row.raw_get_cell(i, value, table_id, column_id);
ASSERT_TRUE( ObActionFlag::OP_NOP == value->get_ext() ) << "ext value: " << value->get_ext();
}
row.get_cell(OB_INVALID_ID, OB_ACTION_FLAG_COLUMN_ID, value);
ASSERT_TRUE( ObActionFlag::OP_ROW_DOES_NOT_EXIST == value->get_ext() );
}
示例15: sizeof
int ObStatManager::get_scanner(ObNewScanner &scanner) const
{
int ret = OB_SUCCESS;
int64_t last_used_mod = OB_INVALID_ID;
char ipbuf[OB_IP_STR_BUFF] = {0};
server_.ip_to_string(ipbuf, sizeof (ipbuf));
ObString ipstr = ObString::make_string(ipbuf);
const int32_t port = server_.get_port();
ObString server_name = ObString::make_string(print_role(get_server_type()));
int64_t total_stat_cnt = 0;
/* create row_desc */
ObRowDesc row_desc;
int32_t column_id = OB_APP_MIN_COLUMN_ID;
row_desc.add_column_desc(OB_ALL_SERVER_STAT_TID, column_id++);
row_desc.add_column_desc(OB_ALL_SERVER_STAT_TID, column_id++);
row_desc.add_column_desc(OB_ALL_SERVER_STAT_TID, column_id++);
row_desc.add_column_desc(OB_ALL_SERVER_STAT_TID, column_id++);
row_desc.add_column_desc(OB_ALL_SERVER_STAT_TID, column_id++);
row_desc.set_rowkey_cell_count(4);
ObRow row;
ObObj obj;
// drop mod id info
for (int32_t mod = 0; mod < OB_MAX_MOD_NUMBER; mod++)
{
ObStat stat;
total_stat_cnt += stat_cnt_[mod];
// drop table id info
for (int32_t i = 0; i < table_stats_[mod].get_array_index(); i++)
{
for (int32_t j = 0; j < stat_cnt_[mod]; j++)
{
stat.inc(j, table_stats_[mod].at(i)->get_value(j));
}
}
for (int32_t i = 0; i < stat_cnt_[mod]; i++)
{
column_id = OB_APP_MIN_COLUMN_ID;
row.set_row_desc(row_desc);
row.reset(false, ObRow::DEFAULT_NULL);
/* server type */
obj.set_type(ObVarcharType);
obj.set_varchar(server_name);
row.set_cell(OB_ALL_SERVER_STAT_TID, column_id++, obj);
/* server ip */
obj.set_type(ObVarcharType);
obj.set_varchar(ipstr);
row.set_cell(OB_ALL_SERVER_STAT_TID, column_id++, obj);
/* port */
obj.set_type(ObIntType);
obj.set_int(port);
row.set_cell(OB_ALL_SERVER_STAT_TID, column_id++, obj);
/* key */
obj.set_type(ObVarcharType);
obj.set_varchar(ObString::make_string(get_name(mod, i)));
row.set_cell(OB_ALL_SERVER_STAT_TID, column_id++, obj);
/* value */
obj.set_type(ObIntType);
obj.set_int(stat.get_value(i));
row.set_cell(OB_ALL_SERVER_STAT_TID, column_id++, obj);
scanner.add_row(row);
// for last rowkey
last_used_mod = mod;
}
}
/* last rowkey */
if (total_stat_cnt > 0)
{
static ObObj rk_objs[4];
rk_objs[0].set_type(ObVarcharType);
rk_objs[0].set_varchar(server_name);
rk_objs[1].set_type(ObVarcharType);
rk_objs[1].set_varchar(ipstr);
rk_objs[2].set_type(ObIntType);
rk_objs[2].set_int(port);
rk_objs[3].set_type(ObVarcharType);
rk_objs[3].set_varchar(ObString::make_string(get_name(last_used_mod, stat_cnt_[last_used_mod] - 1)));
ObRowkey rowkey(rk_objs, 4);
scanner.set_last_row_key(rowkey);
}
/* fullfilled */
scanner.set_is_req_fullfilled(true, total_stat_cnt);
return ret;
}