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


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

本文整理汇总了C++中ObObj::set_int方法的典型用法代码示例。如果您正苦于以下问题:C++ ObObj::set_int方法的具体用法?C++ ObObj::set_int怎么用?C++ ObObj::set_int使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObObj的用法示例。


在下文中一共展示了ObObj::set_int方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: schema

TEST_F(TestMutatorParamDecoder, test_decode)
{
  ObSchemaManagerV2 schema(100);
  tbsys::CConfig config;
  EXPECT_TRUE(schema.parse_from_file("schema.ini", config));
  ObCellInfo cell;
  ObCellInfo out_cell;
  char * no_name = (char*)"test_not_exist";
  char * tablename = (char*)"collect_info";
  char * columnname = (char*)"item_price";
  char * rowkey = (char*)"row_key";
  ObString table_name;
  ObString column_name;
  ObString row_key;
  table_name.assign(tablename, static_cast<int32_t>(strlen(tablename)));
  column_name.assign(columnname, static_cast<int32_t>(strlen(columnname)));
  row_key.assign(rowkey, static_cast<int32_t>(strlen(rowkey)));

  ObMutator mutator;
  int64_t count = 20;
  mutator.del_row(table_name, row_key);
  for (int64_t i = 0; i < count; ++i)
  {
    mutator.add(table_name, row_key, column_name, (int64_t)1, ObMutator::RETURN_NO_RESULT);
    mutator.add(table_name, row_key, column_name, i + 10, ObMutator::RETURN_UPDATE_RESULT);
  }
  mutator.del_row(table_name, row_key);
  
  ObUpdateCondition & cond = mutator.get_update_condition();
  ObObj obj;
  obj.set_int(1234);
  EXPECT_TRUE(OB_SUCCESS == cond.add_cond(table_name, row_key, column_name, LT, obj));
  EXPECT_TRUE(OB_SUCCESS == cond.add_cond(table_name, row_key, false));
  obj.set_int(1230);
  EXPECT_TRUE(OB_SUCCESS == cond.add_cond(table_name, row_key, column_name, GT, obj));
  EXPECT_TRUE(OB_SUCCESS == cond.add_cond(table_name, row_key, false));
  // succ
  ObMutator decode_mutator;
  ObGetParam org_param;
  ObGetParam decode_param;
  EXPECT_TRUE(OB_SUCCESS == ObMutatorParamDecoder::decode(mutator, schema, decode_mutator, org_param, decode_param));
  // decode mutator
  EXPECT_TRUE(decode_mutator.get_update_condition().get_count() == cond.get_count());
  // need return
  EXPECT_TRUE(org_param.get_cell_size() == count);
  // need prefetch
  EXPECT_TRUE(decode_param.get_cell_size() == (count + cond.get_count()));

  // failed
  table_name.assign(no_name, static_cast<int32_t>(strlen(no_name)));
  for (int64_t i = 0; i < count; ++i)
  {
    mutator.add(table_name, row_key, column_name, (int64_t)1, ObMutator::RETURN_NO_RESULT);
    mutator.add(table_name, row_key, column_name, i + 10, ObMutator::RETURN_UPDATE_RESULT);
  }
  org_param.reset();
  decode_param.reset();
  decode_mutator.reset();
  EXPECT_TRUE(OB_SUCCESS != ObMutatorParamDecoder::decode(mutator, schema, decode_mutator, org_param, decode_param));
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:60,代码来源:test_merger_mutator_decoder.cpp

示例2: OK

TEST_F(ObRowUtilTest, basic_test1)
{
  char buf[1024];
  ObCompactCellWriter cell_writer;
  OK(cell_writer.init(buf, 1024, SPARSE));

  ObObj value;
  ObRowDesc row_desc;
  for(int64_t i=0;i<10;i++)
  {
    row_desc.add_column_desc(TABLE_ID, i);
    value.set_int(i);
    OK(cell_writer.append(i, value));
  }
  OK(cell_writer.row_finish());

  ObString compact_row;
  compact_row.assign_ptr(cell_writer.get_buf(), (int32_t)cell_writer.size());

  ObRow row;

  row.set_row_desc(row_desc);
  OK(ObRowUtil::convert(compact_row, row));

  const ObObj *cell = NULL;
  uint64_t column_id = OB_INVALID_ID;
  uint64_t table_id = OB_INVALID_ID;
  int64_t int_value = 0;
  for(int64_t i=0;i<10;i++)
  {
    OK(row.raw_get_cell(i, cell, table_id, column_id));
    cell->get_int(int_value);
    ASSERT_EQ(i, int_value);
  }
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:35,代码来源:test_row_util.cpp

示例3: auto_set_val

/* only support integer and string */
void ObScannerLoader::auto_set_val(ObObj &val, char *buf)
{
  if (NULL == buf)
  {
    TBSYS_LOG(ERROR, "invalid scanner data input");
  }
  else
  {
    int len = static_cast<int32_t>(strlen(buf));
    int i = 0;
    ObString tmpstr;
    bool is_num = true;

    for(i = 0; i < len; i++)
    {
      if (!isdigit(buf[i]))
      {
        is_num = false;
        break;
      }
    }

    if (is_num)
    {
      val.set_int(atoi(buf));
    }
    else
    {
      tmpstr.assign(buf, static_cast<int32_t>(strlen(buf)));
      val.set_varchar(tmpstr);
    }
    //val.dump();
  }
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:35,代码来源:ob_scanner_loader.cpp

示例4:

TEST(TestObInsertDBSemFilter, child_not_empty)
{
  ObInsertDBSemFilter dbi;
  ObRowDesc row_desc;
  row_desc.add_column_desc(1001, 16);
  row_desc.add_column_desc(1001, 17);
  row_desc.add_column_desc(1001, 101);
  row_desc.add_column_desc(1001, 102);
  ObRowDescExt row_desc_ext;
  ObObj type;
  type.set_int(0);
  row_desc_ext.add_column_desc(1001, 16, type);
  row_desc_ext.add_column_desc(1001, 17, type);
  row_desc_ext.add_column_desc(1001, 101, type);
  row_desc_ext.add_column_desc(1001, 102, type);
  ObValues cc;
  dbi.get_values().set_row_desc(row_desc, row_desc_ext);
  cc.set_row_desc(row_desc);
  build_values(10, row_desc, dbi.get_values(), cc);

  dbi.set_child(0, cc);

  int ret = dbi.open();
  EXPECT_EQ(OB_ERR_PRIMARY_KEY_DUPLICATE, ret);

  const ObRow *row = NULL;
  ret = dbi.get_next_row(row);
  EXPECT_EQ(OB_ITER_END, ret);

  ret = dbi.close();
  EXPECT_EQ(OB_SUCCESS, ret);
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:32,代码来源:test_insert_dbsem_filter.cpp

示例5: get_mutator

int CellinfoBuilder::get_mutator(const ObString &row_key, const ObSchema &schema, int64_t &cur_seed,
                                ObMutator &mutator, PageArena<char> &allocer)
{
  int ret = OB_SUCCESS;
  
  int64_t sign = ob_crc64(row_key.ptr(), row_key.length());
  uint64_t table_id = schema.get_table_id();
  sign = ob_crc64(sign, &table_id, sizeof(uint64_t));

  struct drand48_data rand_data;
  cur_seed += 1;
  srand48_r(sign + cur_seed, &rand_data);

  int64_t rand = 0;
  lrand48_r(&rand_data, &rand);
  
  int64_t op_num = range_rand(1, max_op_num_, rand);
  for (int64_t i = 0; i < op_num; i++)
  {
    ret = build_operator_(rand_data, row_key, schema, mutator, allocer);
    if (OB_SUCCESS != ret)
    {
      break;
    }
  }
  ObString table_name;
  table_name.assign_ptr(const_cast<char*>(schema.get_table_name()), strlen(schema.get_table_name()));
  ObString column_name;
  column_name.assign_ptr(SEED_COLUMN_NAME, strlen(SEED_COLUMN_NAME));
  ObObj obj;
  obj.set_int(cur_seed);
  mutator.update(table_name, row_key, column_name, obj);

  return ret;
}
开发者ID:CCoder123,项目名称:pproj,代码行数:35,代码来源:cellinfo_builder.cpp

示例6: free

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);
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:32,代码来源:test_ob_object.cpp

示例7: build_values

void build_values(const int64_t row_count, ObRowDesc &row_desc, ObExprValues &values1, ObValues &values2)
{
  for (int64_t i = 0; i < row_count; i++)
  {
    ObRow row;
    row.set_row_desc(row_desc);
    for (int64_t j = 0; j < row_desc.get_column_num(); j++)
    {
      uint64_t table_id = OB_INVALID_ID;
      uint64_t column_id = OB_INVALID_ID;
      row_desc.get_tid_cid(j, table_id, column_id);
      ObObj obj;
      obj.set_int(i + j);
      row.set_cell(table_id, column_id, obj); 

      ObSqlExpression se;
      se.set_tid_cid(table_id, column_id);
      ExprItem ei;
      ei.type_ = T_INT;
      ei.value_.int_ = i + j;
      se.add_expr_item(ei);
      //ei.type_ = T_REF_COLUMN;
      //ei.value_.cell_.tid = table_id;
      //ei.value_.cell_.cid = column_id;
      //se.add_expr_item(ei);
      se.add_expr_item_end();

      values1.add_value(se);
    }
    //values1.add_values(row);
    values2.add_values(row);
  }
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:33,代码来源:test_insert_dbsem_filter.cpp

示例8: schema

TEST_F(TestParamDecoder, test_decode_cond_cell)
{
  ObSchemaManagerV2 schema(100);
  tbsys::CConfig config;
  EXPECT_TRUE(schema.parse_from_file("schema.ini", config));
  ObCondInfo cond;
  ObCellInfo out_cell;
  char * no_name = (char*)"test_not_exist";
  char * tablename = (char*)"collect_info";
  char * columnname = (char*)"item_price";
  char * rowkey = (char*)"rowkey_test";
  ObString table_name;
  ObString column_name;
  ObRowkey row_key;

  // NORMAL TYPE
  // table name not exist and column not exist
  table_name.assign(no_name, static_cast<int32_t>(strlen(no_name)));
  column_name.assign(no_name, static_cast<int32_t>(strlen(no_name)));
  row_key = make_rowkey(rowkey, &allocator_);
  ObObj obj;
  obj.set_int(1234);
  cond.set(NE, table_name, row_key, column_name, obj);
  EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell));

  // table name not exist but column exist
  table_name.assign(no_name, static_cast<int32_t>(strlen(no_name)));
  column_name.assign(columnname, static_cast<int32_t>(strlen(columnname)));
  cond.set(NE, table_name, row_key, column_name, obj);
  EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell));

  // table name exist but column not exist
  table_name.assign(tablename, static_cast<int32_t>(strlen(tablename)));
  column_name.assign(no_name, static_cast<int32_t>(strlen(no_name)));
  cond.set(NE, table_name, row_key, column_name, obj);
  EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell));

  // table name exist and column exist
  table_name.assign(tablename, static_cast<int32_t>(strlen(tablename)));
  column_name.assign(columnname, static_cast<int32_t>(strlen(columnname)));
  cond.set(NE, table_name, row_key, column_name, obj);
  EXPECT_TRUE(OB_SUCCESS == ObParamDecoder::decode_cond_cell(cond, schema, out_cell));

  // EXIST TYPE
  // table name not exist
  table_name.assign(no_name, static_cast<int32_t>(strlen(no_name)));
  row_key = make_rowkey(rowkey, &allocator_);
  cond.set(table_name, row_key, false);
  EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell));
  cond.set(table_name, row_key, true);
  EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell));

  // table name exist
  table_name.assign(tablename, static_cast<int32_t>(strlen(tablename)));
  cond.set(table_name, row_key, true);
  EXPECT_TRUE(OB_SUCCESS == ObParamDecoder::decode_cond_cell(cond, schema, out_cell));
  cond.set(table_name, row_key, false);
  EXPECT_TRUE(OB_SUCCESS == ObParamDecoder::decode_cond_cell(cond, schema, out_cell));
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:59,代码来源:test_merger_param_decoder.cpp

