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

Function MakeVectorGenerator

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

Source from the content-addressed store, hash-verified

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

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
TEST_FFunction · 0.68