MCPcopy Create free account
hub / github.com/apache/arrow / DoCount

Method DoCount

cpp/src/arrow/csv/reader.cc:1196–1210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

CountMethod · 0.95

Calls 3

MakeMappedGeneratorFunction · 0.85
ThenMethod · 0.80

Tested by

no test coverage detected