pub fn new_from_disk_with_reader(
        store_range: usize,
        branches: usize,
        config: &StoreConfig,
        reader: ExternalReader<R>,
    ) -> Result<Self> {
        let data_path = StoreConfig::data_path(&config.path, &config.id);

        let file = OpenOptions::new().write(true).read(true).open(data_path)?;
        let metadata = file.metadata()?;
        let store_size = metadata.len() as usize;

        // The LevelCacheStore base data layer must already be a
        // massaged next pow2 (guaranteed if created with
        // DiskStore::compact, which is the only supported method at
        // the moment).
        let size = get_merkle_tree_leafs(store_range, branches)?;
        ensure!(
            size == next_pow2(size),
            "Inconsistent merkle tree row_count detected"
        );

        // Values below in bytes.
        // Convert store_range from an element count to bytes.
        let store_range = store_range * E::byte_len();

        // LevelCacheStore on disk file is only the cached data, so
        // the file size dictates the cache_size.  Calculate cache
        // start and the updated size with repect to the file size.
        let cache_size =
            get_merkle_tree_cache_size(size, branches, config.rows_to_discard)? * E::byte_len();
        let cache_index_start = store_range - cache_size;

        // Sanity checks that the StoreConfig rows_to_discard matches this
        // particular on-disk file.  Since an external reader *is*
        // set, we check to make sure that the data on disk is *only*
        // the cached element data.
        ensure!(
            store_size == cache_size,
            "Inconsistent store size detected with external reader ({} != {})",
            store_size,
            cache_size,
        );

        Ok(LevelCacheStore {
            len: store_range / E::byte_len(),
            elem_len: E::byte_len(),
            file,
            data_width: size,
            cache_index_start,
            store_size,
            loaded_from_disk: false,
            reader: Some(reader),
            _e: Default::default(),
        })
    }
/// Used for opening v2 compacted DiskStores.
Used for opening v2 compacted DiskStores.
Used for opening v2 compacted DiskStores .
pub fn new_from_disk_with_reader(
        store_range: usize,
        branches: usize,
        config: &StoreConfig,
        reader: ExternalReader<R>,
    ) -> Result<Self> {
        let data_path = StoreConfig::data_path(&config.path, &config.id);
        let file = OpenOptions::new().write(true).read(true).open(data_path)?;
        let metadata = file.metadata()?;
        let store_size = metadata.len() as usize;
        // The LevelCacheStore base data layer must already be a
        // massaged next pow2 (guaranteed if created with
        // DiskStore::compact, which is the only supported method at
        // the moment).
        let size = get_merkle_tree_leafs(store_range, branches)?;
        ensure!(
            size == next_pow2(size),
            "Inconsistent merkle tree row_count detected"
        );
        // Values below in bytes.
        // Convert store_range from an element count to bytes.
        let store_range = store_range * E::byte_len();
        // LevelCacheStore on disk file is only the cached data, so
        // the file size dictates the cache_size.  Calculate cache
        // start and the updated size with repect to the file size.
        let cache_size =
            get_merkle_tree_cache_size(size, branches, config.rows_to_discard)? * E::byte_len();
        let cache_index_start = store_range - cache_size;
        // Sanity checks that the StoreConfig rows_to_discard matches this
        // particular on-disk file.  Since an external reader *is*
        // set, we check to make sure that the data on disk is *only*
        // the cached element data.
        ensure!(
            store_size == cache_size,
            "Inconsistent store size detected with external reader ({} != {})",
            store_size,
            cache_size,
        );
        Ok(LevelCacheStore {
            len: store_range / E::byte_len(),
            elem_len: E::byte_len(),
            file,
            data_width: size,
            cache_index_start,
            store_size,
            loaded_from_disk: false,
            reader: Some(reader),
            _e: Default::default(),
        })
    }
pub fn new_from_disk_with_reader ( store_range : usize , branches : usize , config : & StoreConfig , reader : ExternalReader < R > , ) -> Result < Self > { let data_path = StoreConfig :: data_path ( & config . path , & config . id ) ; let file = OpenOptions :: new ( ) . write ( true ) . read ( true ) . open ( data_path ) ? ; let metadata = file . metadata ( ) ? ; let store_size = metadata . len ( ) as usize ; // The LevelCacheStore base data layer must already be a // massaged next pow2 (guaranteed if created with // DiskStore::compact, which is the only supported method at // the moment). let size = get_merkle_tree_leafs ( store_range , branches ) ? ; ensure ! ( size next_pow2 ( size ) " " ) ; // Values below in bytes. // Convert store_range from an element count to bytes. let store_range = store_range * E :: byte_len ( ) ; // LevelCacheStore on disk file is only the cached data, so // the file size dictates the cache_size.  Calculate cache // start and the updated size with repect to the file size. let cache_size = get_merkle_tree_cache_size ( size , branches , config . rows_to_discard ) ? * E :: byte_len ( ) ; let cache_index_start = store_range - cache_size ; // Sanity checks that the StoreConfig rows_to_discard matches this // particular on-disk file.  Since an external reader *is* // set, we check to make sure that the data on disk is *only* // the cached element data. ensure ! ( store_size cache_size " " store_size cache_size ) ; Ok ( LevelCacheStore { len : store_range / E :: byte_len ( ) , elem_len : E :: byte_len ( ) , file , data_width : size , cache_index_start , store_size , loaded_from_disk : false , reader : Some ( reader ) , _e : Default :: default ( ) , } ) }
Used for opening v2 compacted DiskStores.
Used for opening v2 compacted DiskStores .
store_range
usize
branches
usize
config
&StoreConfig
reader
ExternalReader<R>