当前位置: 首页>>代码示例>>C++>>正文


C++ ObObj::get_decimal方法代码示例

本文整理汇总了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;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:101,代码来源:ob_object.cpp

示例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;
//.........这里部分代码省略.........
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:101,代码来源:ob_object.cpp


注:本文中的ObObj::get_decimal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。