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

Function MakeVectorGenerator

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

Source from the content-addressed store, hash-verified

986/// This generator is async-reentrant
987template <typename T>
988AsyncGenerator<T> MakeVectorGenerator(std::vector<T> vec) {
989 struct State {
990 explicit State(std::vector<T> vec_) : vec(std::move(vec_)), vec_idx(0) {}
991
992 std::vector<T> vec;
993 std::atomic<std::size_t> vec_idx;
994 };
995
996 auto state = std::make_shared<State>(std::move(vec));
997 return [state]() {
998 auto idx = state->vec_idx.fetch_add(1);
999 if (idx >= state->vec.size()) {
1000 // Eagerly return memory
1001 state->vec.clear();
1002 return AsyncGeneratorEnd<T>();
1003 }
1004 return Future<T>::MakeFinished(state->vec[idx]);
1005 };
1006}
1007
1008/// \see MakeMergedGenerator
1009template <typename T>

Callers 15

GetFragmentsFunction · 0.85
GetFragmentsMethod · 0.85
MakeScanNodeFunction · 0.85
ScanBatchesAsyncMethod · 0.85
genMethod · 0.85
ScanBatchesAsyncMethod · 0.85
TEST_PFunction · 0.85
genMethod · 0.85
TableGeneratorMethod · 0.85
GetFileInfoGeneratorMethod · 0.85
AsyncVectorItFunction · 0.85

Calls 2

sizeMethod · 0.45
clearMethod · 0.45

Tested by 8

ScanBatchesAsyncMethod · 0.68
genMethod · 0.68
ScanBatchesAsyncMethod · 0.68
TEST_PFunction · 0.68
genMethod · 0.68
AsyncVectorItFunction · 0.68
TESTFunction · 0.68
TEST_PFunction · 0.68