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


C++ ObString类代码示例

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


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

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

示例2: TEST_F

      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

示例3: set_new_table_name

int ObAlterTableStmt::set_new_table_name(ResultPlan& result_plan, const ObString& table_name)
{
  int& ret = result_plan.err_stat_.err_code_ = OB_SUCCESS;

  ObSchemaChecker* schema_checker = NULL;
  if (name_pool_ == NULL)
  {
    ret = OB_NOT_INIT;
    snprintf(result_plan.err_stat_.err_msg_, MAX_ERROR_MSG,
        "Name pool need to be set, ret=%d", ret);
  }
  else if ((schema_checker = static_cast<ObSchemaChecker*>(result_plan.schema_checker_)) == NULL)
  {
    ret = OB_ERR_SCHEMA_UNSET;
    snprintf(result_plan.err_stat_.err_msg_, MAX_ERROR_MSG,
        "Schema(s) are not set");
  }
  else if(schema_checker->get_table_id(table_name) != OB_INVALID_ID)
  {
    ret = OB_ERR_TABLE_UNKNOWN;
    snprintf(result_plan.err_stat_.err_msg_, MAX_ERROR_MSG,
        "Table '%.*s' already exist", table_name.length(), table_name.ptr());
  }
  else if ((ret = ob_write_string(*name_pool_, table_name, new_table_name_)) != OB_SUCCESS)
  {
    snprintf(result_plan.err_stat_.err_msg_, MAX_ERROR_MSG,
        "Allocate memory for table name failed");
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:30,代码来源:ob_alter_table_stmt.cpp

示例4: TBSYS_LOG

 int64_t ObRowCellVec::get_serialize_size()const
 {
   int64_t res = 0;
   int err = OB_SUCCESS;
   if (NULL == row_ || 0 == row_->cell_num_)
   {
     err = OB_INVALID_ARGUMENT;
     TBSYS_LOG(WARN,"row not initialized");
   }
   if (OB_SUCCESS == err)
   {
     ObString value;
     res += sizeof(ObRow) + sizeof(ObMsCellInfo)*row_->cell_num_ + row_key_.length();
     for (int32_t i = 0; i < row_->cell_num_ && OB_SUCCESS == err; i++)
     {
       if (row_->cells_[i].value_.get_type() == ObVarcharType)
       {
         err = row_->cells_[i].value_.get_varchar(value);
         if (OB_SUCCESS == err)
         {
           res += value.length();
         }
         else
         {
           TBSYS_LOG(WARN,"unexpected error, get varchar [err:%d]",err);
         }
       }
     }
   }
   if (OB_SUCCESS != err)
   {
     res = 0;
   }
   return res;
 }
开发者ID:Abioy,项目名称:oceanbase,代码行数:35,代码来源:ob_row_cell_vec.cpp

示例5: TBSYS_LOG

uint64_t ObMetaTableColumnSchema::get_cid_by_idx(const int64_t i) const
{
  uint64_t ret = OB_INVALID_ID;
  if (i >= get_columns_num() || 0 > i)
  {
    TBSYS_LOG(ERROR, "invalid column index, i=%ld tid=%lu", i, table_schema_.table_id_);
  }
  else
  {
    ObString cname;
    const int buf_len = meta_table_cname::STARTKEY_OBJ_PREFIX.length() + 8;
    char cname_buf[buf_len];
    cname_buf[0] = '\0';
    if (i < static_cast<int64_t>(ARRAYSIZEOF(COLUMNS_NAME)))
    {
      cname = COLUMNS_NAME[i];
    }
    else
    {
      // start_rowkey_obj1, start_rowkey_obj2, ...
      int len = snprintf(cname_buf, buf_len, "%.*s%ld", meta_table_cname::STARTKEY_OBJ_PREFIX.length(),
                         meta_table_cname::STARTKEY_OBJ_PREFIX.ptr(), i - ARRAYSIZEOF(COLUMNS_NAME) + 1);
      cname.assign_ptr(cname_buf, len);      
    }
    if (OB_SUCCESS != get_cid_by_name(cname, ret))
    {
      TBSYS_LOG(ERROR, "meta table column not found, cname=%.*s tid=%lu",
                cname.length(), cname.ptr(), table_schema_.table_id_);
    }
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:32,代码来源:ob_meta_table_schema.cpp

示例6: TEST_F

TEST_F(ObObjCastTest, varchar_to_xxx)
{
    ObExprObj in;
    const char* cases[] = {"1970-1-1 8:0:0", "2012-9-24 16:59:60.000000", "-123456", "-123.456", "true", "false"};
    int64_t int_expected[ARRAYSIZEOF(cases)] = {1970, 2012, -123456, -123, 0, 0};
    float float_expected[ARRAYSIZEOF(cases)] = {1970.0f, 2012.0f, -123456.0f, -123.456f, 0.0f, 0.0f};
    double double_expected[ARRAYSIZEOF(cases)] = {1970.0, 2012.0, -123456.0, -123.456, 0.0, 0.0};
    int64_t pdt_expected[ARRAYSIZEOF(cases)] = {0, 1348477200000000, 0, 0, 0, 0};
    bool bool_expected[ARRAYSIZEOF(cases)] = {false, false, false, false, true, false};
    const char *dec_expected[ARRAYSIZEOF(cases)] = {"0", "0", "-123456", "-123.456", "0", "0"};

    for (int64_t i = 0; i < static_cast<int64_t>(ARRAYSIZEOF(cases)); ++i)
    {
        ObString v;
        v.assign_ptr(const_cast<char*>(cases[i]), static_cast<int32_t>(strlen(cases[i])));
        in.set_varchar(v);
        //printf("case %ld: %s\n", i, cases[i]);
        MY_EXPECT(ObVarcharType, in, ObNullType, int_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObIntType, int_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObFloatType, float_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObDoubleType, double_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObDateTimeType, (pdt_expected[i]/1000000L), cases[i]);
        MY_EXPECT(ObVarcharType, in, ObPreciseDateTimeType, pdt_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObVarcharType, int_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObSeqType, int_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObCreateTimeType, pdt_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObModifyTimeType, pdt_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObExtendType, int_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObBoolType, bool_expected[i], cases[i]);
        MY_EXPECT(ObVarcharType, in, ObDecimalType, int_expected[i], dec_expected[i]);
    }
}
开发者ID:sharpglasses,项目名称:oceanbase,代码行数:32,代码来源:ob_obj_cast_test.cpp

示例7: TBSYS_LOG

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

示例8: TEST_F

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

示例9: resolve_set_password_stmt

int resolve_set_password_stmt(ResultPlan* result_plan,
                              ParseNode* node,
                              uint64_t& query_id)
{
  OB_ASSERT(result_plan);
  OB_ASSERT(node && node->type_ == T_SET_PASSWORD && node->num_child_ == 2);
  int& ret = result_plan->err_stat_.err_code_ = OB_SUCCESS;
  ObSetPasswordStmt *stmt = NULL;
  if (OB_SUCCESS != (ret = prepare_resolve_stmt(result_plan, query_id, stmt)))
  {
  }
  else
  {
    ObString user;
    if (NULL != node->children_[0])
    {
      user.assign_ptr(const_cast<char*>(node->children_[0]->str_value_),
                      static_cast<int32_t>(strlen(node->children_[0]->str_value_)));
    }
    ObString password = ObString::make_string(node->children_[1]->str_value_);
    if (OB_SUCCESS != (ret = stmt->set_user_password(user, password)))
    {
      PARSER_LOG("Failed to set UserPasswordStmt");
    }
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:27,代码来源:priv_build_plan.cpp

示例10: TBSYS_LOG

/* 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: 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

示例12: TBSYS_LOG

int ObSystemConfigKey::set_varchar(const ObString &key, const char * strvalue)
{
  int ret = OB_SUCCESS;
  if (NULL == strvalue)
  {
    TBSYS_LOG(WARN, "check varchar value failed");
    ret = OB_INVALID_ARGUMENT;
  }
  else if (key == ObString::make_string("svr_type"))
  {
    strncpy(server_type_, strvalue, sizeof (server_type_));
    server_type_[OB_SERVER_TYPE_LENGTH - 1] = '\0';
  }
  else if (key == ObString::make_string("svr_ip"))
  {
    strncpy(server_ip_, strvalue, sizeof (server_ip_));
    server_ip_[OB_MAX_SERVER_ADDR_SIZE - 1] = '\0';
  }
  else
  {
    ret = OB_INVALID_ARGUMENT;
    TBSYS_LOG(ERROR, "unknow sys config column name: %.*s",
        key.length(), key.ptr());
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:26,代码来源:ob_system_config_key.cpp

示例13: fast_search

 int64_t ObStringSearch::fast_search(const ObString & pattern, const ObString & text)
 {
   const char* pat = pattern.ptr();
   const int64_t pat_len = pattern.length();
   const char* txt = text.ptr();
   const int64_t txt_len = text.length();
   return fast_search(pat, pat_len, txt, txt_len);
 }
开发者ID:Abioy,项目名称:oceanbase,代码行数:8,代码来源:ob_string_search.cpp

示例14: convert

int ObUpsRowUtil::convert(const ObUpsRow &row, ObString &compact_row)
{
  int ret = OB_SUCCESS;
  ObCompactCellWriter cell_writer;
  cell_writer.init(compact_row.ptr(), compact_row.size());

  const ObObj *cell = NULL;
  uint64_t table_id = OB_INVALID_ID;
  uint64_t column_id = OB_INVALID_ID;
  ObObj cell_clone;

  if(row.get_is_delete_row())
  {
    if(OB_SUCCESS != (ret = cell_writer.row_delete()))
    {
      TBSYS_LOG(WARN, "append delete row fail:ret[%d]", ret);
    }
  }

  for (int64_t i = 0; (OB_SUCCESS == ret) && i < row.get_column_num(); ++i)
  {
    if (OB_SUCCESS != (ret = row.raw_get_cell(i, cell, table_id, column_id)))
    {
      TBSYS_LOG(WARN, "failed to get cell, err=%d", ret);
      break;
    }
    else
    {
      if(ObExtendType == cell->get_type() && ObActionFlag::OP_NOP == cell->get_ext())
      {
        //不用处理,OP_NOP不序列化
      }
      else if (OB_SUCCESS != (ret = cell_writer.append(column_id, *cell)))
      {
        if (OB_SIZE_OVERFLOW != ret)
        {
          TBSYS_LOG(WARN, "failed to append cell, err=%d", ret);
        }
        break;
      }
    }
  } // end for i
  if (OB_SUCCESS == ret)
  {
    if (OB_SUCCESS != (ret = cell_writer.row_finish()))
    {
      if (OB_SIZE_OVERFLOW != ret)
      {
        TBSYS_LOG(WARN, "failed to append cell, err=%d", ret);
      }
    }
    else
    {
      compact_row.assign_ptr(compact_row.ptr(), (int32_t)(cell_writer.size()));
    }
  }
  return ret;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:58,代码来源:ob_ups_row_util.cpp

示例15: TEST

TEST(TestLogMysqlAdaptor, init)
{
  ObLogConfig config;
  ObLogServerSelector server_selector;
  ObLogRpcStub rpc_stub;
  ObLogSchemaGetter schema_getter;
  ObLogMysqlAdaptor mysql_adaptor;

  config.init("./liboblog.conf");
  server_selector.init(config);
  rpc_stub.init();
  schema_getter.init(&server_selector, &rpc_stub);
  mysql_adaptor.init(config, &schema_getter);

  ObObj objs[4];
  objs[0].set_int(13490859);
  objs[1].set_int(0);
  objs[2].set_int(1);
  ObString str;
  str.assign_ptr((char*)("fenxiao-001"), 11);
  objs[3].set_varchar(str);
  ObRowkey rk;
  rk.assign(objs, 4);

  const IObLogColValue *list = NULL;
  int ret = mysql_adaptor.query_whole_row(3001, rk, list);
  TBSYS_LOG(INFO, "query_whole_row ret=%d", ret);

  const IObLogColValue *iter = list;
  while (NULL != iter)
  {
    std::string str;
    iter->to_str(str);
    TBSYS_LOG(INFO, "[VALUE] [%s]", str.c_str());
    iter = iter->get_next();
  }

  ////////////////////

  objs[0].set_int(2222504619);
  str.assign_ptr((char*)("IC"), 2);
  objs[3].set_varchar(str);

  list = NULL;
  ret = mysql_adaptor.query_whole_row(3001, rk, list);
  TBSYS_LOG(INFO, "query_whole_row ret=%d", ret);

  iter = list;
  while (NULL != iter)
  {
    std::string str;
    iter->to_str(str);
    TBSYS_LOG(INFO, "[VALUE] [%s]", str.c_str());
    iter = iter->get_next();
  }
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:56,代码来源:test_mysql_adaptor.cpp


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