| 13 | namespace processor { |
| 14 | |
| 15 | HashJoinBuildInfo PlanMapper::createHashBuildInfo(const Schema& buildSideSchema, |
| 16 | const expression_vector& keys, const expression_vector& payloads) { |
| 17 | f_group_pos_set keyGroupPosSet; |
| 18 | std::vector<DataPos> keysPos; |
| 19 | std::vector<FStateType> fStateTypes; |
| 20 | std::vector<DataPos> payloadsPos; |
| 21 | auto tableSchema = FactorizedTableSchema(); |
| 22 | for (auto& key : keys) { |
| 23 | auto pos = DataPos(buildSideSchema.getExpressionPos(*key)); |
| 24 | keyGroupPosSet.insert(pos.dataChunkPos); |
| 25 | // Keys are always stored in flat column. |
| 26 | auto columnSchema = ColumnSchema(false /* isUnFlat */, pos.dataChunkPos, |
| 27 | LogicalTypeUtils::getRowLayoutSize(key->dataType)); |
| 28 | tableSchema.appendColumn(std::move(columnSchema)); |
| 29 | keysPos.push_back(pos); |
| 30 | fStateTypes.push_back(buildSideSchema.getGroup(pos.dataChunkPos)->isFlat() ? |
| 31 | FStateType::FLAT : |
| 32 | FStateType::UNFLAT); |
| 33 | } |
| 34 | for (auto& payload : payloads) { |
| 35 | auto pos = DataPos(buildSideSchema.getExpressionPos(*payload)); |
| 36 | if (keyGroupPosSet.contains(pos.dataChunkPos) || |
| 37 | buildSideSchema.getGroup(pos.dataChunkPos)->isFlat()) { |
| 38 | // Payloads need to be stored in flat column in 2 cases |
| 39 | // 1. payload is in the same chunk as a key. Since keys are always stored as flat, |
| 40 | // payloads must also be stored as flat. |
| 41 | // 2. payload is in flat chunk |
| 42 | auto columnSchema = ColumnSchema(false /* isUnFlat */, pos.dataChunkPos, |
| 43 | LogicalTypeUtils::getRowLayoutSize(payload->dataType)); |
| 44 | tableSchema.appendColumn(std::move(columnSchema)); |
| 45 | } else { |
| 46 | auto columnSchema = |
| 47 | ColumnSchema(true /* isUnFlat */, pos.dataChunkPos, sizeof(overflow_value_t)); |
| 48 | tableSchema.appendColumn(std::move(columnSchema)); |
| 49 | } |
| 50 | payloadsPos.push_back(pos); |
| 51 | } |
| 52 | auto hashValueColumn = ColumnSchema(false /* isUnFlat */, INVALID_DATA_CHUNK_POS, |
| 53 | LogicalTypeUtils::getRowLayoutSize(LogicalType::HASH())); |
| 54 | tableSchema.appendColumn(std::move(hashValueColumn)); |
| 55 | auto pointerColumn = ColumnSchema(false /* isUnFlat */, INVALID_DATA_CHUNK_POS, |
| 56 | LogicalTypeUtils::getRowLayoutSize(LogicalType::INT64())); |
| 57 | tableSchema.appendColumn(std::move(pointerColumn)); |
| 58 | return HashJoinBuildInfo(std::move(keysPos), std::move(fStateTypes), std::move(payloadsPos), |
| 59 | std::move(tableSchema)); |
| 60 | } |
| 61 | |
| 62 | std::unique_ptr<PhysicalOperator> PlanMapper::mapHashJoin(const LogicalOperator* logicalOperator) { |
| 63 | auto hashJoin = logicalOperator->constPtrCast<LogicalHashJoin>(); |
nothing calls this directly
no test coverage detected