本文整理汇总了C++中ObObj::get_timestamp方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::get_timestamp方法的具体用法?C++ ObObj::get_timestamp怎么用?C++ ObObj::get_timestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObObj
的用法示例。
在下文中一共展示了ObObj::get_timestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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;
//.........这里部分代码省略.........