コード例 #1
0
ファイル: total_scan.cpp プロジェクト: CCoder123/pproj
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;
}
コード例 #2
0
ファイル: ups_admin.cpp プロジェクト: mrunix/oceanbase
int get(const char *fname, PageArena<char> &allocer, MockClient &client, const char *version_range,
        const char * expect_result_fname, const char * schema_fname)
{
  ObScanner scanner;
  ObGetParam get_param;
  read_get_param(fname, GET_PARAM_SECTION, allocer, get_param);
  get_param.set_is_read_consistency(false);
  get_param.set_version_range(str2range(version_range));
  int err = client.ups_get(get_param, scanner, timeout);
  UNUSED(expect_result_fname);
  UNUSED(schema_fname);
  if (OB_SUCCESS == err)
  {
    print_scanner(scanner);
  }
  fprintf(stdout, "[%s] err=%d\n", __FUNCTION__, err);
  return err;
}
コード例 #3
0
ファイル: ups_admin.cpp プロジェクト: mrunix/oceanbase
int param_get(const char *fname, MockClient &client)
{
  int err = OB_SUCCESS;
  int fd = open(fname, O_RDONLY);
  if (-1 == fd)
  {
    fprintf(stdout, "open [%s] fail errno=%u\n", fname, errno);
    err = OB_ERROR;
  }
  else
  {
    struct stat st;
    fstat(fd, &st);
    char *buf = (char*)malloc(st.st_size);
    if (NULL == buf)
    {
      fprintf(stdout, "malloc buf fail size=%ld\n", st.st_size);
       err = OB_ERROR;
    }
    else
    {
      ssize_t __attribute__((unused)) ret = read(fd, buf, st.st_size);
      int64_t pos = 0;
      ObGetParam get_param;
      if (OB_SUCCESS != get_param.deserialize(buf, st.st_size, pos))
      {
        fprintf(stdout, "deserialize get_param fail\n");
        err = OB_ERROR;
      }
      else
      {
        get_param.set_is_read_consistency(false);
        ObScanner scanner;
        int err = client.ups_get(get_param, scanner, timeout);
        fprintf(stdout, "[%s] err=%d\n", __FUNCTION__, err);
        if (OB_SUCCESS == err)
        {
          int64_t row_counter = 0;
          while (OB_SUCCESS == scanner.next_cell())
          {
            ObCellInfo *ci = NULL;
            bool is_row_changed = false;
            scanner.get_cell(&ci, &is_row_changed);
            fprintf(stdout, "%s\n", common::print_cellinfo(ci, "CLI_GET"));
            if (is_row_changed)
            {
              row_counter++;
            }
          }
          bool is_fullfilled = false;
          int64_t fullfilled_num = 0;
          ObRowkey last_rk;
          scanner.get_last_row_key(last_rk);
          scanner.get_is_req_fullfilled(is_fullfilled, fullfilled_num);
          fprintf(stdout, "is_fullfilled=%s fullfilled_num=%ld row_counter=%ld last_row_key=[%s]\n",
                  STR_BOOL(is_fullfilled), fullfilled_num, row_counter, to_cstring(last_rk));
        }
      }
      free(buf);
    }
    close(fd);
  }
  return err;
}