本文整理汇总了C++中ObRow::set_cell方法的典型用法代码示例。如果您正苦于以下问题:C++ ObRow::set_cell方法的具体用法?C++ ObRow::set_cell怎么用?C++ ObRow::set_cell使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObRow
的用法示例。
在下文中一共展示了ObRow::set_cell方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
}
示例3: get_scanner
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;
}
示例4:
// 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() );
}
示例5:
TEST(ObPrivilege, test)
{
ObPrivilege privilege;
int ret = OB_SUCCESS;
ret = privilege.init();
ASSERT_EQ(OB_SUCCESS, ret);
// add_user_table_privilege_per
ObRow row;
ObRowDesc row_desc;
ObRow row2;
ObRowDesc row_desc2;
const uint64_t OB_USERS_TID = 20;
const uint64_t OB_USERS_USERNAME_CID = 30;
const uint64_t OB_USERS_USERID_CID = 31;
const uint64_t OB_USERS_PASSWORD_CID = 32;
const uint64_t OB_USERS_COMMENT_CID = 34;
const uint64_t OB_USERS_PRIV_ALL_CID = 35;
const uint64_t OB_USERS_PRIV_ALTER_CID = 36;
const uint64_t OB_USERS_PRIV_CREATE_CID = 37;
const uint64_t OB_USERS_PRIV_CREATE_USER_CID = 38;
const uint64_t OB_USERS_PRIV_DELETE_CID = 39;
const uint64_t OB_USERS_PRIV_DROP_CID = 40;
const uint64_t OB_USERS_PRIV_GRANT_OPTION_CID = 41;
const uint64_t OB_USERS_PRIV_INSERT_CID = 42;
const uint64_t OB_USERS_PRIV_UPDATE_CID = 43;
const uint64_t OB_USERS_PRIV_SELECT_CID = 44;
const uint64_t OB_USERS_LOCKED_CID = 45;
const uint64_t OB_TABLE_PRIVILEGES_TID = 40;
const uint64_t OB_TABLE_PRIVILEGES_USERID_CID = 50;
const uint64_t OB_TABLE_PRIVILEGES_TABLEID_CID = 51;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_ALL_CID = 52;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_ALTER_CID = 53;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_CREATE_CID = 54;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_CREATE_USER_CID = 55;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_DELETE_CID = 56;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_DROP_CID = 57;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_GRANT_OPTION_CID = 58;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_INSERT_CID = 59;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_UPDATE_CID = 60;
const uint64_t OB_TABLE_PRIVILEGES_PRIV_SELECT_CID = 61;
// set row desc, set table __users
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_USERNAME_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_USERID_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PASSWORD_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_COMMENT_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_ALL_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_ALTER_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_CREATE_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_CREATE_USER_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_DELETE_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_DROP_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_GRANT_OPTION_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_INSERT_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_UPDATE_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_PRIV_SELECT_CID));
ASSERT_EQ(OB_SUCCESS, row_desc.add_column_desc(OB_USERS_TID, OB_USERS_LOCKED_CID));
//set row desc , set table __table_privileges
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_USERID_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_TABLEID_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_ALL_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_ALTER_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_CREATE_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_CREATE_USER_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_DELETE_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_DROP_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_GRANT_OPTION_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_INSERT_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_UPDATE_CID));
ASSERT_EQ(OB_SUCCESS, row_desc2.add_column_desc(OB_TABLE_PRIVILEGES_TID, OB_TABLE_PRIVILEGES_PRIV_SELECT_CID));
row.set_row_desc(row_desc);
row2.set_row_desc(row_desc2);
//=======================================================================================
// set row data
ObObj username;
ObString str;
str.assign_ptr(const_cast<char*>("zhangsan"), static_cast<int32_t>(strlen("zhangsan")));
username.set_varchar(str);
ASSERT_EQ(OB_SUCCESS, row.set_cell(OB_USERS_TID, OB_USERS_USERNAME_CID, username));
ObObj userid;
userid.set_int(10);
ASSERT_EQ(OB_SUCCESS, row.set_cell(OB_USERS_TID, OB_USERS_USERID_CID, userid));
ObObj password;
str.assign_ptr(const_cast<char*>("encryptedpass"), static_cast<int32_t>(strlen("encryptedpass")));
password.set_varchar(str);
ASSERT_EQ(OB_SUCCESS, row.set_cell(OB_USERS_TID, OB_USERS_PASSWORD_CID, password));
ObObj comment;
str.assign_ptr(const_cast<char*>("comment content"), static_cast<int32_t>(strlen("comment content")));
comment.set_varchar(str);
ASSERT_EQ(OB_SUCCESS, row.set_cell(OB_USERS_TID, OB_USERS_COMMENT_CID, comment));
/* PRIV_ALL PRIV_ALTER PRIV_CREATE PRIV_CREATE_USER PRIV_DELETE PRIV_DROP PRIV_GRANT_OPTION PRIV_INSERT PRIV_UPDATE PRIV_SELECT
* 1 1 0 0 1 0 0 1 0 0
*
*
*
*/
/* set privilege-related cell*/
//.........这里部分代码省略.........