| 77 | } |
| 78 | |
| 79 | Result<std::vector<FieldRef>> HashJoinSchema::ComputePayload( |
| 80 | const Schema& schema, const std::vector<FieldRef>& output, |
| 81 | const std::vector<FieldRef>& filter, const std::vector<FieldRef>& keys) { |
| 82 | // payload = (output + filter) - keys, with no duplicates |
| 83 | std::unordered_set<int> payload_fields; |
| 84 | for (const auto& ref : output) { |
| 85 | ARROW_ASSIGN_OR_RAISE(auto match, ref.FindOne(schema)); |
| 86 | payload_fields.insert(match[0]); |
| 87 | } |
| 88 | |
| 89 | for (const auto& ref : filter) { |
| 90 | ARROW_ASSIGN_OR_RAISE(auto match, ref.FindOne(schema)); |
| 91 | payload_fields.insert(match[0]); |
| 92 | } |
| 93 | |
| 94 | for (const auto& ref : keys) { |
| 95 | ARROW_ASSIGN_OR_RAISE(auto match, ref.FindOne(schema)); |
| 96 | payload_fields.erase(match[0]); |
| 97 | } |
| 98 | |
| 99 | std::vector<FieldRef> payload_refs; |
| 100 | for (const auto& ref : output) { |
| 101 | ARROW_ASSIGN_OR_RAISE(auto match, ref.FindOne(schema)); |
| 102 | if (payload_fields.find(match[0]) != payload_fields.end()) { |
| 103 | payload_refs.push_back(ref); |
| 104 | payload_fields.erase(match[0]); |
| 105 | } |
| 106 | } |
| 107 | for (const auto& ref : filter) { |
| 108 | ARROW_ASSIGN_OR_RAISE(auto match, ref.FindOne(schema)); |
| 109 | if (payload_fields.find(match[0]) != payload_fields.end()) { |
| 110 | payload_refs.push_back(ref); |
| 111 | payload_fields.erase(match[0]); |
| 112 | } |
| 113 | } |
| 114 | return payload_refs; |
| 115 | } |
| 116 | |
| 117 | Status HashJoinSchema::Init(JoinType join_type, const Schema& left_schema, |
| 118 | const std::vector<FieldRef>& left_keys, |