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

Method testDictionary

bolt/vector/tests/DecodedVectorTest.cpp:419–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417
418 template <typename T>
419 void testDictionary(
420 vector_size_t size,
421 std::function<T(vector_size_t /*index*/)> valueAt,
422 const TypePtr& type = CppToType<T>::create()) {
423 BufferPtr indices = makeEvenIndices(size);
424 auto dictionarySize = size / 2;
425 auto flatVector = makeFlatVector<T>(size, valueAt, nullptr, type);
426
427 auto dictionaryVector = std::dynamic_pointer_cast<DictionaryVector<T>>(
428 BaseVector::wrapInDictionary(
429 BufferPtr(nullptr), indices, dictionarySize, flatVector));
430 auto check = [&](const auto& decoded) {
431 EXPECT_FALSE(decoded.isConstantMapping());
432 EXPECT_FALSE(decoded.isIdentityMapping());
433 for (int32_t i = 0; i < dictionaryVector->size(); i++) {
434 EXPECT_FALSE(decoded.isNullAt(i)) << "at " << i;
435 EXPECT_EQ(decoded.template valueAt<T>(i), dictionaryVector->valueAt(i))
436 << "at " << i;
437 }
438 };
439
440 {
441 SelectivityVector selection(dictionarySize);
442 DecodedVector decoded(*dictionaryVector, selection);
443 check(decoded);
444 }
445
446 {
447 DecodedVector decoded(*dictionaryVector);
448 check(decoded);
449 }
450 }
451
452 SelectivityVector allSelected_;
453 SelectivityVector halfSelected_;

Callers

nothing calls this directly

Calls 7

wrapInDictionaryFunction · 0.85
isConstantMappingMethod · 0.80
isIdentityMappingMethod · 0.80
createFunction · 0.50
sizeMethod · 0.45
isNullAtMethod · 0.45
valueAtMethod · 0.45

Tested by

no test coverage detected