本文整理汇总了C++中ObObj::get_varchar方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::get_varchar方法的具体用法?C++ ObObj::get_varchar怎么用?C++ ObObj::get_varchar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObObj
的用法示例。
在下文中一共展示了ObObj::get_varchar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int ObStringBuf :: write_obj(const ObObj& obj, ObObj* stored_obj)
{
int err = OB_SUCCESS;
if (NULL != stored_obj)
{
*stored_obj = obj;
}
ObObjType type = obj.get_type();
if (ObVarcharType == type)
{
ObString value;
ObString new_value;
obj.get_varchar(value);
err = write_string(value, &new_value);
if (OB_SUCCESS == err)
{
if (NULL != stored_obj)
{
stored_obj->set_varchar(new_value);
}
}
}
return err;
}
示例2: 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;
}
示例3: get_str_obj_value
int get_str_obj_value(const char* buf, const int64_t buf_len, int64_t & pos, ObString & str_value)
{
int ret = OB_SUCCESS;
ObObj obj;
if ( OB_SUCCESS == (ret = obj.deserialize(buf, buf_len, pos))
&& ObVarcharType == obj.get_type())
{
ret = obj.get_varchar(str_value);
}
return ret;
}
示例4: find
int64_t ObSimpleCond::find(const ObObj & pattern, const uint64_t pattern_sign, const ObObj & src)
{
int64_t pos = -1;
ObString str_pattern;
ObString str_src;
int ret = pattern.get_varchar(str_pattern);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "get varchar type failed from pattern:[%d]", ret);
}
else
{
ret = src.get_varchar(str_src);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "get varchar type failed from src:[%d]", ret);
}
else
{
pos = ObStringSearch::kr_search(str_pattern, pattern_sign, str_src);
}
}
return pos;
}
示例5: calc_sign
int ObSimpleCond::calc_sign(const ObObj & operand, uint64_t & sign)
{
ObString pattern;
int ret = operand.get_varchar(pattern);
if ((ret != OB_SUCCESS) || (pattern.length() == 0))
{
ret = OB_ERROR;
TBSYS_LOG(ERROR, "get varchar pattern or check length failed:len[%d], ret[%d]",
pattern.length(), ret);
}
else
{
sign = ObStringSearch::cal_print(pattern);
}
return ret;
}
示例6: 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;
}
示例7: write_varchar
int ObUpsCompactCellWriter::write_varchar(const ObObj &value, ObObj *clone_value)
{
int ret = OB_SUCCESS;
ObString varchar_value;
ObString varchar_written;
value.get_varchar(varchar_value);
if(varchar_value.length() > INT32_MAX)
{
ret = OB_SIZE_OVERFLOW;
TBSYS_LOG(WARN, "varchar is too long:[%d]", varchar_value.length());
}
if(OB_SUCCESS == ret)
{
ret = buf_writer_.write<int32_t>((int32_t)(varchar_value.length()));
}
if(OB_SUCCESS == ret)
{
if(varchar_value.length() <= (int64_t)sizeof(const char*))
{
ret = buf_writer_.write_varchar(varchar_value, &varchar_written);
}
else
{
if(NULL != mem_tank_)
{
ret = mem_tank_->write_string(varchar_value, &varchar_written);
if(OB_SUCCESS == ret)
{
ret = buf_writer_.write<const char*>(varchar_written.ptr());
}
}
else
{
ret = buf_writer_.write<const char*>(varchar_value.ptr());
}
}
}
if(OB_SUCCESS == ret && NULL != clone_value)
{
clone_value->set_varchar(varchar_written);
}
return ret;
}
示例8: 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;
}
示例9: obj_cast
int obj_cast(ObObj &cell, const ObObjType expected_type, char* buf, int64_t buf_size, int64_t &used_buf_len)
{
int ret = OB_SUCCESS;
used_buf_len = 0;
if (cell.get_type() != expected_type)
{
ObObjCastParams params;
ObExprObj from;
ObExprObj to;
from.assign(cell);
if (ObVarcharType == expected_type)
{
string buffer;
buffer.assign(buf, static_cast<int32_t> (buf_size));
ObObj varchar_cell;
varchar_cell.set_varchar(buffer);
to.assign(varchar_cell);
}
if (OB_SUCCESS != (ret = OB_OBJ_CAST[cell.get_type()][expected_type](params, from, to)))
{
jlog(WARNING, "failed to type cast obj, err=%d", ret);
}
else if (OB_SUCCESS != (ret = to.to(cell)))
{
jlog(WARNING, "failed to convert expr_obj to obj, err=%d", ret);
}
else
{
if (ObVarcharType == expected_type)
{
string varchar;
cell.get_varchar(varchar);
used_buf_len = varchar.length(); // used buffer length for casting to varchar type
}
}
}
return ret;
}
示例10: 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;
}
示例11: compare_same_type
int ObObj::compare_same_type(const ObObj &other) const
{
int cmp = 0;
switch(get_type())
{
case ObIntType:
if (this->value_.int_val < other.value_.int_val)
{
cmp = -1;
}
else if (this->value_.int_val == other.value_.int_val)
{
cmp = 0;
}
else
{
cmp = 1;
}
break;
case ObDecimalType:
{
ObNumber n1, n2;
get_decimal(n1);
other.get_decimal(n2);
cmp = n1.compare(n2);
break;
}
case ObVarcharType:
{
ObString varchar1, varchar2;
this->get_varchar(varchar1);
other.get_varchar(varchar2);
cmp = varchar1.compare(varchar2);
break;
}
case ObFloatType:
{
bool float_eq = fabsf(value_.float_val - other.value_.float_val) < FLOAT_EPSINON;
if (float_eq)
{
cmp = 0;
}
else if (this->value_.float_val < other.value_.float_val)
{
cmp = -1;
}
else
{
cmp = 1;
}
break;
}
case ObDoubleType:
{
bool double_eq = fabs(value_.double_val - other.value_.double_val) < DOUBLE_EPSINON;
if (double_eq)
{
cmp = 0;
}
else if (this->value_.double_val < other.value_.double_val)
{
cmp = -1;
}
else
{
cmp = 1;
}
break;
}
case ObDateTimeType:
case ObPreciseDateTimeType:
case ObCreateTimeType:
case ObModifyTimeType:
{
int64_t ts1 = 0;
int64_t ts2 = 0;
get_timestamp(ts1);
other.get_timestamp(ts2);
if (ts1 < ts2)
{
cmp = -1;
}
else if (ts1 == ts2)
{
cmp = 0;
}
else
{
cmp = 1;
}
break;
}
case ObBoolType:
cmp = this->value_.bool_val - other.value_.bool_val;
break;
default:
TBSYS_LOG(ERROR, "invalid type=%d", get_type());
break;
}
return cmp;
//.........这里部分代码省略.........
示例12: 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;
//.........这里部分代码省略.........