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


C++ ObObj类代码示例

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


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

示例1: TEST

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

示例2: obj_cast

 int obj_cast(const ObObj &orig_cell, const ObObj &expected_type,
         ObObj &casted_cell, const ObObj *&res_cell)
 {
     int ret = OB_SUCCESS;
     if (orig_cell.get_type() != expected_type.get_type())
     {
         // type cast
         ObObjCastParams params;
         ObExprObj from;
         ObExprObj to;
         from.assign(orig_cell);
         to.assign(casted_cell);
         if (OB_SUCCESS != (ret = OB_OBJ_CAST[orig_cell.get_type()][expected_type.get_type()](params, from, to)))
         {
             jlog(WARNING, "failed to type cast obj, err=%d", ret);
         }
         else if (OB_SUCCESS != (ret = to.to(casted_cell)))
         {
             jlog(WARNING, "failed to convert expr_obj to obj, err=%d", ret);
         }
         else
         {
             res_cell = &casted_cell;
         }
     }
     else
     {
         res_cell = &orig_cell;
     }
     return ret;
 }
开发者ID:b-xiang,项目名称:sql_parser-1,代码行数:31,代码来源:ob_obj_cast.cpp

示例3: TEST_F

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

示例4: 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

示例5: TEST

TEST(ObObj,Serialize_bool)
{
  ObObj t;
  t.set_bool(true);

  int64_t len = t.get_serialize_size();

  ASSERT_EQ(len,2);

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

  bool r = false;
  bool l = false;

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

  t.get_bool(l);
  ASSERT_EQ(r,l);
  free(buf);
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:30,代码来源:test_ob_object.cpp

示例6: TEST_F

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

示例7: write_obj

    int ObStringBuf :: write_obj(const ObObj& obj, ObObj* stored_obj)
    {
      int err = OB_SUCCESS;

      if (NULL != stored_obj)
      {
        *stored_obj = obj;
      }

      ObObjType type = obj.get_type();
      if (ObVarcharType == type)
      {
        ObString value;
        ObString new_value;
        obj.get_varchar(value);
        err = write_string(value, &new_value);
        if (OB_SUCCESS == err)
        {
          if (NULL != stored_obj)
          {
            stored_obj->set_varchar(new_value);
          }
        }
      }

      return err;
    }
开发者ID:CCoder123,项目名称:pproj,代码行数:27,代码来源:ob_string_buf.cpp

示例8: TEST_F

      TEST_F(ObTabletJoinTest, get_right_table_rowkey)
      {
        ObRowDesc row_desc;
        row_desc.add_column_desc(LEFT_TABLE_ID, 1);

        const char *rowkey_str = "oceanbase";
        ObString row_key_str;
        row_key_str.assign_ptr(const_cast<char *>(rowkey_str), (int32_t)strlen(rowkey_str));

        ObObj row_key_obj;
        row_key_obj.set_varchar(row_key_str);

        ObRowkey row_key;
        row_key.assign(&row_key_obj, 1);

        ObObj value;
        value.set_varchar(row_key_str);

        ObRow row;
        row.set_row_desc(row_desc);
        row.raw_set_cell(0, value);

        ObObj rowkey_obj[OB_MAX_ROWKEY_COLUMN_NUMBER];
        ObRowkey rowkey2;

        ObTabletCacheJoin tablet_join;
        tablet_join.set_table_join_info(tablet_join_info_);

        OK(tablet_join.get_right_table_rowkey(row, rowkey2, rowkey_obj));
        ASSERT_TRUE(row_key == rowkey2);
      }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:31,代码来源:ob_tablet_join_test.cpp

示例9: ob_crc64

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

示例10: 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

示例11:

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;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:28,代码来源:ob_meta_table3.cpp

示例12: TEST_F

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

示例13: set_str_obj_value

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

示例14: 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

示例15:

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

  ObObj obj;
  obj.set_varchar(value);

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


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