MCPcopy Create free account
hub / github.com/apache/datafusion / calculate_total_byte_size

Method calculate_total_byte_size

datafusion/common/src/stats.rs:421–442  ·  view source on GitHub ↗

Calculates `total_byte_size` based on the schema and `num_rows`. If any of the columns has non-primitive width, `total_byte_size` is set to inexact.

(&mut self, schema: &Schema)

Source from the content-addressed store, hash-verified

419 /// Calculates `total_byte_size` based on the schema and `num_rows`.
420 /// If any of the columns has non-primitive width, `total_byte_size` is set to inexact.
421 pub fn calculate_total_byte_size(&mut self, schema: &Schema) {
422 let mut row_size = Some(0);
423 for field in schema.fields() {
424 match field.data_type().primitive_width() {
425 Some(width) => {
426 row_size = row_size.map(|s| s + width);
427 }
428 None => {
429 row_size = None;
430 break;
431 }
432 }
433 }
434 match row_size {
435 None => {
436 self.total_byte_size = self.total_byte_size.to_inexact();
437 }
438 Some(size) => {
439 self.total_byte_size = self.num_rows.multiply(&Precision::Exact(size));
440 }
441 }
442 }
443
444 /// Returns an unbounded `ColumnStatistics` for each field in the schema.
445 pub fn unknown_column(schema: &Schema) -> Vec<ColumnStatistics> {

Callers 1

project_statisticsMethod · 0.80

Calls 5

to_inexactMethod · 0.80
multiplyMethod · 0.80
fieldsMethod · 0.45
data_typeMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected