Exemplo n.º 1
0
TEST(ObObj,Serialize_int_add)
{
  ObObj t;
  t.set_int(9900);

  int64_t len = t.get_serialize_size();

  ASSERT_EQ(len,3);

  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);

  int64_t r = 0;
  int64_t l = 0;

  ASSERT_EQ(f.get_type(),t.get_type());
  f.get_int(r);

  t.get_int(l);
  ASSERT_EQ(r,l);

  free(buf);
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
TEST(ObObj,int_boundary)
{
  int64_t need_len = 0;

  int64_t data[] = {1,28,-1,INT32_MIN,static_cast<int64_t>(UINT32_MAX),INT64_MAX,INT64_MIN,UINT64_MAX,124543900};
  for(uint32_t i=0;i<sizeof(data)/sizeof(data[0]);++i)
  {
    need_len += serialization::encoded_length_int(data[i]);
  }
  char *buf = (char *)malloc(need_len);
  ObObj t;
  int64_t pos = 0;

  for(uint32_t i=0;i<sizeof(data)/sizeof(data[0]);++i)
  {
    t.reset();
    t.set_int(data[i]);
    ASSERT_EQ(t.serialize(buf,need_len,pos),OB_SUCCESS);
  }

  pos = 0;

  int64_t v = 0;
  for(uint32_t i=0;i<sizeof(data)/sizeof(data[0]);++i)
  {
    t.reset();
    ASSERT_EQ(t.deserialize(buf,need_len,pos),OB_SUCCESS);
    ASSERT_EQ(t.get_int(v),OB_SUCCESS);
    ASSERT_EQ(v,data[i]);
  }
  free(buf);
}
Exemplo n.º 4
0
int ObUpsExecutor::set_trans_params(ObSQLSessionInfo *session, common::ObTransReq &req)
{
  int ret = OB_SUCCESS;
  // get isolation level etc. from session
  ObObj val;
  ObString isolation_str;
  int64_t tx_timeout_val = 0;
  int64_t tx_idle_timeout = 0;
  if (OB_SUCCESS != (ret = session->get_sys_variable_value(ObString::make_string("tx_isolation"), val)))
  {
    TBSYS_LOG(WARN, "failed to get tx_isolation value, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = val.get_varchar(isolation_str)))
  {
    TBSYS_LOG(WARN, "wrong obj type, err=%d", ret);
    ret = OB_ERR_UNEXPECTED;
  }
  else if (OB_SUCCESS != (ret = req.set_isolation_by_name(isolation_str)))
  {
    TBSYS_LOG(WARN, "failed to set isolation level, err=%d", ret);
    ret = OB_ERR_UNEXPECTED;
  }
  else if (OB_SUCCESS != (ret = session->get_sys_variable_value(ObString::make_string("ob_tx_timeout"), val)))
  {
    TBSYS_LOG(WARN, "failed to get tx_timeout value, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = val.get_int(tx_timeout_val)))
  {
    TBSYS_LOG(WARN, "wrong obj type, err=%d", ret);
    ret = OB_ERR_UNEXPECTED;
  }
  else if (OB_SUCCESS != (ret = session->get_sys_variable_value(ObString::make_string("ob_tx_idle_timeout"), val)))
  {
    TBSYS_LOG(WARN, "failed to get tx_idle_timeout value, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = val.get_int(tx_idle_timeout)))
  {
    TBSYS_LOG(WARN, "wrong obj type, err=%d", ret);
    ret = OB_ERR_UNEXPECTED;
  }
  else
  {
    req.timeout_ = tx_timeout_val;
    req.idle_time_ = tx_idle_timeout;
  }
  return ret;
}
Exemplo n.º 5
0
    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;
    }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 int ObReadParam::deserialize_reserve_param(const char * buf, const int64_t data_len, int64_t & pos)
 {
   ObObj obj;
   int64_t int_value = 0;
   int ret = obj.deserialize(buf, data_len, pos);
   if (OB_SUCCESS == ret)
   {
     ret = obj.get_int(int_value);
     if (OB_SUCCESS == ret)
     {
       //is read master
       set_is_read_consistency(int_value);
     }
   }
   return ret;
 }
Exemplo n.º 8
0
TEST(ObObj, performance)
{
  // int64_t start_time = tbsys::CTimeUtil::getTime();
  //const int64_t MAX_COUNT = 10 * 1000 * 1000L;
  const int64_t MAX_COUNT = 1000L;
  ObObj obj;
  char buf[2048];
  int64_t len = 2048;
  int64_t pos = 0;
  int64_t data = 0;
  for (int64_t i = 0; i < MAX_COUNT; ++i)
  {
    obj.set_int(i);
    pos = 0;
    ASSERT_EQ(obj.serialize(buf, len, pos), OB_SUCCESS);
    pos = 0;
    ASSERT_EQ(obj.deserialize(buf, len, pos), OB_SUCCESS);
    ASSERT_EQ(obj.get_int(data), OB_SUCCESS);
    ASSERT_EQ(data, i);
  }

  const char *tmp = "Hello12344556666777777777777545352454254254354354565463241242354345345345235345";
  ObObj obj2;
  ObString string;
  ObString string2;
  string.assign_ptr(const_cast<char *>(tmp), 1024);
  obj2.set_varchar(string);
  for (register int64_t i = 0; i < MAX_COUNT; ++i )
  {
    pos = 0;
    ASSERT_EQ(obj2.serialize(buf, len, pos), OB_SUCCESS);
    pos = 0;
    ASSERT_EQ(obj2.deserialize(buf, len, pos), OB_SUCCESS);
    ASSERT_EQ(obj2.get_varchar(string2), OB_SUCCESS);
  }
  // int64_t end_time = tbsys::CTimeUtil::getTime();
  //printf("using time:%ld\n", end_time - start_time);
}
Exemplo n.º 9
0
    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;
    }
Exemplo n.º 10
0
    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)
          {
            renamed_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);
        }
      }

      if (OB_SUCCESS == ret)
      {
        if (OB_SUCCESS != (ret = obj.deserialize(buf, data_len, pos)))
        {
          TBSYS_LOG(WARN, "fail to deserialize obj:ret[%d]", ret);
        }
        else if (OB_SUCCESS != (ret = obj.get_bool(only_static_data_)))
        {
          TBSYS_LOG(WARN, "fail to get bool:ret[%d]", ret);
        }
      }
      return ret;
    }
