pub fn compute_sort_key<'a>(
    schema: &Schema,
    batches: impl Iterator<Item = &'a RecordBatch>,
) -> SortKey {
    let primary_key = schema.primary_key();

    let cardinalities = distinct_counts(batches, &primary_key);

    let mut cardinalities: Vec<_> = cardinalities.into_iter().collect();
    // Sort by (cardinality, column_name) to have deterministic order if same cardinality
    cardinalities.sort_by_cached_key(|x| (x.1, x.0.clone()));

    let mut builder = SortKeyBuilder::with_capacity(cardinalities.len() + 1);
    for (col, _) in cardinalities {
        builder = builder.with_col(col)
    }
    builder = builder.with_col(TIME_COLUMN_NAME);
    builder.build()
}
/// Given a `Schema` and an iterator of `RecordBatch`es, compute a sort key based on:
///
/// - The columns that make up the primary key of the schema
/// - Order those columns from low cardinality to high cardinality based on the data
/// - Always have the time column last
Given a `Schema` and an iterator of `RecordBatch`es, compute a sort key based on:
The columns that make up the primary key of the schema
Order those columns from low cardinality to high cardinality based on the data
Always have the time column last
Given a ` Schema ` and an iterator of ` RecordBatch ` es compute a sort key based on : The columns that make up the primary key of the schema Order those columns from low cardinality to high cardinality based on the data Always have the time column last
pub fn compute_sort_key<'a>(
    schema: &Schema,
    batches: impl Iterator<Item = &'a RecordBatch>,
) -> SortKey {
    let primary_key = schema.primary_key();
    let cardinalities = distinct_counts(batches, &primary_key);
    let mut cardinalities: Vec<_> = cardinalities.into_iter().collect();
    // Sort by (cardinality, column_name) to have deterministic order if same cardinality
    cardinalities.sort_by_cached_key(|x| (x.1, x.0.clone()));
    let mut builder = SortKeyBuilder::with_capacity(cardinalities.len() + 1);
    for (col, _) in cardinalities {
        builder = builder.with_col(col)
    }
    builder = builder.with_col(TIME_COLUMN_NAME);
    builder.build()
}
pub fn compute_sort_key < ' a > ( schema : & Schema , batches : impl Iterator < Item = & ' a RecordBatch > , ) -> SortKey { let primary_key = schema . primary_key ( ) ; let cardinalities = distinct_counts ( batches , & primary_key ) ; let mut cardinalities : Vec < _ > = cardinalities . into_iter ( ) . collect ( ) ; // Sort by (cardinality, column_name) to have deterministic order if same cardinality cardinalities . sort_by_cached_key ( | x | ( x . 1 , x . 0 . clone ( ) ) ) ; let mut builder = SortKeyBuilder :: with_capacity ( cardinalities . len ( ) + 1 ) ; for ( col , _ ) in cardinalities { builder = builder . with_col ( col ) } builder = builder . with_col ( TIME_COLUMN_NAME ) ; builder . build ( ) }
Given a `Schema` and an iterator of `RecordBatch`es, compute a sort key based on:
 The columns that make up the primary key of the schema
 Order those columns from low cardinality to high cardinality based on the data
 Always have the time column last
Given a ` Schema ` and an iterator of ` RecordBatch ` es compute a sort key based on : The columns that make up the primary key of the schema Order those columns from low cardinality to high cardinality based on the data Always have the time column last
schema
&Schema
batches
impl Iterator<Item = &'a RecordBatch>
schema
&Schema
batches
impl Iterator<Item = &'a RecordBatch>