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

Function ConstructFakeMetaData

cpp/src/parquet/page_index_test.cc:274–314  ·  view source on GitHub ↗

Creates an FileMetaData object w/ single row group based on data in 'row_group_ranges'. It sets the offsets and sizes of the column index and offset index members of the row group. It doesn't set the member if the input value is -1.

Source from the content-addressed store, hash-verified

272/// 'row_group_ranges'. It sets the offsets and sizes of the column index and offset index
273/// members of the row group. It doesn't set the member if the input value is -1.
274std::shared_ptr<FileMetaData> ConstructFakeMetaData(
275 const RowGroupRanges& row_group_ranges) {
276 format::RowGroup row_group;
277 for (auto& page_index_ranges : row_group_ranges) {
278 format::ColumnChunk col_chunk;
279 if (page_index_ranges.column_index_offset != -1) {
280 col_chunk.__set_column_index_offset(page_index_ranges.column_index_offset);
281 }
282 if (page_index_ranges.column_index_length != -1) {
283 col_chunk.__set_column_index_length(
284 static_cast<int32_t>(page_index_ranges.column_index_length));
285 }
286 if (page_index_ranges.offset_index_offset != -1) {
287 col_chunk.__set_offset_index_offset(page_index_ranges.offset_index_offset);
288 }
289 if (page_index_ranges.offset_index_length != -1) {
290 col_chunk.__set_offset_index_length(
291 static_cast<int32_t>(page_index_ranges.offset_index_length));
292 }
293 row_group.columns.push_back(col_chunk);
294 }
295
296 format::FileMetaData metadata;
297 metadata.row_groups.push_back(row_group);
298
299 metadata.schema.emplace_back();
300 schema::NodeVector fields;
301 for (size_t i = 0; i < row_group_ranges.size(); ++i) {
302 fields.push_back(schema::Int64(std::to_string(i)));
303 metadata.schema.emplace_back();
304 fields.back()->ToParquet(&metadata.schema.back());
305 }
306 schema::GroupNode::Make("schema", Repetition::REPEATED, fields)
307 ->ToParquet(&metadata.schema.front());
308
309 auto sink = CreateOutputStream();
310 ThriftSerializer{}.Serialize(&metadata, sink.get());
311 auto buffer = sink->Finish().MoveValueUnsafe();
312 uint32_t len = static_cast<uint32_t>(buffer->size());
313 return FileMetaData::Make(buffer->data(), &len);
314}
315
316/// Validates that 'DeterminePageIndexRangesInRowGroup()' selects the expected file
317/// offsets and sizes or returns false when the row group doesn't have a page index.

Callers 1

ValidatePageIndexRangeFunction · 0.85

Calls 15

to_stringFunction · 0.85
CreateOutputStreamFunction · 0.85
push_backMethod · 0.80
emplace_backMethod · 0.80
ToParquetMethod · 0.80
backMethod · 0.80
MoveValueUnsafeMethod · 0.80
MakeFunction · 0.70

Tested by

no test coverage detected