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

Method arrayVectorImpl

bolt/vector/tests/utils/VectorMaker.h:384–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382
383 template <typename T>
384 ArrayVectorPtr arrayVectorImpl(
385 const TypePtr& type,
386 vector_size_t size,
387 std::function<vector_size_t(vector_size_t /* row */)> sizeAt,
388 std::function<T(vector_size_t /* row */, vector_size_t /* idx */)>
389 valueAt,
390 std::function<bool(vector_size_t /*row */)> isNullAt = nullptr) {
391 BufferPtr nulls;
392 BufferPtr offsets;
393 BufferPtr sizes;
394 auto numElements =
395 createOffsetsAndSizes(size, sizeAt, isNullAt, &nulls, &offsets, &sizes);
396
397 auto flatVector = BaseVector::create<FlatVector<EvalType<T>>>(
398 type->childAt(0), numElements, pool_);
399 vector_size_t currentIndex = 0;
400 for (vector_size_t i = 0; i < size; ++i) {
401 if (isNullAt && isNullAt(i)) {
402 continue;
403 }
404 for (vector_size_t j = 0; j < sizeAt(i); ++j) {
405 auto value = valueAt(i, j);
406 flatVector->set(currentIndex, EvalType<T>(value));
407 currentIndex++;
408 }
409 }
410
411 return std::make_shared<ArrayVector>(
412 pool_,
413 type,
414 nulls,
415 size,
416 offsets,
417 sizes,
418 flatVector,
419 BaseVector::countNulls(nulls, 0, size));
420 }
421
422 /// Create a ArrayVector<T>
423 /// size and null for individual array is determined by sizeAt and isNullAt

Callers

nothing calls this directly

Calls 7

allocateOffsetsFunction · 0.85
allocateSizesFunction · 0.85
childAtMethod · 0.80
isNullAtFunction · 0.50
countNullsFunction · 0.50
setMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected