本文整理汇总了C++中ObObj::get_decimal方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::get_decimal方法的具体用法?C++ ObObj::get_decimal怎么用?C++ ObObj::get_decimal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObObj
的用法示例。
在下文中一共展示了ObObj::get_decimal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
//.........这里部分代码省略.........
}
break;
default:
TBSYS_LOG(ERROR,"unsupported ext value [value:%ld]", mutation.get_ext());
err = OB_INVALID_ARGUMENT;
break;
}
break;
case ObCreateTimeType:
err = mutation.get_createtime(create_time);
if (OB_SUCCESS == err)
{
if (ext_val_can_change || org_is_nop)
{
set_createtime(create_time);
}
}
if (OB_SUCCESS == err)
{
err = get_createtime(value.create_time_val);
}
if (OB_SUCCESS == err)
{
err = mutation.get_createtime(mutation_value.create_time_val);
}
if (OB_SUCCESS == err)
{
set_createtime(std::min<ObCreateTime>(value.create_time_val,mutation_value.create_time_val));
}
break;
case ObModifyTimeType:
err = mutation.get_modifytime(modify_time);
if (OB_SUCCESS == err)
{
if (ext_val_can_change || org_is_nop)
{
set_modifytime(modify_time);
}
}
if (OB_SUCCESS == err)
{
err = get_modifytime(value.modify_time_val);
}
if (OB_SUCCESS == err)
{
err = mutation.get_modifytime(mutation_value.modify_time_val);
}
if (OB_SUCCESS == err)
{
set_modifytime(std::max<ObCreateTime>(value.modify_time_val,mutation_value.modify_time_val));
}
break;
case ObDecimalType:
{
ObNumber num, mutation_num, res;
if (ext_val_can_change || org_is_nop)
{
num.set_zero();
}
else
{
err = get_decimal(num, org_is_add);
}
if (OB_SUCCESS == err)
{
err = mutation.get_decimal(mutation_num, is_add);
}
if (OB_SUCCESS == err)
{
if (is_add)
{
err = num.add(mutation_num, res);
}
else
{
res = mutation_num;
}
}
if (OB_SUCCESS == err)
{
set_decimal(res, meta_.dec_precision_, meta_.dec_scale_, (org_is_add || org_is_nop) && is_add);
}
break;
}
default:
/* case ObSeqType: */
TBSYS_LOG(ERROR,"unsupported type [type:%d]", mut_type);
err = OB_INVALID_ARGUMENT;
break;
}
}
if(OB_SUCCESS != err)
{
TBSYS_LOG(WARN,"fail to apply [this->type:%d,this->ext:%d,"
"mutation->type:%d,mutation->ext:%ld, err:%d]",
org_type, org_ext, mut_type, mutation.get_ext(), err);
}
return err;
}
示例2: 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;
//.........这里部分代码省略.........