コード例 #1
0
ファイル: ups_admin.cpp プロジェクト: mrunix/oceanbase
void total_scan(const char *fname, PageArena<char> &allocer, MockClient &client, const char *version_range)
{
  ObScanner scanner;
  ObScanParam scan_param;
  read_scan_param(fname, SCAN_PARAM_SECTION, allocer, scan_param);
  scan_param.set_version_range(str2range(version_range));
  scan_param.set_is_read_consistency(false);

  int64_t total_fullfilled_num = 0;
  int64_t total_row_counter = 0;
  int64_t total_timeu = 0;
  while (true)
  {
    int64_t timeu = tbsys::CTimeUtil::getTime();
    int err = client.ups_scan(scan_param, scanner, timeout);
    timeu = tbsys::CTimeUtil::getTime() - timeu;
    if (OB_SUCCESS != err)
    {
      fprintf(stdout, "[%s] err=%d\n", __FUNCTION__, err);
      break;
    }
    else
    {
      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", updateserver::print_cellinfo(ci, "CLI_SCAN"));
        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, "[SINGLE_SCAN] is_fullfilled=%s fullfilled_num=%ld row_counter=%ld timeu=%ld last_row_key=[%s]\n",
              STR_BOOL(is_fullfilled), fullfilled_num, row_counter, timeu, to_cstring(last_rk));
      total_fullfilled_num += fullfilled_num;
      total_row_counter += row_counter;
      total_timeu += timeu;
      if (is_fullfilled)
      {
        break;
      }
      else
      {
        const_cast<ObNewRange*>(scan_param.get_range())->start_key_ = last_rk;
        const_cast<ObNewRange*>(scan_param.get_range())->border_flag_.unset_min_value();
        const_cast<ObNewRange*>(scan_param.get_range())->border_flag_.unset_inclusive_start();
      }
    }
  }
  fprintf(stdout, "[TOTAL_SCAN] total_fullfilled_num=%ld total_row_counter=%ld total_timeu=%ld\n",
          total_fullfilled_num, total_row_counter, total_timeu);
}
コード例 #2
0
ファイル: ups_admin.cpp プロジェクト: mrunix/oceanbase
int scan(const char *fname, PageArena<char> &allocer, MockClient &client, const char *version_range,
         const char * expect_result_fname, const char *schema_fname)
{
  ObScanner scanner;
  ObScanParam scan_param;
  read_scan_param(fname, SCAN_PARAM_SECTION, allocer, scan_param);
  scan_param.set_version_range(str2range(version_range));
  scan_param.set_is_read_consistency(false);
  int err = client.ups_scan(scan_param, scanner, timeout);
  UNUSED(expect_result_fname);
  UNUSED(schema_fname);
  // check result
  if (OB_SUCCESS == err)
  {
    print_scanner(scanner);
  }
  fprintf(stdout, "[%s] err=%d\n", __FUNCTION__, err);
  return err;
}
コード例 #3
0
ファイル: mock_client.cpp プロジェクト: Abioy/oceanbase
int main(int argc, char** argv)
{
  const int32_t MOCK_SERVER_LISTEN_PORT = 8888;
  MockClient client;
  ObServer dst_host;
  const char* dst_addr = "localhost";
  dst_host.set_ipv4_addr(dst_addr, MOCK_SERVER_LISTEN_PORT);
  client.init(dst_host);

  // init cell info
  static const int64_t ROW_NUM = 1;
  static const int64_t COL_NUM = 10;

  ObCellInfo cell_infos[ROW_NUM][COL_NUM];
  char row_key_strs[ROW_NUM][50];
  uint64_t table_id = 10;
  // init cell infos
  for (int64_t i = 0; i < ROW_NUM; ++i)
  {
    sprintf(row_key_strs[i], "row_key_%08ld", i);
    for (int64_t j = 0; j < COL_NUM; ++j)
    {
      cell_infos[i][j].table_id_ = table_id;
      cell_infos[i][j].row_key_.assign(row_key_strs[i], strlen(row_key_strs[i]));
      //cell_infos[i][j].op_info_.set_sem_ob();

      cell_infos[i][j].column_id_ = j + 1;

      cell_infos[i][j].value_.set_int(1000 + i * COL_NUM + j);
    }
  }

  // scan memtable
  ObScanner scanner;
  ObScanParam scan_param;
  //ObOperateInfo op_info;
  ObString table_name;
  ObRange range;
  const int64_t version = 999;
  range.start_key_ = cell_infos[0][0].row_key_;
  range.end_key_ = cell_infos[ROW_NUM - 1][0].row_key_;
  range.border_flag_.set_inclusive_start();
  range.border_flag_.set_inclusive_end();

  scan_param.set(table_id, table_name, range);
  //scan_param.set_timestamp(version);
  //scan_param.set_is_read_frozen_only(false);
  ObVersionRange version_range;
  version_range.start_version_ = version;
  version_range.end_version_ = version;
  version_range.border_flag_.set_inclusive_start();
  version_range.border_flag_.set_inclusive_end();
  scan_param.set_version_range(version_range);
  for (int64_t i = 0; i < COL_NUM; ++i)
  {
    scan_param.add_column(cell_infos[0][i].column_id_);
  }


  int64_t count = 0;
  const int64_t timeout = 10 * 1000L;

  int err = client.ups_scan(scan_param, scanner, timeout);
  fprintf(stderr, "ups_scan err=%d\n", err);

  // check result
  count = 0;
  ObScannerIterator iter;
  for (iter = scanner.begin(); iter != scanner.end(); iter++)
  {
    ObCellInfo ci;
    ObCellInfo expected = cell_infos[count / COL_NUM][count % COL_NUM];
    EXPECT_EQ(OB_SUCCESS, iter.get_cell(ci));
    check_cell(expected, ci);
    ++count;
  }
  EXPECT_EQ(ROW_NUM * COL_NUM, count);
  fprintf(stderr, "cell_num=%ld\n", count);

  client.destroy();
  return 0;
}
コード例 #4
0
ファイル: total_scan.cpp プロジェクト: CCoder123/pproj
void scan_check_all(MutatorBuilder &mb, MockClient &client, const int64_t table_start_version, const bool using_id, const bool check)
{
  for (int64_t i = 0; i < mb.get_schema_num(); ++i)
  {
    ObScanParam scan_param;
    prepare_scan_param(scan_param, mb.get_schema(i), table_start_version, using_id);
    int ret = OB_SUCCESS;
    bool is_fullfilled = false;
    int64_t fullfilled_item_num = 0;
    RowChecker rc;
    int64_t row_counter = 0;
    ObScanner scanner;
    while (!is_fullfilled
          && OB_SUCCESS == ret)
    {
      int64_t timeu = tbsys::CTimeUtil::getTime();
      ret = client.ups_scan(scan_param, scanner, TIMEOUT_MS);
      TBSYS_LOG(INFO, "scan ret=%d timeu=%ld", ret, tbsys::CTimeUtil::getTime() - timeu);
      if (check
          && OB_SUCCESS == ret)
      {
        while (OB_SUCCESS == scanner.next_cell())
        {
          ObCellInfo *ci = NULL;
          bool is_row_changed = false;
          if (OB_SUCCESS == scanner.get_cell(&ci, &is_row_changed))
          {
            if (!using_id)
            {
              trans_name2id(*ci, mb.get_schema(i));
            }
            if (is_row_changed && 0 != rc.cell_num())
            {
              std::string row_key_str(rc.get_cur_rowkey().ptr(), 0, rc.get_cur_rowkey().length());
              //fprintf(stderr, "[%.*s] ", rc.get_cur_rowkey().length(), rc.get_cur_rowkey().ptr());

              bool get_row_bret = get_check_row(mb.get_schema(i), rc.get_cur_rowkey(), mb.get_cellinfo_builder(i), client, table_start_version, using_id);
              //fprintf(stderr, "[get_row check_ret=%d] ", bret);

              bool cell_info_bret = rc.check_row(mb.get_cellinfo_builder(i), mb.get_schema(i));
              //fprintf(stderr, "[cell_info check_ret=%d]\n", bret);
              TBSYS_LOG(INFO, "[%s] [get_row check_ret=%d] [cell_info check_ret=%d]", row_key_str.c_str(), get_row_bret, cell_info_bret);
            }
            if (is_row_changed
                && 0 != rc.rowkey_num()
                && rc.is_prefix_changed(ci->row_key_))
            {
              std::string row_key_str(rc.get_last_rowkey().ptr(), 0, rc.get_last_rowkey().length());
              //fprintf(stderr, "[%.*s] ", rc.get_last_rowkey().length(), rc.get_last_rowkey().ptr());

              bool bret = rc.check_rowkey(mb.get_rowkey_builder(i));
              //fprintf(stderr, "row_key check_ret=%d\n", bret);
              TBSYS_LOG(INFO, "[%s] [row_key check_ret=%d]", row_key_str.c_str(), bret);
            }
            rc.add_cell(ci);
            if (is_row_changed)
            {
              rc.add_rowkey(ci->row_key_);
              row_counter++;
            }
          }
        }
        if (0 != rc.cell_num())
        {
          std::string row_key_str(rc.get_cur_rowkey().ptr(), 0, rc.get_cur_rowkey().length());
          //fprintf(stderr, "[%.*s] ", rc.get_cur_rowkey().length(), rc.get_cur_rowkey().ptr());

          bool get_row_bret = get_check_row(mb.get_schema(i), rc.get_cur_rowkey(), mb.get_cellinfo_builder(i), client, table_start_version, using_id);
          //fprintf(stderr, "[get_row check_ret=%d] ", bret);

          bool cell_info_bret = rc.check_row(mb.get_cellinfo_builder(i), mb.get_schema(i));
          //fprintf(stderr, "[cell_info check_ret=%d]\n", bret);
          TBSYS_LOG(INFO, "[%s] [get_row check_ret=%d] [cell_info check_ret=%d]", row_key_str.c_str(), get_row_bret, cell_info_bret);
        }
      }
      scanner.get_is_req_fullfilled(is_fullfilled, fullfilled_item_num);
      ObRange *range = const_cast<ObRange*>(scan_param.get_range());
      scanner.get_last_row_key(range->start_key_);
      range->border_flag_.unset_min_value();
      range->border_flag_.unset_inclusive_start();
    }
    if (check
        && 0 != rc.rowkey_num())
    {
      std::string row_key_str(rc.get_last_rowkey().ptr(), 0, rc.get_last_rowkey().length());
      //fprintf(stderr, "[%.*s] ", rc.get_last_rowkey().length(), rc.get_last_rowkey().ptr());

      bool bret = rc.check_rowkey(mb.get_rowkey_builder(i));
      //fprintf(stderr, "row_key check_ret=%d\n", bret);
      TBSYS_LOG(INFO, "[%s] [row_key check_ret=%d]", row_key_str.c_str(), bret);
    }
    TBSYS_LOG(INFO, "table_id=%lu row_counter=%ld", mb.get_schema(i).get_table_id(), row_counter);
  }
}