| 137 | } |
| 138 | |
| 139 | Result<RecordBatchGenerator> IpcFileFormat::ScanBatchesAsync( |
| 140 | const std::shared_ptr<ScanOptions>& options, |
| 141 | const std::shared_ptr<FileFragment>& file) const { |
| 142 | auto self = shared_from_this(); |
| 143 | auto source = file->source(); |
| 144 | auto open_reader = OpenReaderAsync(source); |
| 145 | auto reopen_reader = [self, options, |
| 146 | source](std::shared_ptr<ipc::RecordBatchFileReader> reader) |
| 147 | -> Future<std::shared_ptr<ipc::RecordBatchFileReader>> { |
| 148 | ARROW_ASSIGN_OR_RAISE(auto options, |
| 149 | GetReadOptions(*reader->schema(), *self, *options)); |
| 150 | return OpenReader(source, options); |
| 151 | }; |
| 152 | auto readahead_level = options->batch_readahead; |
| 153 | auto default_fragment_scan_options = this->default_fragment_scan_options; |
| 154 | auto open_generator = [=](const std::shared_ptr<ipc::RecordBatchFileReader>& reader) |
| 155 | -> Result<RecordBatchGenerator> { |
| 156 | ARROW_ASSIGN_OR_RAISE( |
| 157 | auto ipc_scan_options, |
| 158 | GetFragmentScanOptions<IpcFragmentScanOptions>(kIpcTypeName, options.get(), |
| 159 | default_fragment_scan_options)); |
| 160 | |
| 161 | RecordBatchGenerator generator; |
| 162 | if (ipc_scan_options->cache_options) { |
| 163 | // Transferring helps performance when coalescing |
| 164 | ARROW_ASSIGN_OR_RAISE(generator, reader->GetRecordBatchGenerator( |
| 165 | /*coalesce=*/true, options->io_context, |
| 166 | *ipc_scan_options->cache_options, |
| 167 | ::arrow::internal::GetCpuThreadPool())); |
| 168 | } else { |
| 169 | ARROW_ASSIGN_OR_RAISE(generator, reader->GetRecordBatchGenerator( |
| 170 | /*coalesce=*/false, options->io_context)); |
| 171 | } |
| 172 | WRAP_ASYNC_GENERATOR_WITH_CHILD_SPAN( |
| 173 | generator, "arrow::dataset::IpcFileFormat::ScanBatchesAsync::Next"); |
| 174 | if (readahead_level == 0) { |
| 175 | return MakeChunkedBatchGenerator(std::move(generator), options->batch_size); |
| 176 | } |
| 177 | auto batch_generator = MakeReadaheadGenerator(std::move(generator), readahead_level); |
| 178 | return MakeChunkedBatchGenerator(std::move(batch_generator), options->batch_size); |
| 179 | }; |
| 180 | return MakeFromFuture(open_reader.Then(reopen_reader).Then(open_generator)); |
| 181 | } |
| 182 | |
| 183 | Future<std::optional<int64_t>> IpcFileFormat::CountRows( |
| 184 | const std::shared_ptr<FileFragment>& file, compute::Expression predicate, |
nothing calls this directly
no test coverage detected