Exemplo n.º 11
0
int ObResultSet::open()
{
  int ret = common::OB_SUCCESS;
  ObObj val;
  int64_t plan_timeout = OB_DEFAULT_STMT_TIMEOUT;

  if (OB_UNLIKELY(NULL == physical_plan_))
  {
    if (ObBasicStmt::T_PREPARE != stmt_type_)
    {
      TBSYS_LOG(WARN, "physical_plan not init, stmt_type=%d", stmt_type_);
      ret = common::OB_NOT_INIT;
    }
  }
  else
  {
    // get current frozen version
    OB_ASSERT(my_session_);
    FILL_TRACE_LOG("curr_frozen_version=%s", to_cstring(my_session_->get_frozen_version()));
    physical_plan_->set_curr_frozen_version(my_session_->get_frozen_version());

       ///  query timeout for sql level
    if (OB_SUCCESS == my_session_->get_sys_variable_value(ObString::make_string(OB_QUERY_TIMEOUT_PARAM), val))
    {
      if (OB_SUCCESS != val.get_int(plan_timeout))
      {
        TBSYS_LOG(WARN, "fail to get query timeout from session, ret=%d", ret);
        plan_timeout = OB_DEFAULT_STMT_TIMEOUT; // use default
      }
    }
    physical_plan_->set_timeout_timestamp(plan_timeout + tbsys::CTimeUtil::getTime());
    ObPhyOperator *main_query = physical_plan_->get_main_query();
    ObPhyOperator *pre_query = physical_plan_->get_pre_query();

    if (NULL != pre_query)
    {
      ret = pre_query->open();
      FILL_TRACE_LOG("pre_query finished");
      if (OB_SUCCESS != ret)
      {
        TBSYS_LOG(WARN, "failed to open pre_query, ret=%d", ret);
      }
    }

    if (OB_SUCCESS == ret)
    {
      if (NULL == main_query)
      {
        ret = OB_ERR_UNEXPECTED;
        TBSYS_LOG(ERROR, "main query must not be NULL");
      }
      else
      {
        ret = main_query->open();
        FILL_TRACE_LOG("main_query finished");
        if (OB_SUCCESS != ret)
        {
          TBSYS_LOG(WARN, "failed to open main query, ret=%d", ret);
        }
      }
    }
  }
  set_errcode(ret);
  return ret;
}
Exemplo n.º 12
0
    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)
            {
              value.double_val += mutation_value.double_val;
            }
            else
            {
              value.double_val = mutation_value.double_val;
            }
            set_double(value.double_val, (org_is_add || org_is_nop) && is_add);
          }
          break;
        case ObDateTimeType:
          if (ext_val_can_change || org_is_nop)
          {
            set_datetime(0);
          }
          err = get_datetime(value.second_val,org_is_add);
          if (OB_SUCCESS == err)
          {
            err = mutation.get_datetime(mutation_value.second_val,is_add);
          }
          if (OB_SUCCESS == err)
          {
            if (is_add)
            {
              value.second_val += mutation_value.second_val;
            }
            else
            {
              value.second_val = mutation_value.second_val;
            }
            set_datetime(value.second_val,is_add && (org_is_add || org_is_nop));
          }
          break;
        case ObPreciseDateTimeType:
          if (ext_val_can_change || org_is_nop)
          {
            set_precise_datetime(0);
          }
          err = get_precise_datetime(value.microsecond_val,org_is_add);
          if (OB_SUCCESS == err)
          {
            err = mutation.get_precise_datetime(mutation_value.microsecond_val,is_add);
          }
          if (OB_SUCCESS == err)
          {
            if (is_add)
            {
              value.microsecond_val += mutation_value.microsecond_val;
            }
            else
            {
              value.microsecond_val = mutation_value.microsecond_val;
            }
            set_precise_datetime(value.microsecond_val,is_add && (org_is_add || org_is_nop));
          }
          break;
        case ObExtendType:
          switch (mutation.get_ext())
          {
          case ObActionFlag::OP_DEL_ROW:
          case ObActionFlag::OP_DEL_TABLE:
            /// used for join, if right row was deleted, set the cell to null
            set_null();
            break;
          case ObActionFlag::OP_ROW_DOES_NOT_EXIST:
            /// do nothing
            break;
          case ObActionFlag::OP_NOP:
            if (get_ext() == ObActionFlag::OP_ROW_DOES_NOT_EXIST
              || get_ext() == ObActionFlag::OP_DEL_ROW)
            {
              set_null();
            }
            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;
        default:
          /* case ObSeqType: */
          TBSYS_LOG(ERROR,"unsupported type [type:%d]", static_cast<int32_t>(mutation.get_type()));
          err = OB_INVALID_ARGUMENT;
          break;
        }
      }
      if(OB_SUCCESS != err)
      {
        TBSYS_LOG(WARN,"fail to apply [this->type:%ld,this->ext:%ld,mutation->type:%d,mutation->ext:%ld, err:%d]", 
          org_type, org_ext, mutation.get_type(), mutation.get_ext(), err);
      }
      return err;
    }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
    int ObMergeServerParams::update_item(const ObObj &item_name, const ObObj &item_value)
    {
      int ret = OB_SUCCESS;
      static const int max_name_len = 256;
      char name[max_name_len];
      int64_t value = 0;
      ObString str;

      if (OB_SUCCESS != (ret = item_name.get_varchar(str)))
      {
        TBSYS_LOG(WARN, "fail to get item name value. ret=%d", ret);
      }
      else if (str.length() < max_name_len)
      {
        strncpy(name, str.ptr(), str.length());
        name[str.length()] = '\0';
      }
      else
      {
        TBSYS_LOG(WARN, "item name too long. are you sure about this? item_name len=%d, max=%d", str.length(), max_name_len);
      }

      if ((OB_SUCCESS == ret) && (OB_SUCCESS != (ret = item_value.get_int(value))))
      {
        TBSYS_LOG(WARN, "fail to get value. expect int type");
      }

      if (OB_SUCCESS == ret)
      {
        if (0 == strcmp(name, OBMS_RETRY_TIMES))
        {
          retry_times_ = static_cast<int32_t>(value);
        }
        else if (0 == strcmp(name,  OBMS_TASK_QUEUE_SIZE))
        {
          task_queue_size_ = static_cast<int32_t>(value);
        }
        else if (0 == strcmp(name,  OBMS_TASK_THREAD_COUNT))
        {
          task_thread_count_ = static_cast<int32_t>(value);
        }
        else if (0 == strcmp(name,  OBMS_TASK_LEFT_TIME))
        {
          task_left_time_ = value;
        }
        else if (0 == strcmp(name,  OBMS_LOG_INTERVAL_COUNT))
        {
          log_interval_count_ = value;
        }
        else if (0 == strcmp(name,  OBMS_NETWORK_TIMEOUT))
        {
          network_time_out_ = value;
        }
        else if (0 == strcmp(name,  OBMS_LEASE_INTERVAL))
        {
          check_lease_interval_ = value;
        }
        else if (0 == strcmp(name,  OBMS_MONITOR_INTERVAL))
        {
          monitor_interval_ = value;
        }
        else if (0 == strcmp(name,  OBMS_UPSLIST_INTERVAL))
        {
          fetch_ups_interval_ = value;
        }
        else if (0 == strcmp(name,  OBMS_UPSVERION_TIMEOT))
        {
          frozen_version_timeout_ = value;
        }
        else if (0 == strcmp(name,  OBMS_BLACKLIST_TIMEOUT))
        {
          ups_blacklist_timeout_ = value;
        }
        else if (0 == strcmp(name,  OBMS_BLACKLIST_FAIL_COUNT))
        {
          ups_fail_count_ = value;
        }
        else if (0 == strcmp(name,  OBMS_LOCATION_CACHE_SIZE))
        {
          location_cache_size_ = static_cast<int32_t>(value) * 1024 * 1024L;
        }
        else if (0 == strcmp(name,  OBMS_LOCATION_CACHE_TIMEOUT))
        {
          location_cache_timeout_ = value;
        }
        else if (0 == strcmp(name,  OBMS_INTERMEDIATE_BUFFER_SIZE))
        {
          intermediate_buffer_size_  = value * (1024*1024);
        }
        else if (0 == strcmp(name,  OBMS_MAX_REQ_PROCESS_TIME))
        {
          max_req_process_time_ = value;
        }
        else if (0 == strcmp(name,  OBMS_MEMORY_SIZE_LIMIT_PERCENT))
        {
          memory_size_limit_ = value * (sysconf(_SC_PHYS_PAGES)*sysconf(_SC_PAGE_SIZE)) / 100;
        }
        else if (0 == strcmp(name, OBMS_MAX_CS_TIMEOUT_PERCENT))
        {
          max_cs_timeout_percent_ = static_cast<double>(value) / 100.0f;
        }
        else if (0 == strcmp(name,  OBMS_ALLOW_RETURN_UNCOMPLETE_RESULT))
        {
          allow_return_uncomplete_result_ = static_cast<int32_t>(value);
        }
        else if (0 == strcmp(name,  OBMS_MAX_PARELLEL_COUNT))
        {
          max_parellel_count_ = value;
        }
        else if (0 == strcmp(name,  OBMS_MAX_GET_ROWS_PER_SUBREQ))
        {
          max_get_rows_per_subreq_ = value;
        }
        else if (0 == strcmp(name,  OBMS_GET_REQUEST_FACTOR))
        {
          get_request_factor_ = value;
        }
        else if (0 == strcmp(name,  OBMS_SCAN_REQUEST_FACTOR))
        {
          scan_request_factor_ = value;
        }
        else if (0 == strcmp(name,  OBMS_SLOW_QUERY_THRESHOLD))
        {
          slow_query_threshold_ = value;
        }
        else
        {
          TBSYS_LOG(ERROR, "unexpected config item name. name=%s", name);
          ret = OB_ERROR;
        }
      }
      return ret;
    }