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

Method RunEndEncoded

cpp/src/arrow/testing/random.cc:977–997  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

975}
976
977std::shared_ptr<Array> RandomArrayGenerator::RunEndEncoded(
978 std::shared_ptr<DataType> value_type, int64_t logical_size, double null_probability) {
979 Int32Builder run_ends_builder;
980 pcg32 rng(seed());
981
982 DCHECK_LE(logical_size, std::numeric_limits<int32_t>::max());
983
984 std::uniform_int_distribution<int64_t> distribution(1, 100);
985 int64_t current_end = 0;
986 while (current_end < logical_size) {
987 current_end += distribution(rng);
988 current_end = std::min(current_end, logical_size);
989 ARROW_CHECK_OK(run_ends_builder.Append(static_cast<int32_t>(current_end)));
990 }
991
992 std::shared_ptr<Array> run_ends = *run_ends_builder.Finish();
993 std::shared_ptr<Array> values =
994 ArrayOf(std::move(value_type), run_ends->length(), null_probability);
995
996 return RunEndEncodedArray::Make(logical_size, run_ends, values).ValueOrDie();
997}
998
999std::shared_ptr<Array> RandomArrayGenerator::SparseUnion(const ArrayVector& fields,
1000 int64_t size, int64_t alignment,

Callers 1

MakeRunEndEncodedFunction · 0.80

Calls 6

seedFunction · 0.85
ValueOrDieMethod · 0.80
MakeFunction · 0.50
AppendMethod · 0.45
FinishMethod · 0.45
lengthMethod · 0.45

Tested by 1

MakeRunEndEncodedFunction · 0.64