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

Function GenJoinFieldRefs

cpp/src/arrow/acero/hash_join_node_test.cc:836–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

834}
835
836void GenJoinFieldRefs(Random64Bit& rng, int num_key_fields, bool no_output,
837 const std::vector<std::shared_ptr<Array>>& original_input,
838 const std::string& field_name_prefix,
839 std::vector<std::shared_ptr<Array>>* new_input,
840 std::vector<FieldRef>* keys, std::vector<FieldRef>* output,
841 std::vector<int>* output_field_ids) {
842 // Permute input
843 std::vector<int> shuffle = GenShuffle(rng, static_cast<int>(original_input.size()));
844 new_input->resize(original_input.size());
845 for (size_t i = 0; i < original_input.size(); ++i) {
846 (*new_input)[i] = original_input[shuffle[i]];
847 }
848
849 // Compute key field refs
850 keys->resize(num_key_fields);
851 for (size_t i = 0; i < shuffle.size(); ++i) {
852 if (shuffle[i] < num_key_fields) {
853 bool use_by_name_ref = (rng.from_range(0, 1) == 0);
854 if (use_by_name_ref) {
855 (*keys)[shuffle[i]] = FieldRef(field_name_prefix + std::to_string(i));
856 } else {
857 (*keys)[shuffle[i]] = FieldRef(static_cast<int>(i));
858 }
859 }
860 }
861
862 // Compute output field refs
863 if (!no_output) {
864 int num_output = rng.from_range(1, static_cast<int>(original_input.size() + 1));
865 output_field_ids->resize(num_output);
866 output->resize(num_output);
867 for (int i = 0; i < num_output; ++i) {
868 int col_id = rng.from_range(0, static_cast<int>(original_input.size() - 1));
869 (*output_field_ids)[i] = col_id;
870 (*output)[i] = (rng.from_range(0, 1) == 0)
871 ? FieldRef(field_name_prefix + std::to_string(col_id))
872 : FieldRef(col_id);
873 }
874 }
875}
876
877std::shared_ptr<Table> HashJoinSimple(
878 ExecContext* ctx, JoinType join_type, const std::vector<JoinKeyCmp>& cmp,

Callers 1

TESTFunction · 0.85

Calls 6

GenShuffleFunction · 0.85
to_stringFunction · 0.85
resizeMethod · 0.80
from_rangeMethod · 0.80
FieldRefFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected