pub fn new(
        backoff_config: BackoffConfig,
        time_provider: Arc<dyn TimeProvider>,
        metric_registry: Arc<metric::Registry>,
        ram_pool: Arc<ResourcePool<RamSize>>,
    ) -> Self {
        let metric_registry_captured = Arc::clone(&metric_registry);
        let loader = Box::new(FunctionLoader::new(
            move |_parquet_file_id, extra_fetch_info: ExtraFetchInfo| {
                let backoff_config = backoff_config.clone();
                let metric_registry = Arc::clone(&metric_registry_captured);

                async move {
                    let rb_chunk = Backoff::new(&backoff_config)
                        .retry_all_errors("get read buffer chunk from parquet file", || {
                            let decoded_parquet_file_for_load =
                                Arc::clone(&extra_fetch_info.decoded_parquet_file);
                            let table_name_for_load = Arc::clone(&extra_fetch_info.table_name);
                            let store_for_load = extra_fetch_info.store.clone();

                            async {
                                load_from_parquet_file(
                                    decoded_parquet_file_for_load,
                                    table_name_for_load,
                                    store_for_load,
                                    &metric_registry,
                                )
                                .await
                            }
                        })
                        .await
                        .expect("retry forever");

                    Arc::new(rb_chunk)
                }
            },
        ));

        let loader = Arc::new(MetricsLoader::new(
            loader,
            CACHE_ID,
            Arc::clone(&time_provider),
            &metric_registry,
        ));

        // add to memory pool
        let backend = Box::new(LruBackend::new(
            Box::new(HashMap::new()),
            Arc::clone(&ram_pool),
            CACHE_ID,
            Arc::new(FunctionEstimator::new(
                |k: &ParquetFileId, v: &Arc<RBChunk>| {
                    RamSize(mem::size_of_val(k) + mem::size_of_val(v) + v.size())
                },
            )),
        ));

        // get a direct handle so we can clear out entries as needed
        let _backend = SharedBackend::new(backend);

        let cache = Cache::new(loader, Box::new(_backend.clone()));

        Self { cache, _backend }
    }
/// Create a new empty cache.
Create a new empty cache.
Create a new empty cache .
pub fn new(
        backoff_config: BackoffConfig,
        time_provider: Arc<dyn TimeProvider>,
        metric_registry: Arc<metric::Registry>,
        ram_pool: Arc<ResourcePool<RamSize>>,
    ) -> Self {
        let metric_registry_captured = Arc::clone(&metric_registry);
        let loader = Box::new(FunctionLoader::new(
            move |_parquet_file_id, extra_fetch_info: ExtraFetchInfo| {
                let backoff_config = backoff_config.clone();
                let metric_registry = Arc::clone(&metric_registry_captured);
                async move {
                    let rb_chunk = Backoff::new(&backoff_config)
                        .retry_all_errors("get read buffer chunk from parquet file", || {
                            let decoded_parquet_file_for_load =
                                Arc::clone(&extra_fetch_info.decoded_parquet_file);
                            let table_name_for_load = Arc::clone(&extra_fetch_info.table_name);
                            let store_for_load = extra_fetch_info.store.clone();
                            async {
                                load_from_parquet_file(
                                    decoded_parquet_file_for_load,
                                    table_name_for_load,
                                    store_for_load,
                                    &metric_registry,
                                )
                                .await
                            }
                        })
                        .await
                        .expect("retry forever");
                    Arc::new(rb_chunk)
                }
            },
        ));
        let loader = Arc::new(MetricsLoader::new(
            loader,
            CACHE_ID,
            Arc::clone(&time_provider),
            &metric_registry,
        ));
        // add to memory pool
        let backend = Box::new(LruBackend::new(
            Box::new(HashMap::new()),
            Arc::clone(&ram_pool),
            CACHE_ID,
            Arc::new(FunctionEstimator::new(
                |k: &ParquetFileId, v: &Arc<RBChunk>| {
                    RamSize(mem::size_of_val(k) + mem::size_of_val(v) + v.size())
                },
            )),
        ));
        // get a direct handle so we can clear out entries as needed
        let _backend = SharedBackend::new(backend);
        let cache = Cache::new(loader, Box::new(_backend.clone()));
        Self { cache, _backend }
    }
pub fn new ( backoff_config : BackoffConfig , time_provider : Arc < dyn TimeProvider > , metric_registry : Arc < metric :: Registry > , ram_pool : Arc < ResourcePool < RamSize > > , ) -> Self { let metric_registry_captured = Arc :: clone ( & metric_registry ) ; let loader = Box :: new ( FunctionLoader :: new ( move | _parquet_file_id , extra_fetch_info : ExtraFetchInfo | { let backoff_config = backoff_config . clone ( ) ; let metric_registry = Arc :: clone ( & metric_registry_captured ) ; async move { let rb_chunk = Backoff :: new ( & backoff_config ) . retry_all_errors ( " " , | | { let decoded_parquet_file_for_load = Arc :: clone ( & extra_fetch_info . decoded_parquet_file ) ; let table_name_for_load = Arc :: clone ( & extra_fetch_info . table_name ) ; let store_for_load = extra_fetch_info . store . clone ( ) ; async { load_from_parquet_file ( decoded_parquet_file_for_load , table_name_for_load , store_for_load , & metric_registry , ) . await } } ) . await . expect ( " " ) ; Arc :: new ( rb_chunk ) } } , ) ) ; let loader = Arc :: new ( MetricsLoader :: new ( loader , CACHE_ID , Arc :: clone ( & time_provider ) , & metric_registry , ) ) ; // add to memory pool let backend = Box :: new ( LruBackend :: new ( Box :: new ( HashMap :: new ( ) ) , Arc :: clone ( & ram_pool ) , CACHE_ID , Arc :: new ( FunctionEstimator :: new ( | k : & ParquetFileId , v : & Arc < RBChunk > | { RamSize ( mem :: size_of_val ( k ) + mem :: size_of_val ( v ) + v . size ( ) ) } , ) ) , ) ) ; // get a direct handle so we can clear out entries as needed let _backend = SharedBackend :: new ( backend ) ; let cache = Cache :: new ( loader , Box :: new ( _backend . clone ( ) ) ) ; Self { cache , _backend } }
Create a new empty cache.
Create a new empty cache .
backoff_config
BackoffConfig
time_provider
Arc<dyn TimeProvider>
metric_registry
Arc<metric::Registry>
ram_pool
Arc<ResourcePool<RamSize>>
backoff_config
BackoffConfig
time_provider
Arc<dyn TimeProvider>
metric_registry
Arc<metric::Registry>
ram_pool
Arc<ResourcePool<RamSize>>