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

Function StatisticsAsScalars

cpp/src/parquet/arrow/reader_internal.cc:306–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304} // namespace
305
306Status StatisticsAsScalars(const Statistics& statistics,
307 std::shared_ptr<::arrow::Scalar>* min,
308 std::shared_ptr<::arrow::Scalar>* max) {
309 if (!statistics.HasMinMax()) {
310 return Status::Invalid("Statistics has no min max.");
311 }
312
313 auto column_desc = statistics.descr();
314 if (column_desc == nullptr) {
315 return Status::Invalid("Statistics carries no descriptor, can't infer arrow type.");
316 }
317
318 auto physical_type = column_desc->physical_type();
319 auto logical_type = column_desc->logical_type();
320 switch (physical_type) {
321 case Type::BOOLEAN:
322 return MakeMinMaxScalar<bool, BoolStatistics>(
323 checked_cast<const BoolStatistics&>(statistics), min, max);
324 case Type::FLOAT:
325 return MakeMinMaxScalar<float, FloatStatistics>(
326 checked_cast<const FloatStatistics&>(statistics), min, max);
327 case Type::DOUBLE:
328 return MakeMinMaxScalar<double, DoubleStatistics>(
329 checked_cast<const DoubleStatistics&>(statistics), min, max);
330 case Type::INT32:
331 return FromInt32Statistics(checked_cast<const Int32Statistics&>(statistics),
332 *logical_type, min, max);
333 case Type::INT64:
334 return FromInt64Statistics(checked_cast<const Int64Statistics&>(statistics),
335 *logical_type, min, max);
336 case Type::BYTE_ARRAY:
337 case Type::FIXED_LEN_BYTE_ARRAY:
338 return ByteArrayStatisticsAsScalars(statistics, min, max);
339 default:
340 return Status::NotImplemented("Extract statistics unsupported for physical_type ",
341 physical_type, " unsupported.");
342 }
343
344 return Status::OK();
345}
346
347// ----------------------------------------------------------------------
348// Primitive types

Calls 9

FromInt32StatisticsFunction · 0.85
FromInt64StatisticsFunction · 0.85
HasMinMaxMethod · 0.80
physical_typeMethod · 0.80
InvalidFunction · 0.50
NotImplementedFunction · 0.50
OKFunction · 0.50
descrMethod · 0.45

Tested by 1