/// Encode [Apache Parquet] metadata as freestanding [Apache Thrift]-encoded, and [Zstandard]-compressed bytes.
///
/// This can be used to store metadata separate from the related payload data. The usage of [Apache Thrift] allows the
/// same stability guarantees as the usage of an ordinary [Apache Parquet] file. To encode a thrift message into bytes
/// the [Thrift Compact Protocol] is used.
///
/// [Apache Parquet]: https://parquet.apache.org/
/// [Apache Thrift]: https://thrift.apache.org/
/// [Thrift Compact Protocol]: https://github.com/apache/thrift/blob/master/doc/specs/thrift-compact-protocol.md
/// [Zstandard]: http://facebook.github.io/zstd/
Encode [Apache Parquet] metadata as freestanding [Apache Thrift]-encoded, and [Zstandard]-compressed bytes.
This can be used to store metadata separate from the related payload data. The usage of [Apache Thrift] allows the
same stability guarantees as the usage of an ordinary [Apache Parquet] file. To encode a thrift message into bytes
the [Thrift Compact Protocol] is used.


Encode [ Apache Parquet ] metadata as freestanding [ Apache Thrift ] - encoded and [ Zstandard ] - compressed bytes . This can be used to store metadata separate from the related payload data . The usage of [ Apache Thrift ] allows the same stability guarantees as the usage of an ordinary [ Apache Parquet ] file . To encode a thrift message into bytes the [ Thrift Compact Protocol ] is used .
fn parquet_md_to_thrift(parquet_md: ParquetMetaData) -> Result<Vec<u8>> {
        // step 1: assemble a thrift-compatible struct
        use parquet::schema::types::to_thrift as schema_to_thrift;
        let file_metadata = parquet_md.file_metadata();
        let thrift_schema =
            schema_to_thrift(file_metadata.schema()).context(ParquetSchemaToThriftSnafu {})?;
        let thrift_row_groups: Vec<_> = parquet_md
            .row_groups()
            .iter()
            .map(|rg| rg.to_thrift())
            .collect();
        let thrift_file_metadata = parquet_format::FileMetaData {
            version: file_metadata.version(),
            schema: thrift_schema,
            // TODO: column order thrift wrapper (https://github.com/influxdata/influxdb_iox/issues/1408)
            // NOTE: currently the column order is `None` for all written files, see https://github.com/apache/arrow-rs/blob/4dfbca6e5791be400d2fd3ae863655445327650e/parquet/src/file/writer.rs#L193
            column_orders: None,
            num_rows: file_metadata.num_rows(),
            row_groups: thrift_row_groups,
            key_value_metadata: file_metadata.key_value_metadata().cloned(),
            created_by: file_metadata.created_by().map(|s| s.to_string()),
            encryption_algorithm: None,
            footer_signing_key_metadata: None,
        };
        // step 2: serialize the thrift struct into bytes
        Self::try_from(thrift_file_metadata).map(|opt| opt.data)
    }
fn parquet_md_to_thrift ( parquet_md : ParquetMetaData ) -> Result < Vec < u8 > > { // step 1: assemble a thrift-compatible struct use parquet :: schema :: types :: to_thrift as schema_to_thrift ; let file_metadata = parquet_md . file_metadata ( ) ; let thrift_schema = schema_to_thrift ( file_metadata . schema ( ) ) . context ( ParquetSchemaToThriftSnafu { } ) ? ; let thrift_row_groups : Vec < _ > = parquet_md . row_groups ( ) . iter ( ) . map ( | rg | rg . to_thrift ( ) ) . collect ( ) ; let thrift_file_metadata = parquet_format :: FileMetaData { version : file_metadata . version ( ) , schema : thrift_schema , // TODO: column order thrift wrapper (https://github.com/influxdata/influxdb_iox/issues/1408) // NOTE: currently the column order is `None` for all written files, see https://github.com/apache/arrow-rs/blob/4dfbca6e5791be400d2fd3ae863655445327650e/parquet/src/file/writer.rs#L193 column_orders : None , num_rows : file_metadata . num_rows ( ) , row_groups : thrift_row_groups , key_value_metadata : file_metadata . key_value_metadata ( ) . cloned ( ) , created_by : file_metadata . created_by ( ) . map ( | s | s . to_string ( ) ) , encryption_algorithm : None , footer_signing_key_metadata : None , } ; // step 2: serialize the thrift struct into bytes Self :: try_from ( thrift_file_metadata ) . map ( | opt | opt . data ) }
Encode [Apache Parquet] metadata as freestanding [Apache Thrift]-encoded, and [Zstandard]-compressed bytes.
Encode [ Apache Parquet ] metadata as freestanding [ Apache Thrift ] - encoded and [ Zstandard ] - compressed bytes .
parquet_md
ParquetMetaData