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


C++ ObString::assign方法代码示例

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


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

示例1: pat

      TEST_F(TestObStringSearch, test_kr_fast_print)
      {
        const char *pattern[8]={"Free softw","d be free "," socially ","bjects—su"," that it c","y. These p","abcdefghigklmnopqrstuvwxyzABCDEFGIJKLMNOPQRSTUVWXYZ", "hellohello"};

        const char *text    = "Free software is a matter of freedom: people should be free to use software in all the ways that are socially useful. Software differs from material objects—such as chairs, sandwiches, and gasoline—in that it can be copied and changed much more easily. These possibilities make software as useful as abcdefghigklmnopqrstuvwxyzABCDEFGIJKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz it is; we believe software use";
        ObString txt;
        txt.assign(const_cast<char*>(text), strlen(text));
        for (int i = 0; i < 8; ++i)
        {
          ObString pat(strlen(pattern[i]), strlen(pattern[i]), const_cast<char*>(pattern[i]));
          uint64_t pat_print = ObStringSearch::cal_print(pat);
          if ( 7 == i)
          {
            EXPECT_EQ(-1, ObStringSearch::kr_search(pat, pat_print, txt));
            EXPECT_EQ(-1, ObStringSearch::kr_search(pat, txt));
            EXPECT_EQ(-1, ObStringSearch::fast_search(pat, txt));
          }
          else
          {
            EXPECT_EQ(0, memcmp(pattern[i], text+ObStringSearch::kr_search(pat, pat_print, txt), strlen(pattern[i])));
            EXPECT_TRUE(0 ==  memcmp(pattern[i], text+ObStringSearch::kr_search(pat, txt), strlen(pattern[i])));
            EXPECT_TRUE(0 ==  memcmp(pattern[i], text+ObStringSearch::fast_search(pat, txt), strlen(pattern[i])));
          }
          EXPECT_TRUE(ObStringSearch::kr_search(pat, pat_print, txt) == ObStringSearch::kr_search(pat, txt));
          EXPECT_TRUE(ObStringSearch::kr_search(pat, txt) == ObStringSearch::fast_search(pat, txt));
        }
      }
开发者ID:CCoder123,项目名称:pproj,代码行数:27,代码来源:test_ob_string_search.cpp

示例2: memset

