| 62 | } |
| 63 | |
| 64 | size_t FlightSqlResultSet::Move(size_t rows, size_t bind_offset, size_t bind_type, |
| 65 | uint16_t* row_status_array) { |
| 66 | // Consider it might be the first call to Move() and current_chunk is not |
| 67 | // populated yet |
| 68 | assert(rows > 0); |
| 69 | if (current_chunk_.data == nullptr) { |
| 70 | if (!chunk_buffer_.GetNext(¤t_chunk_)) { |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | if (transformer_) { |
| 75 | current_chunk_.data = transformer_->Transform(current_chunk_.data); |
| 76 | } |
| 77 | |
| 78 | for (size_t column_num = 0; column_num < columns_.size(); ++column_num) { |
| 79 | columns_[column_num].ResetAccessor( |
| 80 | current_chunk_.data->column(static_cast<int>(column_num))); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // Reset GetData value offsets. |
| 85 | if (static_cast<size_t>(num_binding_) != get_data_offsets_.size() && reset_get_data_) { |
| 86 | std::fill(get_data_offsets_.begin(), get_data_offsets_.end(), 0); |
| 87 | } |
| 88 | |
| 89 | size_t fetched_rows = 0; |
| 90 | while (fetched_rows < rows) { |
| 91 | size_t batch_rows = current_chunk_.data->num_rows(); |
| 92 | size_t rows_to_fetch = std::min(static_cast<size_t>(rows - fetched_rows), |
| 93 | static_cast<size_t>(batch_rows - current_row_)); |
| 94 | |
| 95 | if (rows_to_fetch == 0) { |
| 96 | if (!chunk_buffer_.GetNext(¤t_chunk_)) { |
| 97 | break; |
| 98 | } |
| 99 | |
| 100 | if (transformer_) { |
| 101 | current_chunk_.data = transformer_->Transform(current_chunk_.data); |
| 102 | } |
| 103 | |
| 104 | for (size_t column_num = 0; column_num < columns_.size(); ++column_num) { |
| 105 | columns_[column_num].ResetAccessor( |
| 106 | current_chunk_.data->column(static_cast<int>(column_num))); |
| 107 | } |
| 108 | current_row_ = 0; |
| 109 | continue; |
| 110 | } |
| 111 | |
| 112 | for (auto& column : columns_) { |
| 113 | // There can be unbound columns. |
| 114 | if (!column.is_bound) continue; |
| 115 | |
| 116 | auto* accessor = column.GetAccessorForBinding(); |
| 117 | ColumnBinding shifted_binding = column.binding; |
| 118 | uint16_t* shifted_row_status_array = |
| 119 | row_status_array ? &row_status_array[fetched_rows] : nullptr; |
| 120 | |
| 121 | if (shifted_row_status_array) { |