| 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 |
| 1190 | // MakeMappedGenerator, and it must use a type with a valid end value to work with |
| 1191 | // IterationEnd. |
| 1192 | std::function<Result<std::optional<int64_t>>(const CSVBlock&)> count_cb = |
| 1193 | [self](const CSVBlock& maybe_block) -> Result<std::optional<int64_t>> { |
| 1194 | ARROW_ASSIGN_OR_RAISE(auto parsed_block, self->Parse(maybe_block)); |
| 1195 | int32_t total_row_count = parsed_block.parser->total_num_rows(); |
| 1196 | self->row_count_ += total_row_count; |
| 1197 | return total_row_count; |
| 1198 | }; |
| 1199 | auto count_gen = MakeMappedGenerator(block_generator_, std::move(count_cb)); |
| 1200 | return DiscardAllFromAsyncGenerator(count_gen).Then( |
| 1201 | [self]() { return self->row_count_; }); |
| 1202 | } |
| 1203 | |
| 1204 | Executor* cpu_executor_; |
| 1205 | AsyncGenerator<CSVBlock> block_generator_; |
no test coverage detected