std::unique_ptr MetaUtil::MetaRequest()

in src/hbase/client/meta-utils.cc [60:97]


std::unique_ptr<Request> MetaUtil::MetaRequest(const TableName tn, const std::string &row) const {
  auto request = Request::scan();
  auto msg = std::static_pointer_cast<ScanRequest>(request->req_msg());

  msg->set_number_of_rows(1);
  msg->set_close_scanner(true);

  // Set the region this scan goes to
  auto region = msg->mutable_region();
  region->set_value(MetaUtil::kMetaRegionName);
  region->set_type(
      RegionSpecifier_RegionSpecifierType::RegionSpecifier_RegionSpecifierType_ENCODED_REGION_NAME);

  auto scan = msg->mutable_scan();
  // We don't care about before, just now.
  scan->set_max_versions(1);
  // Meta should be cached at all times.
  scan->set_cache_blocks(true);
  // We only want one row right now.
  //
  // TODO(eclark): Figure out if we should get more.
  scan->set_caching(1);
  // Close the scan after we have data.
  scan->set_small(true);
  // We know where to start but not where to end.
  scan->set_reversed(true);
  // Give me everything or nothing.
  scan->set_allow_partial_results(false);

  // Set the columns that we need
  auto info_col = scan->add_column();
  info_col->set_family(MetaUtil::kCatalogFamily);
  info_col->add_qualifier(MetaUtil::kServerColumn);
  info_col->add_qualifier(MetaUtil::kRegionInfoColumn);

  scan->set_start_row(RegionLookupRowkey(tn, row));
  return request;
}