|
11 | 11 | //! |
12 | 12 | //! use object_store::local::LocalFileSystem; |
13 | 13 | //! |
14 | | -//! use async_tiff::metadata::{PrefetchBuffer, TiffMetadataReader}; |
| 14 | +//! use async_tiff::metadata::TiffMetadataReader; |
| 15 | +//! use async_tiff::metadata::cache::ReadaheadMetadataCache; |
15 | 16 | //! use async_tiff::reader::ObjectReader; |
16 | 17 | //! |
17 | 18 | //! // Create new Arc<dyn ObjectStore> |
|
23 | 24 | //! "tests/image_tiff/images/tiled-jpeg-rgb-u8.tif".into(), |
24 | 25 | //! ); |
25 | 26 | //! |
26 | | -//! // Use PrefetchBuffer to ensure that a given number of bytes at the start of the |
27 | | -//! // file are prefetched. |
| 27 | +//! // Use ReadaheadMetadataCache to ensure that a given number of bytes at the start of the |
| 28 | +//! // file are prefetched, and to ensure that any additional fetches are made in larger chunks. |
28 | 29 | //! // |
29 | | -//! // This or a similar caching layer should **always** be used and ensures that the |
30 | | -//! // underlying read calls that the TiffMetadataReader makes don't translate to actual |
31 | | -//! // network fetches. |
32 | | -//! let prefetch_reader = PrefetchBuffer::new(reader.clone(), 32 * 1024) |
33 | | -//! .await |
34 | | -//! .unwrap(); |
| 30 | +//! // The `ReadaheadMetadataCache` or a similar caching layer should **always** be used to ensure |
| 31 | +//! // that the underlying small read calls that the TiffMetadataReader makes don't translate to |
| 32 | +//! // individual tiny network fetches. |
| 33 | +//! let cached_reader = ReadaheadMetadataCache::new(reader.clone()); |
35 | 34 | //! |
36 | 35 | //! // Create a TiffMetadataReader wrapping some MetadataFetch |
37 | | -//! let mut metadata_reader = TiffMetadataReader::try_open(&prefetch_reader) |
| 36 | +//! let mut metadata_reader = TiffMetadataReader::try_open(&cached_reader) |
38 | 37 | //! .await |
39 | 38 | //! .unwrap(); |
40 | 39 | //! |
41 | 40 | //! // Read all IFDs out of the source. |
42 | 41 | //! let ifds = metadata_reader |
43 | | -//! .read_all_ifds(&prefetch_reader) |
| 42 | +//! .read_all_ifds(&cached_reader) |
44 | 43 | //! .await |
45 | 44 | //! .unwrap(); |
46 | 45 | //! # }) |
|
54 | 53 | //! [`MetadataFetch`] implementation. |
55 | 54 | //! |
56 | 55 | //! Thus, it is **imperative to always supply some sort of caching, prefetching, or buffering** |
57 | | -//! middleware when reading metadata. [`PrefetchBuffer`] is an example of this, which |
58 | | -//! fetches the first `N` bytes out of a file. |
59 | | -//! |
| 56 | +//! middleware when reading metadata. [`ReadaheadMetadataCache`] is an example of this, which |
| 57 | +//! fetches the first `N` bytes out of a file, and then multiplies the size of any subsequent |
| 58 | +//! fetches by a given `multiplier`. |
60 | 59 |
|
61 | 60 | pub mod cache; |
62 | 61 | mod fetch; |
|
0 commit comments