| 1164 | |
| 1165 | private: |
| 1166 | Future<> Init(const std::shared_ptr<CSVRowCounter>& self) { |
| 1167 | ARROW_ASSIGN_OR_RAISE(auto istream_it, |
| 1168 | io::MakeInputStreamIterator(input_, read_options_.block_size)); |
| 1169 | // TODO Consider exposing readahead as a read option (ARROW-12090) |
| 1170 | ARROW_ASSIGN_OR_RAISE(auto bg_it, MakeBackgroundGenerator(std::move(istream_it), |
| 1171 | io_context_.executor())); |
| 1172 | auto transferred_it = MakeTransferredGenerator(bg_it, cpu_executor_); |
| 1173 | auto buffer_generator = CSVBufferIterator::MakeAsync(std::move(transferred_it)); |
| 1174 | |
| 1175 | return buffer_generator().Then( |
| 1176 | [self, buffer_generator](std::shared_ptr<Buffer> first_buffer) { |
| 1177 | if (!first_buffer) { |
| 1178 | return Status::Invalid("Empty CSV file"); |
| 1179 | } |
| 1180 | RETURN_NOT_OK(self->ProcessHeader(first_buffer, &first_buffer)); |
| 1181 | self->block_generator_ = SerialBlockReader::MakeAsyncIterator( |
| 1182 | buffer_generator, MakeChunker(self->parse_options_), |
| 1183 | std::move(first_buffer), 0); |
| 1184 | return Status::OK(); |
| 1185 | }); |
| 1186 | } |
| 1187 | |
| 1188 | Future<int64_t> DoCount(const std::shared_ptr<CSVRowCounter>& self) { |
| 1189 | // count_cb must return a value instead of Status/Future<> to work with |
no test coverage detected