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: native_rows_fetcher.rs
    path of file: ./repos/databend/src/query/storages/fuse/src/operations/read
    
    the code of the file until where you have to start completion: // Copyright 2021 Datafuse Labs
//
// Licensed 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.

use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::sync::Arc;

use databend_common_arrow::parquet::metadata::ColumnDescriptor;
use databend_common_base::runtime::execute_futures_in_parallel;
use databend_common_catalog::plan::block_idx_in_segment;
use databend_common_catalog::plan::split_prefix;
use databend_common_catalog::plan::split_row_id;
use databend_common_catalog::plan::PartInfoPtr;
use databend_common_catalog::plan::Projection;
use databend_common_catalog::table::Table;
use databend_common_exception::Result;
use databend_common_expression::DataBlock;
use databend_common_expression::DataSchema;
use databend_common_expression::TableSchemaRef;
use databend_common_storage::ColumnNodes;
use databend_storages_common_cache::LoadParams;
use databend_storages_common_table_meta::meta::TableSnapshot;
use itertools::Itertools;

use super::fuse_rows_fetcher::RowsFetcher;
use crate::io::BlockReader;
use crate::io::CompactSegmentInfoReader;
use crate::io::MetaReaders;
use crate::io::NativeSourceData;
use crate::FuseTable;

pub(super) struct NativeRowsFetcher<const BLOCKING_IO: bool> {
    table: Arc<FuseTable>,
    snapshot: Option<Arc<TableSnapshot>>,
    segment_reader: CompactSegmentInfoReader,
    projection: Projection,
    schema: TableSchemaRef,
    reader: Arc<BlockReader>,
    column_leaves: Arc<Vec<Vec<ColumnDescriptor>>>,

    // The value contains part info and the page size of the corresponding block file.
    part_map: HashMap<u64, (PartInfoPtr, u64)>,

    // To control the parallelism of fetching blocks.
    max_threads: usize,
}

#[async_trait::async_trait]
impl<const BLOCKING_IO: bool> RowsFetcher for NativeRowsFetcher<BLOCKING_IO> {
    #[async_backtrace::framed]
    async fn on_start(&mut self) -> Result<()> {
        self.snapshot = self.table.read_table_snapshot().await?;
        Ok(())
    }

    #[async_backtrace::framed]
    async fn fetch(&mut self, row_ids: &[u64]) -> Result<DataBlock> {
        self.prepare_part_map(row_ids).await?;

        let num_rows: usize = ro
    
    async fn fetch(&mut self, row_ids: &[u64]) -> Result<DataBlock> {
        self.prepare_part_map(row_ids).await?;

        let num_rows: usize = row_ids.len();
        let mut part_set: HashMap<_, HashSet<_>> = HashMap::new();
        let mut row_set = Vec::with_capacity(num_rows);
        for row_id in row_ids {
            let (prefix, idx) = split_row_id(*row_id);
            let page_size = self.part_map[&prefix].1;
            let page_idx = idx / page_size;
            let idx_within_page = idx % page_size;
            part_set
                .entry(prefix)
                .and_modify(|s| {
                    s.insert(page_idx);
                })
                .or_insert(HashSet::from([page_idx]));
            row_set.push((prefix, page_idx, idx_within_page));
        }

        // Read blocks in `prefix` order.
        let part_set = part_set
            .into_iter()
            .sorted_by_key(|(k, _)| *k)
            .map(|(k, v)| {
                let mut v = v.into_iter().collect::<Vec<_>>();
                v.sort();
                (k, v)
            })
            .collect::<Vec<_>>();
        let mut idx_map = HashMap::with_capacity(part_set.len());
        for (p, pages) in part_set.iter() {
            for page in pages {
                idx_map.insert((*p, *page), idx_map.len());
            }
        }
        // parts_per_thread = num_parts / max_threads
        // remain = num_parts % max_threads
        // task distribution:
        //   Part number of each task   |       Task number
        // ------------------------------------------------------
        //    parts_per_thread + 1      |         remain
        //      parts_per_thread        |   max_threads - remain
        let num_parts = part_set.len();
        let mut tasks = Vec::with_capacity(self.max_threads);
        // Fetch blocks in parallel.
        for i in 0..self.max_threads {
            let begin = num_parts * i / self.max_threads;
            let end = num_parts * (i + 1) / self.max_threads;
            if begin == end {
                continue;
            }
            let parts = part_set[begin..end]
                .iter()
                .map(|(idx, pages)| (self.part_map[idx].0.clone(), pages.clone()))
                .collect::<Vec<_>>();
            tasks.push(Self::fetch_blocks(
                self.reader.clone(),
                parts,
                self.column_leaves.clone(),
            ))
        }

        let num_task = tasks.len();
        let blocks = execute_futures_in_parallel(
            tasks,
            num_task,
            num_task * 2,
            "native rows fetch".to_string(),
        )
        .await?
        .into_iter()
        .collect::<Result<Vec<_>>>()?
        .into_iter()
        .flatten()
        .collect::<Vec<_>>();
        let indices = row_set
            .iter()
            .map(|(prefix, page_idx, idx)| {
                let block_idx = idx_map[&(*prefix, *page_idx)];
                (block_idx as u32, *idx as u32, 1_usize)
            })
            .collect::<Vec<_>>();

        Ok(DataBlock::take_blocks(&blocks, &indices, num_rows))
    }