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

Method testSlice

bolt/vector/tests/VectorTest.cpp:675–763  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

673 }
674
675 static void testSlice(
676 const VectorPtr& vec,
677 int level,
678 vector_size_t offset,
679 vector_size_t length) {
680 SCOPED_TRACE(fmt::format(
681 "testSlice encoding={} offset={} length={}",
682 vec->encoding(),
683 offset,
684 length));
685 ASSERT_GE(vec->size(), offset + length);
686 auto slice = vec->loadedVector()->slice(offset, length);
687 ASSERT_EQ(slice->size(), length);
688 // Compare values and nulls directly.
689 for (int i = 0; i < length; ++i) {
690 EXPECT_TRUE(slice->equalValueAt(vec.get(), i, offset + i));
691 }
692 { // Check DecodedVector works on slice.
693 SelectivityVector allRows(length);
694 DecodedVector decoded(*slice, allRows);
695 auto base = decoded.base();
696 auto indices = decoded.indices();
697 for (int i = 0; i < length; ++i) {
698 auto j = offset + i;
699 if (vec->isNullAt(j)) {
700 EXPECT_TRUE(decoded.isNullAt(i));
701 } else {
702 ASSERT_FALSE(decoded.isNullAt(i));
703 auto ii = indices ? indices[i] : i;
704 EXPECT_TRUE(base->equalValueAt(vec.get(), ii, j));
705 }
706 }
707 }
708 if (level == 0) {
709 return;
710 }
711 // Add constant wrapping.
712 if (auto i = 3 + level; i < slice->size()) {
713 testSlices(BaseVector::wrapInConstant(123, i, slice), level - 1);
714 }
715 // Add constant wrapping using null row.
716 if (slice->mayHaveNulls() && !slice->isLazy()) {
717 for (int i = 0; i < slice->size(); ++i) {
718 if (slice->isNullAt(i)) {
719 testSlices(BaseVector::wrapInConstant(i + 123, i, slice), level - 1);
720 break;
721 }
722 }
723 }
724 {
725 // Add dictionary wrapping to put vectors elements in reverse order. If
726 // 'source' has nulls, add more nulls every 11-th row starting with row #
727 // 'level'.
728 BufferPtr nulls;
729 uint64_t* rawNulls = nullptr;
730 if (slice->mayHaveNulls()) {
731 nulls = allocateNulls(slice->size(), slice->pool());
732 rawNulls = nulls->asMutable<uint64_t>();

Callers

nothing calls this directly

Calls 15

allocateNullsFunction · 0.85
wrapInDictionaryFunction · 0.85
equalValueAtMethod · 0.80
indicesMethod · 0.80
setNullFunction · 0.50
encodingMethod · 0.45
sizeMethod · 0.45
sliceMethod · 0.45
loadedVectorMethod · 0.45
getMethod · 0.45
baseMethod · 0.45
isNullAtMethod · 0.45

Tested by

no test coverage detected