TEST_F(ObSqlExpressionTest, copy_operator_test)
{
  ObString stdstring;
  stdstring.assign((char*)"hello world", 11);

  ObSqlExpression p;
  ExprItem item_b;
  item_b.type_ = T_STRING;
  item_b.string_.assign((char*)"hello world", 11);
  p.add_expr_item(item_b);

  ObRow row;
  const ObObj *result = NULL;
  p.add_expr_item_end();
  p.calc(row, result);

  //int64_t re;
  ObString mystring;
  EXPECT_EQ(OB_SUCCESS, result->get_varchar(mystring));
  EXPECT_EQ(mystring, stdstring);

  // test deep copy
  ObSqlExpression q;
  q = p;
  p.~ObSqlExpression();
  memset(&p, 0, sizeof(p));
  EXPECT_EQ(OB_SUCCESS, q.calc(row, result));
  EXPECT_EQ(OB_SUCCESS, result->get_varchar(mystring));
  EXPECT_EQ(mystring, stdstring);
  TBSYS_LOG(INFO, "%.*s", mystring.length(), mystring.ptr());
  //ASSERT_EQ();
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:32,代码来源:ob_sql_expression_test.cpp

示例3: update

int ObMergerTabletLocationCache::update(const uint64_t table_id, const ObString & rowkey,
    const ObMergerTabletLocationList & location)
{
  int ret = OB_SUCCESS;
  if (!init_)
  {
    TBSYS_LOG(ERROR, "%s", "check init failed");
    ret = OB_INNER_STAT_ERROR;
  }
  else if ((0 == rowkey.length()) || (NULL == rowkey.ptr()))
  {
    TBSYS_LOG(ERROR, "%s", "check rowkey length failed");
    ret = OB_INPUT_PARAM_ERROR;
  }
  else
  {
    char * temp = (char *)ob_malloc(sizeof(table_id) + rowkey.length(),ObModIds::OB_MS_LOCATION_CACHE);
    if (NULL == temp)
    {
      TBSYS_LOG(ERROR, "check ob malloc failed:size[%lu], pointer[%p]", 
          sizeof(table_id) + rowkey.length(), temp);
      ret = OB_ALLOCATE_MEMORY_FAILED;
    }
    else
    {
      ObRange range;
      ObString CacheKey;
      // encode table_id + rowkey as CacheKey
      *((uint64_t *) temp) = table_id;
      memcpy(temp + sizeof(uint64_t), rowkey.ptr(), rowkey.length());
      CacheKey.assign(temp, static_cast<int32_t>(sizeof(table_id) + rowkey.length()));
      // get the pair according to the key
      ObCachePair pair;
      ret = tablet_cache_.get(CacheKey, pair);
      if (OB_SUCCESS != ret)
      {
        TBSYS_LOG(DEBUG, "find tablet from cache failed:table_id[%lu], length[%d]",
            table_id, rowkey.length());
      }
      else
      {
        int64_t pos = 0;
        // TODO double check pair.key whether as equal with CacheKey
        ret = range.deserialize(pair.get_key().ptr(), pair.get_key().length(), pos);
        if (OB_SUCCESS != ret)
        {
          TBSYS_LOG(ERROR, "deserialize tablet range failed:table_id[%lu], ret[%d]",
              table_id, ret);
        }
        else
        {
          ret = set(range, location);
        }
      }
      // destory the temp buffer
      ob_free(temp);
    }
  }
  return ret;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:60,代码来源:ob_ms_tablet_location.cpp

示例4: add_columns_conf

int TaskFactory::add_columns_conf(const uint64_t table_id, common::ObScanParam & param, const TableConf *conf)
{
  int ret = OB_SUCCESS;
  TableConf::ColumnIterator itr = conf->column_begin();

  ObString column;
  while (itr != conf->column_end())
  {
    const char *column_name = *itr;
    if (conf->is_null_column(column_name) || conf->is_rowkey(column_name))
    {
      itr++;
      continue;
    }

    TBSYS_LOG(DEBUG, "columns with conf, column = %s", column_name);
    column.assign(const_cast<char *>(*itr), (int32_t)strlen(column_name));
    ret = param.add_column(column);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "add column failed:table[%lu], column[%s], ret[%d]",
                table_id, column_name, ret);
      ret = OB_ERROR;
      break;
    }

    itr++;
  }

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

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

示例6: start_key

TEST_F(TestCacheTable, test_compare)
{
  char temp[100];
  char temp_end[100];
  ObRange range;
  sprintf(temp, "%d", 1001);
  sprintf(temp_end, "%d", 100100);
  ObString start_key(100, static_cast<int32_t>(strlen(temp)), temp);
  ObString end_key(100, static_cast<int32_t>(strlen(temp_end)), temp_end);
  range.start_key_ = start_key;
  range.end_key_ = end_key;
  range.table_id_ = 100;

  ObCBtreeTable<int, int>::MapKey key;
  ObString rowkey;
  // bad case bug
  char * cmp_key = (char*)"100";
  rowkey.assign(cmp_key, static_cast<int32_t>(strlen(cmp_key)));
  ObBorderFlag row_key_flag;
  int ret = key.compare_range_with_key(100, rowkey, row_key_flag, ObCBtreeTable<int, int>::OB_SEARCH_MODE_EQUAL, range);
  // bug fix EXPECT_TRUE(ret == 0);
  EXPECT_TRUE(ret < 0);
  
  // good case 
  cmp_key = (char*)"10010";
  rowkey.assign(cmp_key, static_cast<int32_t>(strlen(cmp_key)));
  ret = key.compare_range_with_key(100, rowkey, row_key_flag, ObCBtreeTable<int, int>::OB_SEARCH_MODE_EQUAL, range);
  EXPECT_TRUE(ret == 0);

  cmp_key = (char*)"101";
  rowkey.assign(cmp_key, static_cast<int32_t>(strlen(cmp_key)));
  ret = key.compare_range_with_key(100, rowkey, row_key_flag, ObCBtreeTable<int, int>::OB_SEARCH_MODE_EQUAL, range);
  EXPECT_TRUE(ret > 0);
  
  cmp_key = (char*)"1001002";
  rowkey.assign(cmp_key, static_cast<int32_t>(strlen(cmp_key)));
  ret = key.compare_range_with_key(100, rowkey, row_key_flag, ObCBtreeTable<int, int>::OB_SEARCH_MODE_EQUAL, range);
  EXPECT_TRUE(ret > 0);
  
  // bad case bug
  cmp_key = (char*)"10010002";
  rowkey.assign(cmp_key, static_cast<int32_t>(strlen(cmp_key)));
  ret = key.compare_range_with_key(100, rowkey, row_key_flag, ObCBtreeTable<int, int>::OB_SEARCH_MODE_EQUAL, range);
  // buf fix EXPECT_TRUE(ret == 0);
  EXPECT_TRUE(ret > 0);
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:46,代码来源:test_merger_cache_table.cpp

示例7: build_get_param

    int ObPermInfoKey::build_get_param(ObGetParam & get_param)
    {
      int ret = OB_SUCCESS;
      ObCellInfo cell_info;
      ObString rowkey;
      ObVersionRange ver_range;
      int64_t pos = 0;
      if (NULL == buffer_)
      {
        buffer_ = reinterpret_cast<char*>(ob_malloc(BUF_SIZE));
      }

      if (NULL != buffer_)
      {
        int64_t encode_pos = pos;        
        ret = serialization::encode_i64(buffer_, BUF_SIZE, encode_pos, table_id_);
        if (OB_SUCCESS != ret)
        {
          TBSYS_LOG(ERROR, "encode failed table_id=%ld", table_id_);
        }
        else
        {
          memcpy(buffer_ + encode_pos, user_name_, length_);
          encode_pos += length_;
          rowkey.assign(buffer_ + pos, static_cast<int32_t>(encode_pos - pos));
          get_param.set_is_result_cached(true);
          cell_info.table_id_  = PERM_TABLE_ID;
          cell_info.row_key_   = rowkey;
          cell_info.column_id_ = PERM_COL_ID;
          ret = get_param.add_cell(cell_info);
          if (OB_SUCCESS != ret)
          {
            TBSYS_LOG(ERROR, "Get param add cell failed table_id[%lu]", cell_info.table_id_);
          }
          else
          {
            ver_range.start_version_ = 0;
            ver_range.end_version_   = INT64_MAX - 1;
            ver_range.border_flag_.set_inclusive_start();
            ver_range.border_flag_.set_inclusive_end();
            get_param.set_version_range(ver_range);
          }
        }
      }
      else
      {
        TBSYS_LOG(ERROR, "malloc key buffer failed");
        ret = OB_ERROR;
      }
      return ret;
    }
开发者ID:Abioy,项目名称:oceanbase,代码行数:51,代码来源:ob_meta_cache.cpp

示例8: write_cg_sstable

int write_cg_sstable(const ObCellInfo** cell_infos,
    const int64_t row_num, const int64_t col_num, const char* sstable_file_path )
{
  int err = OB_SUCCESS;
  EXPECT_TRUE(NULL != cell_infos);
  EXPECT_TRUE(row_num > 0);
  EXPECT_TRUE(col_num > 0);

  if (sstable_file_path) unlink(sstable_file_path);

  ObSSTableSchema sstable_schema;
  generate_cg_schema(sstable_schema, cell_infos, 12, 0, 1);
  generate_cg_schema(sstable_schema, cell_infos, 13, 1, 3);
  generate_cg_schema(sstable_schema, cell_infos, 15, 3, col_num);

  ObString path;
  ObString compress_name;
  const char* path_str = NULL;
  if (NULL != sstable_file_path)
  {
    path_str = sstable_file_path;
  }
  else
  {
    path_str = DEF_SSTABLE_PATH;
  }
  path.assign((char*) path_str, static_cast<int32_t>(strlen(path_str)));
  compress_name.assign((char*)"lzo", static_cast<int32_t>(strlen("lzo")));

  ObSSTableWriter writer;
  uint64_t table_id = cell_infos[0][0].table_id_;
  err = writer.create_sstable(sstable_schema, path, compress_name, table_id);
  EXPECT_EQ(0, err);

  err = append_cg_rows(writer, cell_infos, 12, row_num, 0, 1);
  EXPECT_EQ(0, err);
  err = append_cg_rows(writer, cell_infos, 13, row_num, 1, 3);
  EXPECT_EQ(0, err);
  err = append_cg_rows(writer, cell_infos, 15, row_num, 3, col_num);
  EXPECT_EQ(0, err);

  int64_t offset = 0;
  err = writer.close_sstable(offset);
  EXPECT_EQ(0, err);

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

示例9: add_all_columns

int TaskFactory::add_all_columns(const uint64_t table_id, ObScanParam & param)
{
  int ret = OB_SUCCESS;
  int32_t count = 0;
  const ObColumnSchemaV2 * column_schema = schema_->get_table_schema(table_id, count);
  if ((NULL == column_schema) || (0 == count))
  {
    ret = OB_ERROR;
    TBSYS_LOG(ERROR, "check column schema or schema count failed:column[%p], count[%d]",
        column_schema, count);
  }
  else
  {
    ObString column;
    const char * column_name = NULL;
    for (int32_t i = 0; i < count; ++i)
    {
      column_name = column_schema->get_name();
      if (column_name != NULL)
      {
        TBSYS_LOG(DEBUG, "TableId:%ld, COLUMN=%s", table_id, column_name);

        column.assign(const_cast<char *>(column_name), (int32_t)strlen(column_name));
        ret = param.add_column(column);
        if (ret != OB_SUCCESS)
        {
          TBSYS_LOG(ERROR, "add column failed:table[%lu], column[%s], ret[%d]",
              table_id, column_name, ret);
          ret = OB_ERROR;
          break;
        }
      }
      else
      {
        ret = OB_ERROR;
        TBSYS_LOG(ERROR, "check column name failed:table[%lu], name[%s]", table_id, column_name);
        break;
      }
      ++column_schema;
    }
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:43,代码来源:task_factory.cpp

示例10: if

ObCellInfo *callback_func_get_cell_info(const char* column_name)
{
  TBSYS_LOG(INFO, "%s", column_name);
  if (0 == strcmp(column_name, "name"))
  {
    ObString str;
    str.assign(config_item_1, (int32_t)strlen(config_item_1));
    my_cell_info[0].value_.set_varchar(str);
    return &my_cell_info[0];
  }
  else if (0 == strcmp(column_name, "value"))
  {
    my_cell_info[1].value_.set_int(102);
    return &my_cell_info[1];
  }
  else
  {
    return NULL;
  }
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:20,代码来源:ob_ms_config_proxy_test.cpp

示例11: del

int ObMergerTabletLocationCache::del(const uint64_t table_id, const ObString & rowkey)
{
  int ret = OB_SUCCESS;
  if (!init_)
  {
    TBSYS_LOG(ERROR, "%s", "check init failed");
    ret = OB_INNER_STAT_ERROR;
  }
  else
  {
    char * temp = (char *)ob_malloc(sizeof(table_id) + rowkey.length(), ObModIds::OB_MS_LOCATION_CACHE);
    if (NULL == temp)
    {
      TBSYS_LOG(ERROR, "check ob malloc failed:size[%lu], pointer[%p]", 
          sizeof(table_id) + rowkey.length(), temp);
      ret = OB_ALLOCATE_MEMORY_FAILED;
    }
    else
    {
      // construct table_id + rowkey to CacheKey as cache key
      ObString CacheKey;
      *(reinterpret_cast<uint64_t *>(temp)) = table_id;
      memcpy(temp + sizeof(uint64_t), rowkey.ptr(), rowkey.length());
      CacheKey.assign(temp, static_cast<int32_t>(sizeof(table_id) + rowkey.length()));
      ret = tablet_cache_.remove(CacheKey);
      if (OB_SUCCESS != ret)
      {
        TBSYS_LOG(DEBUG, "find this row tablet failed:table_id[%lu], length[%d]", 
            table_id, rowkey.length());
      }
      else
      {
        TBSYS_LOG(DEBUG, "%s", "del this location from cache succ");
      }
      // destory the temp buffer
      ob_free(temp);
    }
  }
  return ret;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:40,代码来源:ob_ms_tablet_location.cpp

示例12: main

int main(int argc, char ** argv)
{
  UNUSED(argc);
  UNUSED(argv);
  int ret = OB_SUCCESS;
  //char * test = "00596331192663719";
  char * test = "00912219024438372";
  ObString rowkey;
  rowkey.assign(test, strlen(test));
  char temp[1024];
  hex_to_str(rowkey.ptr(), rowkey.length(), temp, 1024);
  printf("test2str:test[%s], str[%s]\n", test, temp);

  int64_t ip = 539289610; //488957962; //522512394;
  ObServer server;
  server.set_ipv4_addr(ip, 1024);
  static const int32_t MAX_SERVER_ADDR_SIZE = 128;
  char server_addr[MAX_SERVER_ADDR_SIZE];
  server.to_string(server_addr, MAX_SERVER_ADDR_SIZE);
  printf("server:[%ld], server[%s]\n", ip, server_addr);
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:22,代码来源:dump2str.cpp

示例13: ObString

TEST(get_next_param, orderby)
{
  ObStringBuf buf;
  ObScanParam scan_param; 
  ObRange q_range;
  ObScanner prev_result; 
  int64_t prev_limit_offset = 0;
  ObRange prev_tablet_range;

  ObRange cur_range;
  int64_t cur_limit_offset = 0;

  uint64_t table_id = 1001;

  /// last tablet and full fill
  q_range.border_flag_.set_max_value();
  q_range.border_flag_.set_min_value();
  EXPECT_EQ(scan_param.set(table_id, ObString(),q_range), OB_SUCCESS);
  //scan_param.set_scan_direction(ObScanParam::BACKWARD);
  prev_tablet_range.border_flag_.set_max_value();
  prev_tablet_range.border_flag_.set_min_value();
  EXPECT_EQ(scan_param.add_orderby_column(0),OB_SUCCESS);

  const char *c_ptr = "9";
  ObString str;
  ObCellInfo cell;
  str.assign((char*)c_ptr, static_cast<int32_t>(strlen(c_ptr)));
  EXPECT_EQ(buf.write_string(str, &cell.row_key_),OB_SUCCESS);
  EXPECT_EQ(prev_result.add_cell(cell),OB_SUCCESS);
  EXPECT_EQ(prev_result.set_is_req_fullfilled(false,1), OB_SUCCESS);
  EXPECT_EQ(prev_result.set_range(prev_tablet_range), OB_SUCCESS);

  EXPECT_EQ(get_next_range(scan_param, prev_result,prev_limit_offset,cur_range,cur_limit_offset,buf), OB_SUCCESS);
  EXPECT_EQ(cur_limit_offset, 1);
  EXPECT_TRUE(cur_range.border_flag_.is_min_value());
  EXPECT_TRUE(cur_range.border_flag_.is_max_value()); 
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:37,代码来源:test_param_modifier.cpp

示例14: sizeof

TEST(ObGroupByParam, function)
{
  char serialize_buf[2048];
  int64_t buf_len = sizeof(serialize_buf);
  int64_t pos = 0;
  int64_t data_len = 0;
  /// row width 7;
  /// 0, not used int
  /// 1, groupby int
  /// 2, return int
  /// 3, group str
  /// 4, group int
  /// 5, aggregate column int
  /// 6. not used string
  ObCellArray org_cell_array;
  /// row width 6
  /// 0, group int
  /// 1, group str
  /// 2, return int
  /// 3, return str
  /// 4, aggregate sum
  /// 5, aggregate count
  /// ObCellArray agg_cell_array;
  ObGroupByOperator agg_operator;
  /// ObCellArray all_in_one_group_agg_cell_array;
  ObGroupByOperator all_in_one_group_agg_operator;
  ObStringBuf buffer;
  ObGroupByParam param;
  ObGroupByParam all_in_one_group_param;
  ObGroupByParam decoded_param;
  int64_t basic_column_num = 4;
  for (int64_t i = 0; i <= basic_column_num; i++)
  {
    /// 1, 3
    if (i%2)
    {
      EXPECT_EQ(param.add_groupby_column(i),OB_SUCCESS);
    }
  }
  for (int64_t i = 0; i <= basic_column_num; i++)
  {
    /// 2, 4
    if (i%2 == 0 && i > 0)
    {
      EXPECT_EQ(param.add_return_column(i),OB_SUCCESS);
    }
  }
  /// 5
  EXPECT_EQ(param.add_aggregate_column(basic_column_num+1,SUM),OB_SUCCESS);
  EXPECT_EQ(param.add_aggregate_column(basic_column_num+1,COUNT),OB_SUCCESS);
  EXPECT_EQ(all_in_one_group_param.add_aggregate_column(basic_column_num + 1, SUM), OB_SUCCESS);
  EXPECT_EQ(all_in_one_group_param.add_aggregate_column(basic_column_num + 1, COUNT), OB_SUCCESS);

  pos = 0;
  EXPECT_EQ(param.serialize(serialize_buf,buf_len,pos), OB_SUCCESS);
  data_len = pos;
  pos = 0;
  EXPECT_EQ(decoded_param.deserialize(serialize_buf,data_len,pos),OB_SUCCESS);
  EXPECT_EQ(pos,data_len);
  EXPECT_TRUE(decoded_param == param);

  EXPECT_EQ(agg_operator.init(param, 1024*1024*1024),OB_SUCCESS);
  EXPECT_EQ(all_in_one_group_agg_operator.init(all_in_one_group_param, 1024*1024*1024),OB_SUCCESS);

  int64_t agg_sum = 0;
  int64_t agg_count = 0;
  ObCellInfo cell;
  ObInnerCellInfo *cell_out = NULL;
  ObString str;
  ObObj return_str_obj;
  ObObj groupby_str_obj;
  const int64_t no_int_value = -1;
  const int64_t return_int_value = 0;
  ObObj return_int_obj;
  return_int_obj.set_int(return_int_value);
  const int64_t groupby_int_value = 1;
  ObObj groupby_int_obj;
  groupby_int_obj.set_int(groupby_int_value);

  ObObj agg_sum_obj;
  ObObj agg_count_obj;
  /// prepare first row in org cell array
  /// cell not used, 0
  cell.value_.set_int(no_int_value);
  EXPECT_EQ(org_cell_array.append(cell, cell_out),OB_SUCCESS);
  /// groupby cell, 1
  cell.value_.set_int(groupby_int_value);
  EXPECT_EQ(org_cell_array.append(cell, cell_out),OB_SUCCESS);
  /// return cell, 2
  cell.value_.set_int(return_int_value);
  EXPECT_EQ(org_cell_array.append(cell, cell_out),OB_SUCCESS);
  /// groupby cell, 3
  str.assign(const_cast<char*>("groupby"),static_cast<int32_t>(strlen("groupby")));
  cell.value_.set_varchar(str);
  EXPECT_EQ(org_cell_array.append(cell, cell_out),OB_SUCCESS);
  groupby_str_obj = cell_out->value_;
  /// return cell, 4
  str.assign(const_cast<char*>("return"),static_cast<int32_t>(strlen("return")));
  cell.value_.set_varchar(str);
  EXPECT_EQ(org_cell_array.append(cell, cell_out),OB_SUCCESS);
//.........这里部分代码省略.........
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:101,代码来源:test_groupby_operator.cpp

示例15:

TEST(ObGroupByParam, row_change)
{
  ObGroupByParam param;
  ObGroupByOperator groupby_operator;
  int64_t groupby_idx =  0;
  int64_t agg_idx = 1;
  ObAggregateFuncType agg_func = SUM;
  EXPECT_EQ(param.add_groupby_column(groupby_idx), OB_SUCCESS);
  EXPECT_EQ(param.add_aggregate_column(agg_idx, agg_func),OB_SUCCESS);
  ObStringBuf buffer;
  ObString str;
  const char *c_str = NULL;
  ObRowkey rowkey;
  ObCellInfo org_cell_info;
  ObCellArray org_cells;
  ObInnerCellInfo  *cell_out;
  ObString table_name;
  c_str = "table";
  str.assign((char*)c_str, static_cast<int32_t>(strlen(c_str)));
  EXPECT_EQ(buffer.write_string(str,&(table_name)), OB_SUCCESS);
  org_cell_info.table_name_ = table_name;

  c_str = "abc";
  rowkey = make_rowkey(c_str, &allocator_);
  EXPECT_EQ(buffer.write_string(rowkey,&(org_cell_info.row_key_)), OB_SUCCESS);

  int groupby_one_val = 1;
  org_cell_info.value_.set_int(groupby_one_val);
  EXPECT_EQ(org_cells.append(org_cell_info, cell_out),OB_SUCCESS);
  EXPECT_EQ(org_cells.append(org_cell_info, cell_out),OB_SUCCESS);

  int groupby_two_val = 2;
  c_str = "def";
  rowkey = make_rowkey(c_str, &allocator_);
  EXPECT_EQ(buffer.write_string(rowkey,&(org_cell_info.row_key_)), OB_SUCCESS);
  org_cell_info.value_.set_int(groupby_two_val);
  EXPECT_EQ(org_cells.append(org_cell_info, cell_out),OB_SUCCESS);
  EXPECT_EQ(org_cells.append(org_cell_info, cell_out),OB_SUCCESS);

  EXPECT_EQ(groupby_operator.init(param,1024*1024*10), OB_SUCCESS);
  EXPECT_EQ(groupby_operator.add_row(org_cells,0,1), OB_SUCCESS);
  EXPECT_EQ(groupby_operator.add_row(org_cells, 2,3), OB_SUCCESS);

  EXPECT_EQ(groupby_operator.get_cell_size(), 4);

  bool is_row_changed = false;
  EXPECT_EQ(groupby_operator.next_cell(), OB_SUCCESS);
  EXPECT_EQ(groupby_operator.get_cell(&cell_out, &is_row_changed), OB_SUCCESS);
  EXPECT_TRUE(is_row_changed);

  EXPECT_EQ(groupby_operator.next_cell(), OB_SUCCESS);
  EXPECT_EQ(groupby_operator.get_cell(&cell_out, &is_row_changed), OB_SUCCESS);
  EXPECT_FALSE(is_row_changed);

  EXPECT_EQ(groupby_operator.next_cell(), OB_SUCCESS);
  EXPECT_EQ(groupby_operator.get_cell(&cell_out, &is_row_changed), OB_SUCCESS);
  EXPECT_TRUE(is_row_changed);

  EXPECT_EQ(groupby_operator.next_cell(), OB_SUCCESS);
  EXPECT_EQ(groupby_operator.get_cell(&cell_out, &is_row_changed), OB_SUCCESS);
  EXPECT_FALSE(is_row_changed);

  EXPECT_EQ(groupby_operator.next_cell(), OB_ITER_END);
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:64,代码来源:test_groupby_operator.cpp


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