MCPcopy Create free account
hub / github.com/bytedance/bolt / gatherCopyTest

Method gatherCopyTest

bolt/exec/tests/OperatorUtilsTest.cpp:71–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 driverCtx_->driver = driver_.get();
70 }
71
72 void gatherCopyTest(
73 const std::shared_ptr<const RowType>& targetType,
74 const std::shared_ptr<const RowType>& sourceType,
75 int numSources) {
76 folly::Random::DefaultGenerator rng(1);
77 const int kNumRows = 500;
78 const int kNumColumns = sourceType->size();
79
80 // Build source vectors with nulls.
81 std::vector<RowVectorPtr> sources;
82 for (int i = 0; i < numSources; ++i) {
83 sources.push_back(std::static_pointer_cast<RowVector>(
84 BatchMaker::createBatch(sourceType, kNumRows, *pool_)));
85 for (int j = 0; j < kNumColumns; ++j) {
86 auto vector = sources.back()->childAt(j);
87 int nullRow = (folly::Random::rand32() % kNumRows) / 4;
88 while (nullRow < kNumRows) {
89 vector->setNull(nullRow, true);
90 nullRow +=
91 std::max<int>(1, (folly::Random::rand32() % kNumColumns) / 4);
92 }
93 }
94 }
95
96 std::vector<IdentityProjection> columnMap;
97 if (sourceType != targetType) {
98 for (column_index_t sourceChannel = 0; sourceChannel < kNumColumns;
99 ++sourceChannel) {
100 const auto columnName = sourceType->nameOf(sourceChannel);
101 const column_index_t targetChannel =
102 targetType->getChildIdx(columnName);
103 columnMap.emplace_back(sourceChannel, targetChannel);
104 }
105 }
106
107 std::vector<const RowVector*> sourcesVectors(kNumRows);
108 std::vector<vector_size_t> sourceIndices(kNumRows);
109 for (int iter = 0; iter < 5; ++iter) {
110 const int count =
111 folly::Random::oneIn(10) ? 0 : folly::Random::rand32() % kNumRows;
112 const int targetIndex = folly::Random::rand32() % (kNumRows - count);
113 for (int i = 0; i < count; ++i) {
114 sourcesVectors[i] = sources[folly::Random::rand32() % numSources].get();
115 sourceIndices[i] = sourceIndices[folly::Random::rand32() % kNumRows];
116 }
117 auto targetVector =
118 BaseVector::create<RowVector>(targetType, kNumRows, pool_.get());
119 for (int32_t childIdx = 0; childIdx < targetVector->childrenSize();
120 ++childIdx) {
121 targetVector->childAt(childIdx)->resize(kNumRows);
122 }
123 gatherCopy(
124 targetVector.get(),
125 targetIndex,
126 count,
127 sourcesVectors,
128 sourceIndices,

Callers

nothing calls this directly

Calls 14

gatherCopyFunction · 0.85
childAtMethod · 0.80
backMethod · 0.80
getChildIdxMethod · 0.80
equalValueAtMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45
setNullMethod · 0.45
nameOfMethod · 0.45
getMethod · 0.45
childrenSizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected