Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}