Exemple #1
0
int CellinfoBuilder::check_schema_mgr(const ObSchemaManager &schema_mgr)
{
  int ret = OB_SUCCESS;
  const ObSchema *schema = NULL;
  for (schema = schema_mgr.begin(); schema != schema_mgr.end(); ++schema)
  {
    if (NULL == schema->find_column_info(SEED_COLUMN_NAME)
        || NULL == schema->find_column_info(ROWKEY_INFO_COLUMN_NAME)
        || SEED_COLUMN_ID != schema->find_column_info(SEED_COLUMN_NAME)->get_id()
        || ROWKEY_INFO_COLUMN_ID != schema->find_column_info(ROWKEY_INFO_COLUMN_NAME)->get_id())
    {
      TBSYS_LOG(WARN, "no seed or rowkey_info column in the schema");
      ret = OB_ERROR;
      break;
    }
  }
  return ret;
}
Exemple #2
0
int MutatorBuilder::init4write(const ObSchemaManager &schema_mgr,
                              const int64_t prefix_start,
                              const char *serv_addr,
                              const int serv_port,
                              const int64_t table_start_version,
                              const bool using_id,
                              const int64_t suffix_length,
                              const int64_t suffix_num,
                              const int64_t prefix_end,
                              const int64_t max_rownum_per_mutator,
                              ClientWrapper *client4write)
{
  int ret = OB_SUCCESS;
  if (OB_SUCCESS != (ret = CellinfoBuilder::check_schema_mgr(schema_mgr)))
  {
    TBSYS_LOG(WARN, "schema cannot pass check");
  }
  else
  {
    client_.init(serv_addr, serv_port);

    table_num_ = schema_mgr.end() - schema_mgr.begin();
    srand48_r(time(NULL), &table_rand_seed_);
    schema_mgr_ = schema_mgr;
    max_rownum_per_mutator_ = max_rownum_per_mutator;
    table_start_version_ = table_start_version;
    //seed_map_.create(2000000);
    const ObSchema *schema_array = schema_mgr_.begin();
    for (int64_t i = 0; i < table_num_; i++)
    {
      int64_t tmp_suffix_length = get_suffix_length_(schema_array[i], using_id, prefix_start);
      tmp_suffix_length = (0 == tmp_suffix_length) ? suffix_length : tmp_suffix_length;
      int64_t tmp_suffix_num = get_suffix_num_(schema_array[i], using_id, prefix_start);
      tmp_suffix_num = (0 == tmp_suffix_num) ? suffix_num : tmp_suffix_num;
      int64_t tmp_prefix_end = get_prefix_end_(schema_array[i], using_id, prefix_start);
      tmp_prefix_end = std::max(prefix_end, tmp_prefix_end);
      if (0 == tmp_suffix_length
          || 0 == tmp_suffix_num
          || 0 == tmp_prefix_end)
      {
        TBSYS_LOG(WARN, "suffix_length=%ld suffix_num=%ld prefix_end=%ld",
                  tmp_suffix_length, tmp_suffix_num, tmp_prefix_end);
        ret = OB_ERROR;
        break;
      }
      if (NULL == (cb_array_[i] = new(std::nothrow) CellinfoBuilder())
          || NULL == (rb_array_[i] = new(std::nothrow) RowkeyBuilder(prefix_start, tmp_suffix_num, tmp_suffix_length)))
      {
        ret = OB_ERROR;
        break;
      }
      prefix_end_array_[i] = tmp_prefix_end;
      if (NULL == client4write)
      {
        continue;
      }
      if (OB_SUCCESS != (ret = put_suffix_length_(*client4write, schema_array[i], prefix_start, tmp_suffix_length)))
      {
        break;
      }
      if (OB_SUCCESS != (ret = put_suffix_num_(*client4write, schema_array[i], prefix_start, tmp_suffix_num)))
      {
        break;
      }
      if (OB_SUCCESS != (ret = put_prefix_end_(*client4write, schema_array[i], prefix_start, tmp_prefix_end)))
      {
        break;
      }
    }
  }
  assert(OB_SUCCESS == ret);
  return ret;
}