You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: writer.rs
    path of file: ./repos/incubator-horaedb/src/analytic_engine/src/sst/parquet
    
    the code of the file until where you have to start completion: // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

//! Sst writer implementation based on parquet.

use std::collections::{HashMap, HashSet};

use async_trait::async_trait;
use common_types::{
    datum::DatumKind, record_batch::FetchedRecordBatch, request_id::RequestId, schema::Schema,
    time::TimeRange,
};
use datafusion::parquet::basic::Compression;
use futures::StreamExt;
use generic_error::BoxError;
use logger::{debug, error};
use object_store::{ObjectStoreRef, Path};
use parquet::data_type::AsBytes;
use snafu::{OptionExt, ResultExt};
use tokio::io::{AsyncWrite, AsyncWriteExt};

use crate::{
    sst::{
        factory::ObjectStorePickerRef,
        file::Level,
        parquet::{
            encoding::{encode_sst_meta_data, ColumnEncoding, EncodeOptions, ParquetEncoder},
            meta_data::{
                filter::{ParquetFilter, RowGroupFilter, RowGroupFilterBuilder},
                ColumnValueSet, ParquetMetaData,
            },
        },
        writer::{
            self, BuildParquetFilter, EncodePbData, EncodeRecordBatch, ExpectTimestampColumn, Io,
            MetaData, Pol
    
    fn sample(&mut self) -> Result<()> {
        let num_total_rows: usize = self.sample_row_groups.iter().map(|v| v.num_rows()).sum();
        let ignore_sampling = num_total_rows < self.min_num_sample_rows;
        if ignore_sampling {
            self.decide_column_encodings_by_data_type();
            return Ok(());
        }

        assert!(self.max_unique_value_ratio <= 1.0 && self.max_unique_value_ratio >= 0.0);
        let max_unique_values = (num_total_rows as f64 * self.max_unique_value_ratio) as usize;
        let mut column_hashes = HashSet::with_capacity(max_unique_values);
        for (col_idx, col_schema) in self.meta_data.schema.columns().iter().enumerate() {
            if !Self::is_dictionary_type(col_schema.data_type) {
                self.column_encodings.insert(
                    col_schema.name.clone(),
                    ColumnEncoding { enable_dict: false },
                );
                continue;
            }

            if self.column_encodings.contains_key(&col_schema.name) {
                continue;
            }

            for row_group in self.sample_row_groups {
                let col_block = &row_group.columns()[col_idx];
                for idx in 0..row_group.num_rows() {
                    if column_hashes.len() >= max_unique_values {
                        break;
                    }
                    let datum_view = col_block.datum_view(idx);
                    datum_view.do_with_bytes(|val| {
                        let hash = hash_ext::hash64(val);
                        column_hashes.insert(hash);
                    })
                }
            }

            // The dictionary encoding make senses only if the number of unique values is
            // small.
            let enable_dict = column_hashes.len() < max_unique_values;
            column_hashes.clear();
            self.column_encodings
                .insert(col_schema.name.clone(), ColumnEncoding { enable_dict });
        }

        Ok(())
    }