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

Function FuzzReader

cpp/src/parquet/arrow/fuzz_internal.cc:190–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188} // namespace
189
190Status FuzzReader(const uint8_t* data, int64_t size) {
191 Status st;
192
193 auto buffer = std::make_shared<::arrow::Buffer>(data, size);
194 auto file = std::make_shared<::arrow::io::BufferReader>(buffer);
195 auto pool = ::arrow::internal::fuzzing_memory_pool();
196 auto reader_properties = MakeFuzzReaderProperties(pool);
197
198 std::default_random_engine rng(/*seed*/ 42);
199
200 // Read Parquet file metadata only once, which will reduce iteration time slightly
201 std::shared_ptr<FileMetaData> pq_md;
202 BEGIN_PARQUET_CATCH_EXCEPTIONS {
203 int num_row_groups, num_columns;
204 auto pq_file_reader = ParquetFileReader::Open(file, reader_properties);
205 {
206 // Read some additional metadata (often lazy-decoded, such as statistics)
207 pq_md = pq_file_reader->metadata();
208 num_row_groups = pq_md->num_row_groups();
209 num_columns = pq_md->num_columns();
210 for (int i = 0; i < num_row_groups; ++i) {
211 auto rg = pq_md->RowGroup(i);
212 rg->sorting_columns();
213 for (int j = 0; j < num_columns; ++j) {
214 auto col = rg->ColumnChunk(j);
215 col->encoded_statistics();
216 col->statistics();
217 col->geo_statistics();
218 col->size_statistics();
219 col->key_value_metadata();
220 col->encodings();
221 col->encoding_stats();
222 }
223 }
224 }
225 {
226 // Read and decode bloom filters
227 auto& bloom_reader = pq_file_reader->GetBloomFilterReader();
228 std::uniform_int_distribution<uint64_t> hash_dist;
229 for (int i = 0; i < num_row_groups; ++i) {
230 auto bloom_rg = bloom_reader.RowGroup(i);
231 for (int j = 0; j < num_columns; ++j) {
232 st &= FuzzReadBloomFilter(bloom_rg.get(), j, hash_dist, rng);
233 }
234 }
235 }
236 {
237 // Read and decode page indexes
238 auto index_reader = pq_file_reader->GetPageIndexReader();
239 for (int i = 0; i < num_row_groups; ++i) {
240 auto index_rg = index_reader->RowGroup(i);
241 if (index_rg) {
242 for (int j = 0; j < num_columns; ++j) {
243 st &= FuzzReadPageIndex(index_rg.get(), pq_md->schema(), j);
244 }
245 }
246 }
247 }

Callers 2

LLVMFuzzerTestOneInputFunction · 0.85
TESTFunction · 0.85

Calls 15

fuzzing_memory_poolFunction · 0.85
MakeFuzzReaderPropertiesFunction · 0.85
FuzzReadBloomFilterFunction · 0.85
FuzzReadPageIndexFunction · 0.85
geo_statisticsMethod · 0.80
metadataMethod · 0.45
num_row_groupsMethod · 0.45
num_columnsMethod · 0.45
RowGroupMethod · 0.45
sorting_columnsMethod · 0.45
ColumnChunkMethod · 0.45
encoded_statisticsMethod · 0.45

Tested by 1

TESTFunction · 0.68