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

Function VisitAsyncGenerator

cpp/src/arrow/util/async_generator.h:87–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85/// returning a future that completes when all have been visited
86template <typename T, typename Visitor>
87Future<> VisitAsyncGenerator(AsyncGenerator<T> generator, Visitor visitor) {
88 struct LoopBody {
89 struct Callback {
90 Result<ControlFlow<>> operator()(const T& next) {
91 if (IsIterationEnd(next)) {
92 return Break();
93 } else {
94 auto visited = visitor(next);
95 if (visited.ok()) {
96 return Continue();
97 } else {
98 return visited;
99 }
100 }
101 }
102
103 Visitor visitor;
104 };
105
106 Future<ControlFlow<>> operator()() {
107 Callback callback{visitor};
108 auto next = generator();
109 return next.Then(std::move(callback));
110 }
111
112 AsyncGenerator<T> generator;
113 Visitor visitor;
114 };
115
116 return Loop(LoopBody{std::move(generator), std::move(visitor)});
117}
118
119/// \brief Wait for an async generator to complete, discarding results.
120template <typename T>

Callers 10

VisitBatchesAsyncMethod · 0.85
AssertScanTaskEqualsMethod · 0.85
CountRowsMethod · 0.85
FinishMethod · 0.85
BeginCaptureOutputMethod · 0.85
ReadAsyncMethod · 0.85

Calls 1

LoopFunction · 0.85

Tested by 4

AssertScanTaskEqualsMethod · 0.68
FinishMethod · 0.68
BeginCaptureOutputMethod · 0.68