std::shared_ptr ResponseConverter::ToResult()

in src/hbase/client/response-converter.cc [60:85]


std::shared_ptr<Result> ResponseConverter::ToResult(
    const hbase::pb::Result& result, const std::shared_ptr<CellScanner> cell_scanner) {
  std::vector<std::shared_ptr<Cell>> vcells;
  for (auto cell : result.cell()) {
    std::shared_ptr<Cell> pcell =
        std::make_shared<Cell>(cell.row(), cell.family(), cell.qualifier(), cell.timestamp(),
                               cell.value(), static_cast<hbase::CellType>(cell.cell_type()));
    vcells.push_back(pcell);
  }

  // iterate over the cells coming from rpc codec
  if (cell_scanner != nullptr) {
    int cells_read = 0;
    while (cells_read != result.associated_cell_count()) {
      if (cell_scanner->Advance()) {
        vcells.push_back(cell_scanner->Current());
        cells_read += 1;
      } else {
        LOG(ERROR) << "CellScanner::Advance() returned false unexpectedly. Cells Read:- "
                   << cells_read << "; Expected Cell Count:- " << result.associated_cell_count();
        std::runtime_error("CellScanner::Advance() returned false unexpectedly");
      }
    }
  }
  return std::make_shared<Result>(vcells, result.exists(), result.stale(), result.partial());
}