| 1148 | |
| 1149 | template <typename DType> |
| 1150 | int64_t TypedColumnReaderImpl<DType>::Skip(int64_t num_values_to_skip) { |
| 1151 | int64_t values_to_skip = num_values_to_skip; |
| 1152 | // Optimization: Do not call HasNext() when values_to_skip == 0. |
| 1153 | while (values_to_skip > 0 && HasNext()) { |
| 1154 | // If the number of values to skip is more than the number of undecoded values, skip |
| 1155 | // the Page. |
| 1156 | const int64_t available_values = this->available_values_current_page(); |
| 1157 | if (values_to_skip >= available_values) { |
| 1158 | values_to_skip -= available_values; |
| 1159 | this->ConsumeBufferedValues(available_values); |
| 1160 | } else { |
| 1161 | // We need to read this Page |
| 1162 | // Jump to the right offset in the Page |
| 1163 | int64_t values_read = 0; |
| 1164 | InitScratchForSkip(); |
| 1165 | ARROW_DCHECK_NE(this->scratch_for_skip_, nullptr); |
| 1166 | do { |
| 1167 | int64_t batch_size = std::min(kSkipScratchBatchSize, values_to_skip); |
| 1168 | values_read = ReadBatch(static_cast<int>(batch_size), |
| 1169 | scratch_for_skip_->mutable_data_as<int16_t>(), |
| 1170 | scratch_for_skip_->mutable_data_as<int16_t>(), |
| 1171 | scratch_for_skip_->mutable_data_as<T>(), &values_read); |
| 1172 | values_to_skip -= values_read; |
| 1173 | } while (values_read > 0 && values_to_skip > 0); |
| 1174 | } |
| 1175 | } |
| 1176 | return num_values_to_skip - values_to_skip; |
| 1177 | } |
| 1178 | |
| 1179 | } // namespace |
| 1180 | |