| 67 | serde_ = std::make_unique<serializer::presto::PrestoVectorSerde>(); |
| 68 | } |
| 69 | void timeFlat() { |
| 70 | // Serialize different fractions of a 10K vector of int32_t and int64_t with |
| 71 | // IndexRange and row range variants with and without nulls. |
| 72 | constexpr int32_t kPad = 8; |
| 73 | std::vector<int32_t> numSelectedValues = {3, 30, 300, 10000}; |
| 74 | std::vector<std::vector<IndexRange>> indexRanges; |
| 75 | std::vector<std::vector<vector_size_t>> rowSets; |
| 76 | std::vector<int32_t> nullPctValues = {0, 1, 10, 90}; |
| 77 | std::vector<int32_t> bitsValues = {32, 64}; |
| 78 | const int32_t vectorSize = 10000; |
| 79 | for (auto numSelected : numSelectedValues) { |
| 80 | std::vector<IndexRange> ir; |
| 81 | std::vector<vector_size_t> rr; |
| 82 | int32_t step = vectorSize / numSelected; |
| 83 | for (auto r = 0; r < vectorSize; r += step) { |
| 84 | ir.push_back(IndexRange{r, 1}); |
| 85 | rr.push_back(r); |
| 86 | } |
| 87 | std::cout << rr.size(); |
| 88 | indexRanges.push_back(std::move(ir)); |
| 89 | rr.resize(rr.size() + kPad, 999999999); |
| 90 | rowSets.push_back(std::move(rr)); |
| 91 | } |
| 92 | VectorMaker vm(pool_.get()); |
| 93 | std::vector<VectorPtr> v32s; |
| 94 | std::vector<VectorPtr> v64s; |
| 95 | for (auto nullPct : nullPctValues) { |
| 96 | auto v32 = vm.flatVector<int32_t>( |
| 97 | vectorSize, |
| 98 | [&](auto row) { return row; }, |
| 99 | [&](auto row) { return nullPct == 0 ? false : row % 100 < nullPct; }); |
| 100 | auto v64 = vm.flatVector<int64_t>( |
| 101 | vectorSize, |
| 102 | [&](auto row) { return row; }, |
| 103 | [&](auto row) { return nullPct == 0 ? false : row % 100 < nullPct; }); |
| 104 | v32s.push_back(std::move(v32)); |
| 105 | v64s.push_back(std::move(v64)); |
| 106 | } |
| 107 | std::vector<SerializeCase> cases; |
| 108 | Scratch scratch; |
| 109 | |
| 110 | auto runCase = [&](int32_t nullIdx, int32_t selIdx, int32_t bits) { |
| 111 | SerializeCase item; |
| 112 | item.vectorSize = vectorSize; |
| 113 | item.nullPct = nullPctValues[nullIdx]; |
| 114 | item.numSelected = numSelectedValues[selIdx]; |
| 115 | item.bits = bits; |
| 116 | int32_t numRepeat = 100 * vectorSize / indexRanges[selIdx].size(); |
| 117 | |
| 118 | VectorPtr vector = bits == 32 ? v32s[nullIdx] : v64s[nullIdx]; |
| 119 | auto rowType = ROW({vector->type()}); |
| 120 | auto rowVector = vm.rowVector({vector}); |
| 121 | { |
| 122 | MicrosecondTimer t(&item.irTime); |
| 123 | auto group = std::make_unique<VectorStreamGroup>(pool_.get()); |
| 124 | group->createStreamTree(rowType, rowSets[selIdx].size() - kPad); |
| 125 | for (auto repeat = 0; repeat < numRepeat; ++repeat) { |
| 126 | group->append( |
no test coverage detected