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

Method SampleUniqueBinary

cpp/src/arrow/compute/key_hash_test.cc:80–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79 template <typename Type, typename ArrayType = typename TypeTraits<Type>::ArrayType>
80 static Result<std::pair<std::vector<int>, std::shared_ptr<ArrayType>>>
81 SampleUniqueBinary(random::pcg32_fast* random, int num, const ArrayType& uniques) {
82 using BuilderType = typename TypeTraits<Type>::BuilderType;
83 BuilderType builder;
84 std::vector<int> row_ids;
85 row_ids.resize(num);
86
87 std::uniform_int_distribution<int> row_id_gen(0,
88 static_cast<int>(uniques.length()) - 1);
89 for (int i = 0; i < num; ++i) {
90 int row_id = row_id_gen(*random);
91 row_ids[i] = row_id;
92 ARROW_RETURN_NOT_OK(builder.Append(uniques.GetView(row_id)));
93 }
94 ARROW_ASSIGN_OR_RAISE(std::shared_ptr<Array> sampled, builder.Finish());
95 return std::pair<std::vector<int>, std::shared_ptr<ArrayType>>{
96 std::move(row_ids), checked_pointer_cast<ArrayType>(sampled)};
97 }
98
99 public:
100 template <typename Type>

Callers

nothing calls this directly

Calls 6

resizeMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.50
lengthMethod · 0.45
AppendMethod · 0.45
GetViewMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected