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

Function SampleData

cpp/src/parquet/arrow/generate_encoding_fuzz_corpus.cc:90–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88};
89
90Result<std::vector<DataWithEncodings>> SampleData() {
91 auto rag = random::RandomArrayGenerator(/*seed=*/42);
92 std::vector<DataWithEncodings> all_data;
93
94 auto push_array = [&](std::shared_ptr<Array> arr, EncodingVector encodings = {}) {
95 auto pq_type = FullParquetType::FromArrow(*arr->type());
96 if (encodings.empty()) {
97 encodings = ::parquet::SupportedEncodings(pq_type.type);
98 }
99 all_data.emplace_back(pq_type, arr, std::move(encodings));
100 };
101
102 for (const auto size : {100, 10000}) {
103 push_array(rag.Int32(size, /*min=*/0, /*max=*/10));
104 push_array(rag.Int32(size, /*min=*/std::numeric_limits<int32_t>::min(),
105 /*max=*/std::numeric_limits<int32_t>::max()));
106 push_array(rag.Int64(size, /*min=*/0, /*max=*/0));
107 push_array(rag.Int64(size, /*min=*/0, /*max=*/10'000));
108 push_array(rag.Int64(size, /*min=*/std::numeric_limits<int64_t>::min(),
109 /*max=*/std::numeric_limits<int64_t>::max()));
110 for (const double true_probability : {0.01, 0.5, 0.9}) {
111 push_array(rag.Boolean(size, true_probability));
112 }
113 push_array(rag.Float32(size, /*min=*/-1.0f, /*max=*/1.0f));
114 push_array(rag.Float32(size, /*min=*/std::numeric_limits<float>::lowest(),
115 /*max=*/std::numeric_limits<float>::max(),
116 /*null_probability=*/0.0, /*nan_probability=*/1e-2));
117 push_array(rag.Float64(size, /*min=*/-1.0, /*max=*/1.0));
118 push_array(rag.Float64(size, /*min=*/std::numeric_limits<double>::lowest(),
119 /*max=*/std::numeric_limits<double>::max(),
120 /*null_probability=*/0.0, /*nan_probability=*/1e-2));
121 for (const int32_t byte_width : {1, 3, 16}) {
122 const auto fsb_size = size / byte_width;
123 push_array(rag.FixedSizeBinary(fsb_size, byte_width));
124 }
125 for (const int32_t max_binary_length : {1, 30}) {
126 const auto binary_size = size / max_binary_length;
127 push_array(rag.BinaryWithRepeats(binary_size, /*unique=*/binary_size / 2,
128 /*min_length=*/0,
129 /*max_length=*/max_binary_length));
130 }
131 }
132
133 return all_data;
134}
135
136using Int96Vector = std::vector<Int96>;
137

Callers

nothing calls this directly

Calls 11

SupportedEncodingsFunction · 0.85
emplace_backMethod · 0.80
Int32Method · 0.80
BinaryWithRepeatsMethod · 0.80
typeMethod · 0.45
emptyMethod · 0.45
Int64Method · 0.45
BooleanMethod · 0.45
Float32Method · 0.45
Float64Method · 0.45
FixedSizeBinaryMethod · 0.45

Tested by

no test coverage detected