MCPcopy Create free account
hub / github.com/apache/arrow / Make

Method Make

cpp/src/arrow/acero/hash_join_node.cc:725–782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723 }
724
725 static Result<ExecNode*> Make(ExecPlan* plan, std::vector<ExecNode*> inputs,
726 const ExecNodeOptions& options) {
727 // Number of input exec nodes must be 2
728 RETURN_NOT_OK(ValidateExecNodeInputs(plan, inputs, 2, "HashJoinNode"));
729
730 std::unique_ptr<HashJoinSchema> schema_mgr = std::make_unique<HashJoinSchema>();
731
732 const auto& join_options = checked_cast<const HashJoinNodeOptions&>(options);
733 RETURN_NOT_OK(ValidateHashJoinNodeOptions(join_options));
734
735 const auto& left_schema = *(inputs[0]->output_schema());
736 const auto& right_schema = *(inputs[1]->output_schema());
737
738 // This will also validate input schemas
739 if (join_options.output_all) {
740 RETURN_NOT_OK(schema_mgr->Init(
741 join_options.join_type, left_schema, join_options.left_keys, right_schema,
742 join_options.right_keys, join_options.filter,
743 join_options.output_suffix_for_left, join_options.output_suffix_for_right));
744 } else {
745 RETURN_NOT_OK(schema_mgr->Init(
746 join_options.join_type, left_schema, join_options.left_keys,
747 join_options.left_output, right_schema, join_options.right_keys,
748 join_options.right_output, join_options.filter,
749 join_options.output_suffix_for_left, join_options.output_suffix_for_right));
750 }
751
752 ARROW_ASSIGN_OR_RAISE(
753 Expression filter,
754 schema_mgr->BindFilter(join_options.filter, left_schema, right_schema,
755 plan->query_context()->exec_context()));
756
757 // Generate output schema
758 std::shared_ptr<Schema> output_schema = schema_mgr->MakeOutputSchema(
759 join_options.output_suffix_for_left, join_options.output_suffix_for_right);
760
761 // Create hash join implementation object
762 // SwissJoin does not support:
763 // a) 64-bit string offsets
764 // b) dictionaries
765 //
766 bool use_swiss_join;
767#if ARROW_LITTLE_ENDIAN
768 use_swiss_join = !schema_mgr->HasDictionaries() && !schema_mgr->HasLargeBinary();
769#else
770 use_swiss_join = false;
771#endif
772 std::unique_ptr<HashJoinImpl> impl;
773 if (use_swiss_join) {
774 ARROW_ASSIGN_OR_RAISE(impl, HashJoinImpl::MakeSwiss());
775 } else {
776 ARROW_ASSIGN_OR_RAISE(impl, HashJoinImpl::MakeBasic());
777 }
778
779 return plan->EmplaceNode<HashJoinNode>(
780 plan, inputs, join_options, std::move(output_schema), std::move(schema_mgr),
781 std::move(filter), std::move(impl));
782 }

Callers

nothing calls this directly

Calls 7

ValidateExecNodeInputsFunction · 0.85
HasDictionariesMethod · 0.80
HasLargeBinaryMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
InitMethod · 0.45
MakeOutputSchemaMethod · 0.45

Tested by

no test coverage detected