本文整理汇总了C++中ObObj::get_int方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::get_int方法的具体用法?C++ ObObj::get_int怎么用?C++ ObObj::get_int使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObObj
的用法示例。
在下文中一共展示了ObObj::get_int方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: free
TEST(ObObj,Serialize_int_add)
{
ObObj t;
t.set_int(9900);
int64_t len = t.get_serialize_size();
ASSERT_EQ(len,3);
char *buf = (char *)malloc(len);
int64_t pos = 0;
ASSERT_EQ(t.serialize(buf,len,pos),OB_SUCCESS);
ASSERT_EQ(pos,len);
ObObj f;
pos = 0;
ASSERT_EQ(f.deserialize(buf,len,pos),OB_SUCCESS);
ASSERT_EQ(pos,len);
int64_t r = 0;
int64_t l = 0;
ASSERT_EQ(f.get_type(),t.get_type());
f.get_int(r);
t.get_int(l);
ASSERT_EQ(r,l);
free(buf);
}
示例2: check_obj
void check_obj(const ObObj& expected, const ObObj& real)
{
// TODO
EXPECT_EQ(expected.get_type(), real.get_type());
int64_t expected_val, real_val;
int ret = 0;
ret = expected.get_int(expected_val);
EXPECT_EQ(0, ret);
ret = real.get_int(real_val);
EXPECT_EQ(0, ret);
EXPECT_EQ(expected_val, real_val);
}
示例3: set_trans_params
int ObUpsExecutor::set_trans_params(ObSQLSessionInfo *session, common::ObTransReq &req)
{
int ret = OB_SUCCESS;
// get isolation level etc. from session
ObObj val;
ObString isolation_str;
int64_t tx_timeout_val = 0;
int64_t tx_idle_timeout = 0;
if (OB_SUCCESS != (ret = session->get_sys_variable_value(ObString::make_string("tx_isolation"), val)))
{
TBSYS_LOG(WARN, "failed to get tx_isolation value, err=%d", ret);
}
else if (OB_SUCCESS != (ret = val.get_varchar(isolation_str)))
{
TBSYS_LOG(WARN, "wrong obj type, err=%d", ret);
ret = OB_ERR_UNEXPECTED;
}
else if (OB_SUCCESS != (ret = req.set_isolation_by_name(isolation_str)))
{
TBSYS_LOG(WARN, "failed to set isolation level, err=%d", ret);
ret = OB_ERR_UNEXPECTED;
}
else if (OB_SUCCESS != (ret = session->get_sys_variable_value(ObString::make_string("ob_tx_timeout"), val)))
{
TBSYS_LOG(WARN, "failed to get tx_timeout value, err=%d", ret);
}
else if (OB_SUCCESS != (ret = val.get_int(tx_timeout_val)))
{
TBSYS_LOG(WARN, "wrong obj type, err=%d", ret);
ret = OB_ERR_UNEXPECTED;
}
else if (OB_SUCCESS != (ret = session->get_sys_variable_value(ObString::make_string("ob_tx_idle_timeout"), val)))
{
TBSYS_LOG(WARN, "failed to get tx_idle_timeout value, err=%d", ret);
}
else if (OB_SUCCESS != (ret = val.get_int(tx_idle_timeout)))
{
TBSYS_LOG(WARN, "wrong obj type, err=%d", ret);
ret = OB_ERR_UNEXPECTED;
}
else
{
req.timeout_ = tx_timeout_val;
req.idle_time_ = tx_idle_timeout;
}
return ret;
}
示例4: get_rowkey_compatible
int get_rowkey_compatible(const char* buf, const int64_t buf_len, int64_t & pos,
const ObRowkeyInfo& info, ObObj* array, int64_t& size, bool& is_binary_rowkey)
{
int ret = OB_SUCCESS;
ObObj obj;
int64_t obj_count = 0;
ObString str_value;
is_binary_rowkey = false;
if ( OB_SUCCESS == (ret = obj.deserialize(buf, buf_len, pos)) )
{
if (ObIntType == obj.get_type() && (OB_SUCCESS == (ret = obj.get_int(obj_count))))
{
// new rowkey format.
for (int64_t i = 0; i < obj_count && OB_SUCCESS == ret; ++i)
{
if (i >= size)
{
ret = OB_SIZE_OVERFLOW;
}
else
{
ret = array[i].deserialize(buf, buf_len, pos);
}
}
if (OB_SUCCESS == ret) size = obj_count;
}
else if (ObVarcharType == obj.get_type() && OB_SUCCESS == (ret = obj.get_varchar(str_value)))
{
is_binary_rowkey = true;
// old fashion , binary rowkey stream
if (size < info.get_size())
{
TBSYS_LOG(WARN, "input size=%ld not enough, need rowkey obj size=%ld", size, info.get_size());
ret = OB_SIZE_OVERFLOW;
}
else if (str_value.length() == 0)
{
// allow empty binary rowkey , incase min, max range.
size = 0;
}
else if (str_value.length() < info.get_binary_rowkey_length())
{
TBSYS_LOG(WARN, "binary rowkey length=%d < need rowkey length=%ld",
str_value.length(), info.get_binary_rowkey_length());
ret = OB_SIZE_OVERFLOW;
}
else
{
size = info.get_size();
ret = ObRowkeyHelper::binary_rowkey_to_obj_array(info, str_value, array, size);
}
}
}
return ret;
}
示例5: get_int_obj_value
int get_int_obj_value(const char* buf, const int64_t buf_len, int64_t & pos, int64_t & int_value)
{
int ret = OB_SUCCESS;
ObObj obj;
if ( OB_SUCCESS == (ret = obj.deserialize(buf, buf_len, pos))
&& ObIntType == obj.get_type())
{
ret = obj.get_int(int_value);
}
return ret;
}
示例6: deserialize_reserve_param
int ObReadParam::deserialize_reserve_param(const char * buf, const int64_t data_len, int64_t & pos)
{
ObObj obj;
int64_t int_value = 0;
int ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
//is read master
set_is_read_consistency(int_value);
}
}
return ret;
}
示例7:
TEST(ObObj, performance)
{
// int64_t start_time = tbsys::CTimeUtil::getTime();
//const int64_t MAX_COUNT = 10 * 1000 * 1000L;
const int64_t MAX_COUNT = 1000L;
ObObj obj;
char buf[2048];
int64_t len = 2048;
int64_t pos = 0;
int64_t data = 0;
for (int64_t i = 0; i < MAX_COUNT; ++i)
{
obj.set_int(i);
pos = 0;
ASSERT_EQ(obj.serialize(buf, len, pos), OB_SUCCESS);
pos = 0;
ASSERT_EQ(obj.deserialize(buf, len, pos), OB_SUCCESS);
ASSERT_EQ(obj.get_int(data), OB_SUCCESS);
ASSERT_EQ(data, i);
}
const char *tmp = "Hello12344556666777777777777545352454254254354354565463241242354345345345235345";
ObObj obj2;
ObString string;
ObString string2;
string.assign_ptr(const_cast<char *>(tmp), 1024);
obj2.set_varchar(string);
for (register int64_t i = 0; i < MAX_COUNT; ++i )
{
pos = 0;
ASSERT_EQ(obj2.serialize(buf, len, pos), OB_SUCCESS);
pos = 0;
ASSERT_EQ(obj2.deserialize(buf, len, pos), OB_SUCCESS);
ASSERT_EQ(obj2.get_varchar(string2), OB_SUCCESS);
}
// int64_t end_time = tbsys::CTimeUtil::getTime();
//printf("using time:%ld\n", end_time - start_time);
}
示例8: deserialize_int
int ObSqlGetParam::deserialize_int(const char* buf, const int64_t data_len, int64_t& pos,
int64_t& value) const
{
int ret = OB_SUCCESS;
ObObjType type = ObNullType;
ObObj obj;
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
type = obj.get_type();
if (ObIntType == type)
{
obj.get_int(value);
}
else
{
TBSYS_LOG(WARN, "expected deserialize int type, but get type=%d", type);
ret = OB_ERROR;
}
}
return ret;
}
示例9: deserialize_basic_param
int ObSqlReadParam::deserialize_basic_param(const char * buf, const int64_t data_len, int64_t & pos)
{
ObObj obj;
int ret = OB_SUCCESS;
int64_t int_value = 0;
// read consistency
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
//is read consistency
set_is_read_consistency(int_value);
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// result cached
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
//is read consistency
set_is_result_cached(int_value > 0);
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// data_version
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
// data version
set_data_version(int_value);
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// table id
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
{
table_id_ = int_value;
}
else
{
TBSYS_LOG(WARN, "fail to get int. obj type=%d", obj.get_type());
}
}
else
{
TBSYS_LOG(WARN, "fail to deserialize obj. ret=%d", ret);
}
}
// renamed table id
if (OB_SUCCESS == ret)
{
ret = obj.deserialize(buf, data_len, pos);
if (OB_SUCCESS == ret)
{
ret = obj.get_int(int_value);
if (OB_SUCCESS == ret)
//.........这里部分代码省略.........
示例10: open
int ObResultSet::open()
{
int ret = common::OB_SUCCESS;
ObObj val;
int64_t plan_timeout = OB_DEFAULT_STMT_TIMEOUT;
if (OB_UNLIKELY(NULL == physical_plan_))
{
if (ObBasicStmt::T_PREPARE != stmt_type_)
{
TBSYS_LOG(WARN, "physical_plan not init, stmt_type=%d", stmt_type_);
ret = common::OB_NOT_INIT;
}
}
else
{
// get current frozen version
OB_ASSERT(my_session_);
FILL_TRACE_LOG("curr_frozen_version=%s", to_cstring(my_session_->get_frozen_version()));
physical_plan_->set_curr_frozen_version(my_session_->get_frozen_version());
/// query timeout for sql level
if (OB_SUCCESS == my_session_->get_sys_variable_value(ObString::make_string(OB_QUERY_TIMEOUT_PARAM), val))
{
if (OB_SUCCESS != val.get_int(plan_timeout))
{
TBSYS_LOG(WARN, "fail to get query timeout from session, ret=%d", ret);
plan_timeout = OB_DEFAULT_STMT_TIMEOUT; // use default
}
}
physical_plan_->set_timeout_timestamp(plan_timeout + tbsys::CTimeUtil::getTime());
ObPhyOperator *main_query = physical_plan_->get_main_query();
ObPhyOperator *pre_query = physical_plan_->get_pre_query();
if (NULL != pre_query)
{
ret = pre_query->open();
FILL_TRACE_LOG("pre_query finished");
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "failed to open pre_query, ret=%d", ret);
}
}
if (OB_SUCCESS == ret)
{
if (NULL == main_query)
{
ret = OB_ERR_UNEXPECTED;
TBSYS_LOG(ERROR, "main query must not be NULL");
}
else
{
ret = main_query->open();
FILL_TRACE_LOG("main_query finished");
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "failed to open main query, ret=%d", ret);
}
}
}
}
set_errcode(ret);
return ret;
}
示例11: apply
int ObObj::apply(const ObObj &mutation)
{
int64_t org_type = get_type();
int64_t org_ext = get_ext();
int err = OB_SUCCESS;
ObCreateTime create_time = 0;
ObModifyTime modify_time = 0;
bool is_add = false;
bool org_is_add = false;
if (ObSeqType == mutation.get_type()
|| ObMinType >= mutation.get_type()
|| ObMaxType <= mutation.get_type())
{
TBSYS_LOG(WARN,"unsupported type [type:%d]", static_cast<int32_t>(mutation.get_type()));
err = OB_INVALID_ARGUMENT;
}
if (OB_SUCCESS == err
&& ObExtendType != get_type()
&& ObNullType != get_type()
&& ObExtendType != mutation.get_type()
&& ObNullType != mutation.get_type()
&& get_type() != mutation.get_type())
{
TBSYS_LOG(WARN,"type not coincident [this->type:%d,mutation.type:%d]",
static_cast<int>(get_type()), static_cast<int>(mutation.get_type()));
err = OB_INVALID_ARGUMENT;
}
_ObjValue value, mutation_value;
if (OB_SUCCESS == err)
{
bool ext_val_can_change = (ObActionFlag::OP_ROW_DOES_NOT_EXIST == get_ext()) || (ObNullType == get_type());
bool org_is_nop = (ObActionFlag::OP_NOP == get_ext());
switch (mutation.get_type())
{
case ObNullType:
set_null();
break;
case ObVarcharType:
*this = mutation;
break;
case ObIntType:
if (ext_val_can_change || org_is_nop)
{
set_int(0);
}
err = get_int(value.int_val,org_is_add);
if (OB_SUCCESS == err)
{
err = mutation.get_int(mutation_value.int_val,is_add);
}
if (OB_SUCCESS == err)
{
if (is_add)
{
value.int_val += mutation_value.int_val;
}
else
{
value.int_val = mutation_value.int_val;
}
set_int(value.int_val, (org_is_add || org_is_nop) && is_add);
}
break;
case ObFloatType:
if (ext_val_can_change || org_is_nop)
{
set_float(0);
}
err = get_float(value.float_val,org_is_add);
if (OB_SUCCESS == err)
{
err = mutation.get_float(mutation_value.float_val, is_add);
}
if (OB_SUCCESS == err)
{
if (is_add)
{
value.float_val += mutation_value.float_val;
}
else
{
value.float_val = mutation_value.float_val;
}
set_float(value.float_val,is_add && (org_is_add || org_is_nop));
}
break;
case ObDoubleType:
if (ext_val_can_change || org_is_nop)
{
set_double(0);
}
err = get_double(value.double_val,org_is_add);
if (OB_SUCCESS == err)
{
err = mutation.get_double(mutation_value.double_val,is_add);
}
if (OB_SUCCESS == err)
{
if (is_add)
{
//.........这里部分代码省略.........
示例12: if
bool ObObj::operator==(const ObObj &that_obj) const
{
bool result = false;
int err = OB_SUCCESS;
if ((get_type() == ObNullType) && (that_obj.get_type() == ObNullType))
{
result = true;
}
else if ((get_type() == ObNullType) || (that_obj.get_type() == ObNullType))
{
result = false;
}
else if (!can_compare(that_obj))
{
result = false;
TBSYS_LOG(ERROR, "logic error, cann't compare two obj with different type [this.type:%d,"
"that.type:%d]", get_type(), that_obj.get_type());
}
else
{
_ObjValue this_value;
_ObjValue that_value;
int64_t this_timestamp = 0;
int64_t that_timestamp = 0;
ObObjType type = get_type();
switch (type)
{
case ObIntType:
err = get_int(this_value.int_val);
if (OB_SUCCESS == err)
{
err = that_obj.get_int(that_value.int_val);
if (OB_SUCCESS == err)
{
result = this_value.int_val == that_value.int_val;
}
}
break;
case ObVarcharType:
err = get_varchar(this_value.varchar_val);
if (OB_SUCCESS == err)
{
err = that_obj.get_varchar(that_value.varchar_val);
if (OB_SUCCESS == err)
{
result = this_value.varchar_val == that_value.varchar_val;
}
}
break;
case ObFloatType:
err = get_float(this_value.float_val);
if (OB_SUCCESS == err)
{
err = that_obj.get_float(that_value.float_val);
if (OB_SUCCESS == err)
{
result = fabsf(this_value.float_val - that_value.float_val) < FLOAT_EPSINON;
}
}
break;
case ObDoubleType:
err = get_double(this_value.double_val);
if (OB_SUCCESS == err)
{
err = that_obj.get_double(that_value.double_val);
if (OB_SUCCESS == err)
{
result = fabs(this_value.double_val - that_value.double_val) < DOUBLE_EPSINON;
}
}
break;
case ObDateTimeType:
case ObPreciseDateTimeType:
case ObCreateTimeType:
case ObModifyTimeType:
err = get_timestamp(this_timestamp);
if (OB_SUCCESS == err)
{
err = that_obj.get_timestamp(that_timestamp);
if (OB_SUCCESS == err)
{
result = this_timestamp == that_timestamp;
}
}
break;
/*case ObSeqType:
/// @todo (wushi [email protected]) sequence
break;*/
default:
result = OB_ERR_UNEXPECTED;
TBSYS_LOG(ERROR,"unexpected obj type [obj.type:%d]", type);
break;
}
}
return result;
}
示例13: update_item
int ObMergeServerParams::update_item(const ObObj &item_name, const ObObj &item_value)
{
int ret = OB_SUCCESS;
static const int max_name_len = 256;
char name[max_name_len];
int64_t value = 0;
ObString str;
if (OB_SUCCESS != (ret = item_name.get_varchar(str)))
{
TBSYS_LOG(WARN, "fail to get item name value. ret=%d", ret);
}
else if (str.length() < max_name_len)
{
strncpy(name, str.ptr(), str.length());
name[str.length()] = '\0';
}
else
{
TBSYS_LOG(WARN, "item name too long. are you sure about this? item_name len=%d, max=%d", str.length(), max_name_len);
}
if ((OB_SUCCESS == ret) && (OB_SUCCESS != (ret = item_value.get_int(value))))
{
TBSYS_LOG(WARN, "fail to get value. expect int type");
}
if (OB_SUCCESS == ret)
{
if (0 == strcmp(name, OBMS_RETRY_TIMES))
{
retry_times_ = static_cast<int32_t>(value);
}
else if (0 == strcmp(name, OBMS_TASK_QUEUE_SIZE))
{
task_queue_size_ = static_cast<int32_t>(value);
}
else if (0 == strcmp(name, OBMS_TASK_THREAD_COUNT))
{
task_thread_count_ = static_cast<int32_t>(value);
}
else if (0 == strcmp(name, OBMS_TASK_LEFT_TIME))
{
task_left_time_ = value;
}
else if (0 == strcmp(name, OBMS_LOG_INTERVAL_COUNT))
{
log_interval_count_ = value;
}
else if (0 == strcmp(name, OBMS_NETWORK_TIMEOUT))
{
network_time_out_ = value;
}
else if (0 == strcmp(name, OBMS_LEASE_INTERVAL))
{
check_lease_interval_ = value;
}
else if (0 == strcmp(name, OBMS_MONITOR_INTERVAL))
{
monitor_interval_ = value;
}
else if (0 == strcmp(name, OBMS_UPSLIST_INTERVAL))
{
fetch_ups_interval_ = value;
}
else if (0 == strcmp(name, OBMS_UPSVERION_TIMEOT))
{
frozen_version_timeout_ = value;
}
else if (0 == strcmp(name, OBMS_BLACKLIST_TIMEOUT))
{
ups_blacklist_timeout_ = value;
}
else if (0 == strcmp(name, OBMS_BLACKLIST_FAIL_COUNT))
{
ups_fail_count_ = value;
}
else if (0 == strcmp(name, OBMS_LOCATION_CACHE_SIZE))
{
location_cache_size_ = static_cast<int32_t>(value) * 1024 * 1024L;
}
else if (0 == strcmp(name, OBMS_LOCATION_CACHE_TIMEOUT))
{
location_cache_timeout_ = value;
}
else if (0 == strcmp(name, OBMS_INTERMEDIATE_BUFFER_SIZE))
{
intermediate_buffer_size_ = value * (1024*1024);
}
else if (0 == strcmp(name, OBMS_MAX_REQ_PROCESS_TIME))
{
max_req_process_time_ = value;
}
else if (0 == strcmp(name, OBMS_MEMORY_SIZE_LIMIT_PERCENT))
{
memory_size_limit_ = value * (sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGE_SIZE)) / 100;
}
else if (0 == strcmp(name, OBMS_MAX_CS_TIMEOUT_PERCENT))
{
max_cs_timeout_percent_ = static_cast<double>(value) / 100.0f;
//.........这里部分代码省略.........