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