示例9: set_int_obj_value

 int set_int_obj_value(char * buf, const int64_t buf_len, int64_t & pos, const int64_t value)
 {
   int ret = OB_SUCCESS;
   ObObj obj;
   obj.set_int(value);
   ret = obj.serialize(buf, buf_len, pos);
   return ret;
 }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:8,代码来源:ob_common_param.cpp

示例10:

ScanConds::ScanConds(const char* column_name, const ObLogicOperator& cond_op, int64_t value)
{
  ObString name;
  name.assign_ptr(const_cast<char*>(column_name), static_cast<int32_t>(strlen(column_name)));

  ObObj obj;
  obj.set_int(value);

  EasyArray<ObSimpleCond>(ObSimpleCond(name, cond_op, obj));
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:10,代码来源:nb_scan_cond.cpp

示例11: get_reserve_param_serialize_size

 int64_t ObReadParam::get_reserve_param_serialize_size(void) const
 {
   ObObj obj;
   // reserve for read master
   obj.set_ext(ObActionFlag::RESERVE_PARAM_FIELD);
   int64_t total_size = obj.get_serialize_size();
   obj.set_int(get_is_read_consistency());
   total_size += obj.get_serialize_size();
   return total_size;
 }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:10,代码来源:ob_common_param.cpp

示例12: serialize_int

    int ObSqlGetParam::serialize_int(char* buf, const int64_t buf_len, int64_t& pos,
        const int64_t value) const
    {
      int ret = OB_SUCCESS;
      ObObj obj;

      obj.set_int(value);
      ret = obj.serialize(buf, buf_len, pos);

      return ret;
    }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:11,代码来源:ob_sql_get_param.cpp

示例13: serialize_reserve_param

 int ObReadParam::serialize_reserve_param(char * buf, const int64_t buf_len, int64_t & pos) const
 {
   ObObj obj;
   // serialize RESERVER PARAM FIELD
   obj.set_ext(ObActionFlag::RESERVE_PARAM_FIELD);
   int ret = obj.serialize(buf, buf_len, pos);
   if (ret == OB_SUCCESS)
   {
     obj.set_int(get_is_read_consistency());
     ret = obj.serialize(buf, buf_len, pos);
   }
   return ret;
 }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:13,代码来源:ob_common_param.cpp

示例14: get_basic_param_serialize_size

 int64_t ObSqlScanParam::get_basic_param_serialize_size(void) const
 {
   int64_t total_size = 0;
   ObObj obj;
   // BASIC_PARAM_FIELD
   obj.set_ext(ObActionFlag::BASIC_PARAM_FIELD);
   total_size += obj.get_serialize_size();
   // scan range
   obj.set_int(range_.table_id_);
   total_size += obj.get_serialize_size();
   obj.set_int(range_.border_flag_.get_data());
   total_size += obj.get_serialize_size();
   // start_key_
   total_size += get_rowkey_obj_array_size(
       range_.start_key_.get_obj_ptr(), range_.start_key_.get_obj_cnt());
   // end_key_
   total_size += get_rowkey_obj_array_size(
       range_.end_key_.get_obj_ptr(), range_.end_key_.get_obj_cnt());
   obj.set_int(scan_flag_.flag_);
   total_size += obj.get_serialize_size();
   return total_size;
 }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:22,代码来源:ob_sql_scan_param.cpp

示例15:

TEST(ObObj, test_bug)
{
  ObObj obj;
  obj.set_int(100, false);
  char buf[2048];
  int64_t len = 2048;
  int64_t pos = 0;
  ASSERT_EQ(obj.serialize(buf, len, pos), OB_SUCCESS);

  pos = 0;
  ObObj temp;
  temp.set_int(200, true);
  temp.reset();

  ASSERT_EQ(temp.deserialize(buf, len, pos), OB_SUCCESS);
  ASSERT_EQ(temp == obj, true);

  ObObj test;
  test.set_int(300, true);
  test = temp;
  ASSERT_EQ(test == temp, true);
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:22,代码来源:test_ob_object.cpp


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