| 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(current_chunk_.data->column(column_num)); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Reset GetData value offsets. |
| 84 | if (static_cast<size_t>(num_binding_) != get_data_offsets_.size() && reset_get_data_) { |
| 85 | std::fill(get_data_offsets_.begin(), get_data_offsets_.end(), 0); |
| 86 | } |
| 87 | |
| 88 | size_t fetched_rows = 0; |
| 89 | while (fetched_rows < rows) { |
| 90 | size_t batch_rows = current_chunk_.data->num_rows(); |
| 91 | size_t rows_to_fetch = std::min(static_cast<size_t>(rows - fetched_rows), |
| 92 | static_cast<size_t>(batch_rows - current_row_)); |
| 93 | |
| 94 | if (rows_to_fetch == 0) { |
| 95 | if (!chunk_buffer_.GetNext(¤t_chunk_)) { |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | if (transformer_) { |
| 100 | current_chunk_.data = transformer_->Transform(current_chunk_.data); |
| 101 | } |
| 102 | |
| 103 | for (size_t column_num = 0; column_num < columns_.size(); ++column_num) { |
| 104 | columns_[column_num].ResetAccessor(current_chunk_.data->column(column_num)); |
| 105 | } |
| 106 | current_row_ = 0; |
| 107 | continue; |
| 108 | } |
| 109 | |
| 110 | for (auto& column : columns_) { |
| 111 | // There can be unbound columns. |
| 112 | if (!column.is_bound) continue; |
| 113 | |
| 114 | auto* accessor = column.GetAccessorForBinding(); |
| 115 | ColumnBinding shifted_binding = column.binding; |
| 116 | uint16_t* shifted_row_status_array = |
| 117 | row_status_array ? &row_status_array[fetched_rows] : nullptr; |
| 118 | |
| 119 | if (shifted_row_status_array) { |
| 120 | std::fill(shifted_row_status_array, &shifted_row_status_array[rows_to_fetch], |
| 121 | RowStatus_SUCCESS); |