本文整理汇总了C++中ObObj::get_type方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::get_type方法的具体用法?C++ ObObj::get_type怎么用?C++ ObObj::get_type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObObj
的用法示例。
在下文中一共展示了ObObj::get_type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj_cast
int obj_cast(const ObObj &orig_cell, const ObObj &expected_type,
ObObj &casted_cell, const ObObj *&res_cell)
{
int ret = OB_SUCCESS;
if (orig_cell.get_type() != expected_type.get_type())
{
// type cast
ObObjCastParams params;
ObExprObj from;
ObExprObj to;
from.assign(orig_cell);
to.assign(casted_cell);
if (OB_SUCCESS != (ret = OB_OBJ_CAST[orig_cell.get_type()][expected_type.get_type()](params, from, to)))
{
jlog(WARNING, "failed to type cast obj, err=%d", ret);
}
else if (OB_SUCCESS != (ret = to.to(casted_cell)))
{
jlog(WARNING, "failed to convert expr_obj to obj, err=%d", ret);
}
else
{
res_cell = &casted_cell;
}
}
else
{
res_cell = &orig_cell;
}
return ret;
}
示例2:
int ObMetaTable3::MyIterator::check_rowkey_obj_type(int32_t rowkey_obj_idx, const ObObj &obj) const
{
int ret = OB_SUCCESS;
bool found = false;
for (int k = 0; k < table_schema_.columns_.count(); ++k)
{
const ColumnSchema &cschema = table_schema_.columns_.at(k);
if (rowkey_obj_idx + 1 == cschema.rowkey_id_) // rowkey_id start from 1
{
if (obj.get_type() != cschema.data_type_
&& (!obj.is_min_value())
&& (!obj.is_max_value()))
{
TBSYS_LOG(WARN, "invalid meta table row key, cid=%lu ctype=%d obj_type=%d",
cschema.column_id_, cschema.data_type_, obj.get_type());
break;
}
found = true;
break;
}
} // end for
if (!found)
{
TBSYS_LOG(WARN, "rowkey obj not found in table schema, idx=%d", rowkey_obj_idx);
ret = OB_ERR_DATA_FORMAT;
}
return ret;
}
示例3: free
TEST(ObObj,Serialize_bool)
{
ObObj t;
t.set_bool(true);
int64_t len = t.get_serialize_size();
ASSERT_EQ(len,2);
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);
bool r = false;
bool l = false;
ASSERT_EQ(f.get_type(),t.get_type());
f.get_bool(r);
t.get_bool(l);
ASSERT_EQ(r,l);
free(buf);
}
示例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: 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);
}
示例6:
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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: calc
bool ObSimpleCond::calc(const ObObj & left_operand) const
{
bool ret = false;
// skip nulltype for compare return false
switch (logic_operator_)
{
case LT:
{
if (ObNullType != left_operand.get_type())
{
ret = left_operand < right_operand_;
}
break;
}
case LE:
{
if (ObNullType != left_operand.get_type())
{
ret = left_operand <= right_operand_;
}
break;
}
case EQ:
{
ret = left_operand == right_operand_;
break;
}
case NE:
{
ret = left_operand != right_operand_;
break;
}
case GT:
{
if (ObNullType != left_operand.get_type())
{
ret = left_operand > right_operand_;
}
break;
}
case GE:
{
if (ObNullType != left_operand.get_type())
{
ret = left_operand >= right_operand_;
}
break;
}
case LIKE:
{
if (ObNullType != left_operand.get_type())
{
ret = find(right_operand_, pattern_sign_, left_operand) >= 0;
}
break;
}
default:
{
TBSYS_LOG(ERROR, "check condition logic type failed:type[%d]", logic_operator_);
}
}
return ret;
}
示例12: 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)
{
//.........这里部分代码省略.........
示例13: compare
int ObObj::compare(const ObObj &other) const
{
int cmp = 0;
ObObjType this_type = get_type();
ObObjType other_type = other.get_type();
if (!can_compare(other))
{
TBSYS_LOG(ERROR, "can not be compared, this_type=%d other_type=%d",
get_type(), other.get_type());
cmp = this_type - other_type;
}
else
{
// compare principle : min value < null type < normal object < max value;
if (is_min_value())
{
// min value == min value and less than any else
if (other.is_min_value())
{
cmp = 0;
}
else
{
cmp = -1;
}
}
else if (is_max_value())
{
// max value == max value and great than any else
if (other.is_max_value())
{
cmp = 0;
}
else
{
cmp = 1;
}
}
else if (this_type == ObNullType)
{
// null type == null type but less than any else type object.
// null type > min type
if (other.is_min_value())
{
// null type > min value
cmp = 1;
}
else if (other_type == ObNullType)
{
// null type == null type.
cmp = 0;
}
else
{
// null type < any of normal object type.
cmp = -1;
}
}
else if (other.is_min_value() || other_type == ObNullType)
{
// any of normal type (except null type) > (min value & null type)
cmp = 1;
}
else if (other.is_max_value())
{
cmp = -1;
}
/*
else if (this_type == ObNullType || other_type == ObNullType)
{
cmp = this_type - other_type;
}
*/
else
{
// okay finally, two object are normal object type.
cmp = this->compare_same_type(other);
}
}
return cmp;
}
示例14: 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)
//.........这里部分代码省略.........
示例15: 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;
}