| 97 | } // namespace |
| 98 | |
| 99 | WindowBuild::WindowBuild( |
| 100 | const std::shared_ptr<const core::WindowNode>& windowNode, |
| 101 | bolt::memory::MemoryPool* pool, |
| 102 | const common::SpillConfig* spillConfig, |
| 103 | tsan_atomic<bool>* nonReclaimableSection, |
| 104 | uint64_t spillMemoryThreshold, |
| 105 | bool enableJit) |
| 106 | : spillConfig_{spillConfig}, |
| 107 | nonReclaimableSection_{nonReclaimableSection}, |
| 108 | decodedInputVectors_(windowNode->inputType()->size()), |
| 109 | sortSpillCompareFlags_{makeSpillCompareFlags( |
| 110 | windowNode->partitionKeys().size(), |
| 111 | windowNode->sortingOrders())}, |
| 112 | pool_(pool), |
| 113 | spillMemoryThreshold_(spillMemoryThreshold), |
| 114 | enableJit_(enableJit), |
| 115 | numPartitionKeys_{windowNode->partitionKeys().size()} { |
| 116 | BOLT_CHECK_NOT_NULL(pool_); |
| 117 | std::tie(inputChannels_, inversedInputChannels_, inputType_) = |
| 118 | reorderInputChannels( |
| 119 | windowNode->inputType(), |
| 120 | windowNode->partitionKeys(), |
| 121 | windowNode->sortingKeys()); |
| 122 | followedTopNum_ = windowNode->followedTopNum(); |
| 123 | const auto numPartitionKeys = windowNode->partitionKeys().size(); |
| 124 | const auto numSortingKeys = windowNode->sortingKeys().size(); |
| 125 | const auto numKeys = numPartitionKeys + numSortingKeys; |
| 126 | data_ = std::make_unique<RowContainer>( |
| 127 | slice(inputType_->children(), 0, numKeys), |
| 128 | slice(inputType_->children(), numKeys, inputType_->size()), |
| 129 | pool); |
| 130 | |
| 131 | for (auto i = 0; i < numPartitionKeys; ++i) { |
| 132 | partitionKeyInfo_.push_back(std::make_pair(i, core::SortOrder{true, true})); |
| 133 | } |
| 134 | |
| 135 | for (auto i = 0; i < numSortingKeys; ++i) { |
| 136 | sortKeyInfo_.push_back( |
| 137 | std::make_pair(numPartitionKeys + i, windowNode->sortingOrders()[i])); |
| 138 | } |
| 139 | allKeysInfo_.reserve(partitionKeyInfo_.size() + sortKeyInfo_.size()); |
| 140 | allKeysInfo_.insert( |
| 141 | allKeysInfo_.cend(), partitionKeyInfo_.begin(), partitionKeyInfo_.end()); |
| 142 | allKeysInfo_.insert( |
| 143 | allKeysInfo_.cend(), sortKeyInfo_.begin(), sortKeyInfo_.end()); |
| 144 | } |
| 145 | |
| 146 | void WindowBuild::updateEstimatedOutputRowSize() { |
| 147 | const auto optionalRowSize = data_->estimateRowSize(); |
nothing calls this directly
no test coverage detected