@@ -47,22 +47,35 @@ impl From<GetRange> for object_store::GetRange {
47
47
/// # use std::io::stdout;
48
48
/// # use std::sync::Arc;
49
49
/// # use object_store::azure::MicrosoftAzureBuilder;
50
+ /// # use object_store::aws::AmazonS3Builder;
50
51
/// # use object_store::ObjectStore;
51
52
/// # use object_store::path::Path;
52
53
/// # use parquet::arrow::async_reader::ParquetObjectReader;
53
54
/// # use parquet::arrow::ParquetRecordBatchStreamBuilder;
54
55
/// # use parquet::schema::printer::print_parquet_metadata;
55
56
/// # async fn run() {
57
+ /// // Object Stores that support suffix ranges:
58
+ /// // Populate configuration from environment
59
+ /// let storage_container = Arc::new(AmazonS3Builder::from_env().build().unwrap());
60
+ /// let location = Path::from("path/to/blob.parquet");
61
+ ///
62
+ /// // Show Parquet metadata
63
+ /// let reader = ParquetObjectReader::new(storage_container, location);
64
+ /// let builder = ParquetRecordBatchStreamBuilder::new(reader).await.unwrap();
65
+ /// print_parquet_metadata(&mut stdout(), builder.metadata());
66
+ /// # }
67
+ /// # async fn run_non_suffixed() {
56
68
/// // Populate configuration from environment
57
69
/// let storage_container = Arc::new(MicrosoftAzureBuilder::from_env().build().unwrap());
58
70
/// let location = Path::from("path/to/blob.parquet");
59
71
/// let meta = storage_container.head(&location).await.unwrap();
60
72
/// println!("Found Blob with {}B at {}", meta.size, meta.location);
61
73
///
62
74
/// // Show Parquet metadata
63
- /// let reader = ParquetObjectReader::new(storage_container, meta);
75
+ /// let reader = ParquetObjectReader::new(storage_container, location).with_file_size( meta.size );
64
76
/// let builder = ParquetRecordBatchStreamBuilder::new(reader).await.unwrap();
65
77
/// print_parquet_metadata(&mut stdout(), builder.metadata());
78
+ ///
66
79
/// # }
67
80
/// ```
68
81
#[ derive( Clone , Debug ) ]
@@ -76,9 +89,7 @@ pub struct ParquetObjectReader {
76
89
}
77
90
78
91
impl ParquetObjectReader {
79
- /// Creates a new [`ParquetObjectReader`] for the provided [`ObjectStore`] and [`ObjectMeta`]
80
- ///
81
- /// [`ObjectMeta`] can be obtained using [`ObjectStore::list`] or [`ObjectStore::head`]
92
+ /// Creates a new [`ParquetObjectReader`] for the provided [`ObjectStore`] and [`Path`]
82
93
pub fn new ( store : Arc < dyn ObjectStore > , location : Path ) -> Self {
83
94
Self {
84
95
store,
@@ -91,6 +102,8 @@ impl ParquetObjectReader {
91
102
}
92
103
93
104
/// Provide the size of the file, for object stores that do not support suffix ranges (e.g. Azure)
105
+ ///
106
+ /// file_size can be obtained using [`ObjectStore::list`] or [`ObjectStore::head`]
94
107
pub fn with_file_size ( self , file_size : usize ) -> Self {
95
108
Self {
96
109
file_size : Some ( file_size) ,
0 commit comments