Exemplo n.º 1
0
bool get_check_row(const ObSchema &schema, const ObString &row_key, CellinfoBuilder &cb,
                  MockClient &client, const int64_t table_start_version, const bool using_id)
{
  bool bret = false;

  ObGetParam get_param;
  const ObColumnSchema *iter = NULL;
  for (iter = schema.column_begin(); iter != schema.column_end(); iter++)
  {
    ObCellInfo ci;
    ci.row_key_ = row_key;
    if (using_id) 
    {
      ci.table_id_ = schema.get_table_id();
      ci.column_id_ = iter->get_id();
    }
    else
    {
      ci.table_name_.assign_ptr(const_cast<char*>(schema.get_table_name()), strlen(schema.get_table_name()));
      ci.column_name_.assign_ptr(const_cast<char*>(iter->get_name()), strlen(iter->get_name()));
    }
    get_param.add_cell(ci);
  }
  ObVersionRange version_range;
  version_range.start_version_ = table_start_version;
  version_range.border_flag_.set_max_value();
  version_range.border_flag_.set_inclusive_start();
  get_param.set_version_range(version_range);

  ObScanner scanner;
  int ret = client.ups_get(get_param, scanner, TIMEOUT_MS);
  if (OB_SUCCESS == ret)
  {
    RowChecker rc;
    while (OB_SUCCESS == scanner.next_cell())
    {
      ObCellInfo *ci = NULL;
      if (OB_SUCCESS == scanner.get_cell(&ci))
      {
        if (!using_id)
        {
          trans_name2id(*ci, schema);
        }
        rc.add_cell(ci);
      }
    }
    bret = rc.check_row(cb, schema);
  }
  else
  {
    TBSYS_LOG(WARN, "get ret=%d", ret);
  }
  return bret;
  return true;
}
Exemplo n.º 2
0
void prepare_scan_param(ObScanParam &scan_param, const ObSchema &schema,
                        const int64_t table_start_version, const bool using_id)
{
  ObRange range;
  range.border_flag_.set_min_value();
  range.border_flag_.set_max_value();

  const ObColumnSchema *iter = NULL;
  for (iter = schema.column_begin(); iter != schema.column_end(); iter++)
  {
    if (using_id)
    {
      scan_param.add_column(iter->get_id());
    }
    else
    {
      ObString column_name;
      column_name.assign_ptr(const_cast<char*>(iter->get_name()), strlen(iter->get_name()));
      scan_param.add_column(column_name);
    }
  }

  if (using_id)
  {
    scan_param.set(schema.get_table_id(), ObString(), range);
  }
  else
  {
    ObString table_name;
    table_name.assign(const_cast<char*>(schema.get_table_name()), strlen(schema.get_table_name()));
    scan_param.set(OB_INVALID_ID, table_name, range);
  }

  ObVersionRange version_range;
  version_range.start_version_ = table_start_version;
  version_range.border_flag_.set_max_value();
  version_range.border_flag_.set_inclusive_start();
  scan_param.set_version_range(version_range);
}
Exemplo n.º 3
0
void CellinfoBuilder::build_cell_(struct drand48_data &rand_data, const ObString &row_key, const ObSchema &schema,
                                  ObObj &obj, int64_t &column_pos, int &op_type,
                                  PageArena<char> &allocer)
{
  const ObColumnSchema *column_schema = schema.column_begin();
  int64_t column_num = schema.column_end() - schema.column_begin();
  int64_t rand = 0;

  lrand48_r(&rand_data, &rand);
  op_type = calc_op_type_(rand);
  //while (true)
  //{
  //  lrand48_r(&rand_data, &rand);
  //  column_pos = range_rand(0, column_num - 3, rand);
  //  if (ObIntType <= column_schema[column_pos].get_type()
  //      && ObVarcharType >= column_schema[column_pos].get_type())
  //  {
  //    break;
  //  }
  //}
  column_pos=0;

  lrand48_r(&rand_data, &rand);
  switch (column_schema[column_pos].get_type())
  {
    case ObIntType:
      {
        int64_t tmp = rand;
        obj.set_int(tmp, ADD == op_type);
        break;
      }
    case ObFloatType:
      {
        float tmp = static_cast<float>(rand);
        obj.set_float(tmp, ADD == op_type);
        break;
      }
    case ObDoubleType:
      {
        double tmp = static_cast<double>(rand);
        obj.set_double(tmp, ADD == op_type);
        break;
      }
    case ObDateTimeType:
      {
        ObDateTime tmp = static_cast<ObDateTime>(rand);
        obj.set_datetime(tmp, ADD == op_type);
        break;
      }
    case ObPreciseDateTimeType:
      {
        ObPreciseDateTime tmp = static_cast<ObPreciseDateTime>(rand);
        obj.set_precise_datetime(tmp, ADD == op_type);
        break;
      }
    case ObVarcharType:
      {
        int64_t length = range_rand(1, column_schema[column_pos].get_size(), rand);
        char *ptr = allocer.alloc(length);
        build_string(ptr, length, rand);
        ObString str;
        str.assign_ptr(ptr, length);
        if (ADD == op_type)
        {
          op_type = UPDATE;
        }
        obj.set_varchar(str);
        break;
      }
    default:
      break;
  }
  if (DEL_CELL == op_type)
  {
    obj.set_null();
  }
  else if (DEL_ROW == op_type)
  {
    obj.set_ext(ObActionFlag::OP_DEL_ROW);
  }
}