本文整理汇总了C++中ObObj::set_varchar方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::set_varchar方法的具体用法?C++ ObObj::set_varchar怎么用?C++ ObObj::set_varchar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObObj
的用法示例。
在下文中一共展示了ObObj::set_varchar方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OK
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);
}
示例2: auto_set_val
/* only support integer and string */
void ObScannerLoader::auto_set_val(ObObj &val, char *buf)
{
if (NULL == buf)
{
TBSYS_LOG(ERROR, "invalid scanner data input");
}
else
{
int len = static_cast<int32_t>(strlen(buf));
int i = 0;
ObString tmpstr;
bool is_num = true;
for(i = 0; i < len; i++)
{
if (!isdigit(buf[i]))
{
is_num = false;
break;
}
}
if (is_num)
{
val.set_int(atoi(buf));
}
else
{
tmpstr.assign(buf, static_cast<int32_t>(strlen(buf)));
val.set_varchar(tmpstr);
}
//val.dump();
}
}
示例3: set_str_obj_value
int set_str_obj_value(char * buf, const int64_t buf_len, int64_t & pos, const ObString &value)
{
int ret = OB_SUCCESS;
ObObj obj;
obj.set_varchar(value);
ret = obj.serialize(buf, buf_len, pos);
return ret;
}
示例4: strlen
TEST_F(TestSimpleFilter, test_index)
{
ObLogicOperator operate = LIKE;
char * ptr = "test_test";
ObString sub_string;
sub_string.assign(ptr, strlen(ptr));
ObObj operand;
operand.set_varchar(sub_string);
ObSimpleFilter filter;
ObSimpleCond cond1;
EXPECT_TRUE(cond1.set(2, operate, operand) == OB_SUCCESS);
EXPECT_TRUE(filter.add_cond(2, operate, operand) == OB_SUCCESS);
operate = GE;
operand.set_int(23);
ObSimpleCond cond2;
EXPECT_TRUE(cond2.set(1, operate, operand) == OB_SUCCESS);
EXPECT_TRUE(filter.add_cond(1, operate, operand) == OB_SUCCESS);
operate = NE;
operand.set_varchar(sub_string);
ObSimpleCond cond3;
EXPECT_TRUE(cond3.set(3, operate, operand) == OB_SUCCESS);
EXPECT_TRUE(filter.add_cond(3, operate, operand) == OB_SUCCESS);
const ObSimpleCond * cond = NULL;
cond = filter[-1];
EXPECT_TRUE(cond == NULL);
cond = filter[3];
EXPECT_TRUE(cond == NULL);
cond = filter[0];
EXPECT_TRUE(*cond == cond1);
cond = filter[1];
EXPECT_TRUE(cond != NULL);
EXPECT_TRUE(*cond == cond2);
cond = filter[2];
EXPECT_TRUE(cond != NULL);
EXPECT_TRUE(*cond == cond3);
}
示例5:
ScanConds::ScanConds(const char* column_name, const ObLogicOperator& cond_op, ObString& value)
{
ObString name;
name.assign_ptr(const_cast<char*>(column_name), static_cast<int32_t>(strlen(column_name)));
ObObj obj;
obj.set_varchar(value);
EasyArray<ObSimpleCond>(ObSimpleCond(name, cond_op, obj));
}
示例6: copy_obj_
inline int ObCellArray::copy_obj_(ObObj &dst, const ObObj &src)
{
int err = OB_SUCCESS;
char *tmp_buf = NULL;
/// allocate value
if (src.get_type() == ObVarcharType)
{
ObString src_value;
ObString dst_value;
err = src.get_varchar(src_value);
if (OB_SUCCESS == err)
{
// must assign %src to %dst first, for copy meta data to %dst object.
// dst's meta_ members(especially meta_.reserved_) could be random value
// if only call dst.set_varchar();
dst = src;
if (src_value.length() > 0)
{
tmp_buf =reinterpret_cast<char*>( page_arena_.alloc(src_value.length()));
if (NULL == tmp_buf)
{
TBSYS_LOG(WARN, "%s", "fail to malloc buffer for varchar value");
err = OB_ALLOCATE_MEMORY_FAILED;
}
else
{
allocated_memory_size_ += src_value.length();
memcpy(tmp_buf, src_value.ptr(), src_value.length());
dst_value.assign(tmp_buf,src_value.length());
dst.set_varchar(dst_value);
}
}
else
{
dst.set_varchar(dst_value);
}
}
}
return err;
}
示例7: SetUp
virtual void SetUp()
{
int64_t pos = 0;
range.table_id_ = 1001;
start_key_obj.set_varchar(start_key);
range.start_key_.assign(&start_key_obj, 1);
end_key_obj.set_varchar(end_key);
range.end_key_.assign(&end_key_obj, 1);
range.border_flag_.unset_inclusive_start();
range.border_flag_.set_inclusive_end();
default_range.table_id_ = OB_INVALID_ID;
default_range.set_whole_range();
default_range.border_flag_.unset_inclusive_start();
default_range.border_flag_.unset_inclusive_end();
range.start_key_.serialize(key_stream_buf, 512, pos);
range.end_key_.serialize(key_stream_buf, 512, pos);
key_stream.assign_ptr(key_stream_buf, static_cast<int32_t>(pos));
}
示例8: parse_varchar
int ObUpsCompactCellIterator::parse_varchar(ObBufferReader &buf_reader, ObObj &value) const
{
int ret = OB_SUCCESS;
const int32_t *varchar_len = NULL;
ObString str_value;
ret = buf_reader.get<int32_t>(varchar_len);
if(OB_SUCCESS == ret)
{
if(*varchar_len <= (int32_t)sizeof(const char*))
{
str_value.assign_ptr(const_cast<char*>(buf_reader.cur_ptr()), *varchar_len);
buf_reader.skip(*varchar_len);
value.set_varchar(str_value);
}
else
{
const char* ptr = buf_reader.get<const char*>();
str_value.assign_ptr(const_cast<char*>(ptr), *varchar_len);
value.set_varchar(str_value);
}
}
return ret;
}
示例9:
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*/
//.........这里部分代码省略.........
示例10: 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;
}
示例11: build_cell_
void CellinfoBuilder::build_cell_(struct drand48_data &rand_data, const ObString &row_key, const ObSchema &schema,
ObObj &obj, int64_t &column_pos, int &op_type,
PageArena<char> &allocer)
{
const ObColumnSchema *column_schema = schema.column_begin();
int64_t column_num = schema.column_end() - schema.column_begin();
int64_t rand = 0;
lrand48_r(&rand_data, &rand);
op_type = calc_op_type_(rand);
//while (true)
//{
// lrand48_r(&rand_data, &rand);
// column_pos = range_rand(0, column_num - 3, rand);
// if (ObIntType <= column_schema[column_pos].get_type()
// && ObVarcharType >= column_schema[column_pos].get_type())
// {
// break;
// }
//}
column_pos=0;
lrand48_r(&rand_data, &rand);
switch (column_schema[column_pos].get_type())
{
case ObIntType:
{
int64_t tmp = rand;
obj.set_int(tmp, ADD == op_type);
break;
}
case ObFloatType:
{
float tmp = static_cast<float>(rand);
obj.set_float(tmp, ADD == op_type);
break;
}
case ObDoubleType:
{
double tmp = static_cast<double>(rand);
obj.set_double(tmp, ADD == op_type);
break;
}
case ObDateTimeType:
{
ObDateTime tmp = static_cast<ObDateTime>(rand);
obj.set_datetime(tmp, ADD == op_type);
break;
}
case ObPreciseDateTimeType:
{
ObPreciseDateTime tmp = static_cast<ObPreciseDateTime>(rand);
obj.set_precise_datetime(tmp, ADD == op_type);
break;
}
case ObVarcharType:
{
int64_t length = range_rand(1, column_schema[column_pos].get_size(), rand);
char *ptr = allocer.alloc(length);
build_string(ptr, length, rand);
ObString str;
str.assign_ptr(ptr, length);
if (ADD == op_type)
{
op_type = UPDATE;
}
obj.set_varchar(str);
break;
}
default:
break;
}
if (DEL_CELL == op_type)
{
obj.set_null();
}
else if (DEL_ROW == op_type)
{
obj.set_ext(ObActionFlag::OP_DEL_ROW);
}
}
示例12: process_variables_set
int ObVariableSet::process_variables_set()
{
int ret = OB_SUCCESS;
bool need_global_change = false;
ObRow val_row;
const ObObj *value_obj = NULL;
ObSQLSessionInfo *session = my_phy_plan_->get_result_set()->get_session();
for (int64_t i = 0; ret == OB_SUCCESS && i < variable_nodes_.count(); i++)
{
VariableSetNode& node = variable_nodes_.at(i);
if ((ret = node.variable_expr_->calc(val_row, value_obj)) != OB_SUCCESS)
{
TBSYS_LOG(WARN, "Calculate variable value failed. ret=%d", ret);
}
else if (!node.is_system_variable_)
{
// user defined tmp variable
if ((ret = session->replace_variable(
node.variable_name_,
*value_obj)) != OB_SUCCESS)
{
TBSYS_LOG(WARN, "set variable to session plan failed. ret=%d, name=%.*s",
ret, node.variable_name_.length(), node.variable_name_.ptr());
}
}
else if (!node.is_global_)
{
// set session system variable
if ((ret = session->update_system_variable(
node.variable_name_,
*value_obj)) != OB_SUCCESS)
{
TBSYS_LOG(WARN, "set variable to session plan failed. ret=%d, name=%.*s",
ret, node.variable_name_.length(), node.variable_name_.ptr());
}
// special case: set autocommit
else if (node.variable_name_ == ObString::make_string("autocommit"))
{
int64_t int_val = 0;
ObObj int_obj;
ObObj obj_type;
obj_type.set_type(ObIntType);
const ObObj *res_obj = NULL;
if (OB_SUCCESS != (ret = obj_cast(*value_obj, obj_type, int_obj, res_obj)))
{
TBSYS_LOG(WARN, "failed to cast to int, obj=%s", to_cstring(*value_obj));
}
else
{
ret = res_obj->get_int(int_val);
OB_ASSERT(OB_SUCCESS == ret);
if (int_val)
{
ret = set_autocommit();
OB_STAT_INC(OBMYSQL, SQL_AUTOCOMMIT_ON_COUNT);
}
else
{
ret = clear_autocommit();
OB_STAT_INC(OBMYSQL, SQL_AUTOCOMMIT_OFF_COUNT);
}
}
}
}
else
{
// set global system variable
char key_varchar_buff[OB_MAX_ROWKEY_COLUMN_NUMBER + 1][OB_MAX_VARCHAR_LENGTH];
ObObj casted_cells[OB_MAX_ROWKEY_COLUMN_NUMBER + 1];
ObObj rowkey_objs[OB_MAX_ROWKEY_COLUMN_NUMBER];
const ObObj *res_cell = NULL;
ObRowkey rowkey;
ObObj value;
// construct rowkey
for (int64_t j = 0; ret == OB_SUCCESS && j < rowkey_info_.get_size(); ++j)
{
uint64_t cid = OB_INVALID_ID;
ObString varchar;
varchar.assign_ptr(key_varchar_buff[j], OB_MAX_VARCHAR_LENGTH);
casted_cells[j].set_varchar(varchar);
const ObRowkeyColumn *rowkey_column = rowkey_info_.get_column(j);
if (rowkey_column == NULL)
{
ret = OB_ERROR;
TBSYS_LOG(ERROR, "Get rowkey error");
break;
}
else if (OB_SUCCESS != (ret = rowkey_info_.get_column_id(j, cid)))
{
TBSYS_LOG(USER_ERROR, "Primary key can not be empty");
ret = OB_ERR_GEN_PLAN;
break;
}
else
{
ObObj data_type;
data_type.set_type(rowkey_column->type_);
if (cid != name_cid_)
{
//.........这里部分代码省略.........
示例13: test_write_one_file
void test_write_one_file()
{
ObSSTableSchemaColumnDef column_def;
ObSSTableSchema schema;
ObSSTableRow row;
char *compressor_name = (char*)COMPRESSOR_NAME;
ObSSTableWriter writer;
ObString file_name(static_cast<int32_t>(strlen(sstable_path) + 1),
static_cast<int32_t>(strlen(sstable_path) + 1), sstable_path);
ObString compressor(static_cast<int32_t>(strlen(compressor_name) + 1),
static_cast<int32_t>(strlen(compressor_name) + 1), compressor_name);
int64_t disk_usage = 0;
int64_t trailer_offset = 0;
ObObj obj;
ObObj key_obj;
uint64_t table_id = 0;
uint64_t column_group_id = 0;
char value_data[1024 + 1];
char rowkey_str[32];
ObString row_key;
ObRowkey key;
char *ptr;
int ret;
// init schema
for (int64_t i = 0; i < 5; ++i)
{
column_def.table_id_ = static_cast<uint32_t>(1025 + i);
// add rowkey column
column_def.column_group_id_ = 0;
column_def.column_name_id_ = 1;
column_def.column_value_type_ = ObVarcharType;
column_def.rowkey_seq_ = 1;
schema.add_column_def(column_def);
for ( int j = 0; j < 10 ; ++j)
{
column_def.column_group_id_ = static_cast<uint16_t>(j);
column_def.column_name_id_ = 2;
column_def.column_value_type_ = ObDoubleType;
column_def.rowkey_seq_ = 0;
schema.add_column_def(column_def);
column_def.column_name_id_ = 3;
column_def.column_value_type_ = ObIntType;
column_def.rowkey_seq_ = 0;
schema.add_column_def(column_def);
column_def.column_name_id_ = 4;
column_def.column_value_type_ = ObVarcharType;
column_def.rowkey_seq_ = 0;
schema.add_column_def(column_def);
}
}
//build data
ptr = value_data;
for (int64_t i = 0; i < 128; ++i) {
memcpy(ptr, "testing ", 8);
ptr += 8;
}
ObString value_str(1025, 1025, value_data);
writer.set_dio(true);
int64_t start_time = tbsys::CTimeUtil::getTime();
// create sstable file
if (OB_ERROR == (ret = writer.create_sstable(schema, file_name,
compressor, 2)))
{
TBSYS_LOG(ERROR, "Failed to create sstable file: %s", sstable_path);
}
for (int64_t i = 0; i < 5000000; ++i)
{
row.clear();
table_id = i / 1000000 + 1025;
column_group_id = i % 1000000 / 100000;
row.set_table_id(table_id);
row.set_column_group_id(column_group_id);
sprintf(rowkey_str, "row_key_%08ld", i);
row_key.assign(rowkey_str, 16);
key_obj.set_varchar(row_key);
key.assign(&key_obj, 1);
row.set_rowkey(key);
obj.set_double((double)i);
row.add_obj(obj);
obj.set_int(i);
row.add_obj(obj);
obj.set_varchar(value_str);
row.add_obj(obj);
if (OB_ERROR == (ret = writer.append_row(row, disk_usage)))
{
TBSYS_LOG(ERROR, "add row failed, i=%ld", i);
return;
}
}
//.........这里部分代码省略.........
示例14: parse_line
int ObUpsFileTable::parse_line(const ObRow *&row)
{
int ret = OB_SUCCESS;
ObObj value;
int64_t int_value;
ObString str_value;
if (column_count_ + 1 == count_)
{
for (int32_t i=1;(OB_SUCCESS == ret) && i<count_;i++)
{
if( tokens_[0][0] == '-' )
{
curr_ups_row_.set_delete_row(true);
}
else
{
curr_ups_row_.set_delete_row(false);
}
if(0 == strcmp(tokens_[i], "NOP"))
{
value.set_ext(ObActionFlag::OP_NOP);
}
else
{
if(ObIntType == column_type_[i-1])
{
bool is_add = false;
if( tokens_[i][strlen(tokens_[i]) - 1] == '+' )
{
tokens_[i][strlen(tokens_[i]) - 1] = '\0';
is_add = true;
}
int_value = atoi(tokens_[i]);
value.set_int(int_value, is_add);
}
else if(ObVarcharType == column_type_[i-1])
{
str_value.assign_ptr(tokens_[i], strlen(tokens_[i]));
value.set_varchar(str_value);
}
else if(ObExtendType == column_type_[i-1])
{
value.set_ext(ObActionFlag::OP_DEL_ROW);
}
else
{
ret = OB_ERROR;
TBSYS_LOG(WARN, "unsupport type [%d]", column_type_[i-1]);
}
}
if(OB_SUCCESS == ret)
{
ret = curr_ups_row_.set_cell(table_id_, column_ids_[i-1], value);
}
}
}
else
{
ret = OB_ERROR;
TBSYS_LOG(WARN, "column_count_[%d], count_[%d], line_[%s]", column_count_, count_, line_);
}
if (OB_SUCCESS == ret)
{
row = &curr_ups_row_;
}
return ret;
}