File tree Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,7 @@ impl ObjectStorageProvider for AzureBlobConfig {
163163 RuntimeConfig :: new ( ) . with_object_store_registry ( Arc :: new ( object_store_registry) )
164164 }
165165
166- fn get_object_store ( & self ) -> Arc < dyn super :: ObjectStorage > {
166+ fn construct_client ( & self ) -> Arc < dyn super :: ObjectStorage > {
167167 let azure = self . get_default_builder ( ) . build ( ) . unwrap ( ) ;
168168 // limit objectstore to a concurrent request limit
169169 let azure = LimitStore :: new ( azure, super :: MAX_OBJECT_STORE_REQUESTS ) ;
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ impl ObjectStorageProvider for FSConfig {
6767 RuntimeConfig :: new ( )
6868 }
6969
70- fn get_object_store ( & self ) -> Arc < dyn ObjectStorage > {
70+ fn construct_client ( & self ) -> Arc < dyn ObjectStorage > {
7171 Arc :: new ( LocalFS :: new ( self . root . clone ( ) ) )
7272 }
7373
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ use bytes::Bytes;
4646use chrono:: Local ;
4747use datafusion:: { datasource:: listing:: ListingTableUrl , execution:: runtime_env:: RuntimeConfig } ;
4848use itertools:: Itertools ;
49+ use once_cell:: sync:: OnceCell ;
4950use relative_path:: RelativePath ;
5051use relative_path:: RelativePathBuf ;
5152
@@ -60,7 +61,12 @@ use std::{
6061
6162pub trait ObjectStorageProvider : StorageMetrics + std:: fmt:: Debug + Send + Sync {
6263 fn get_datafusion_runtime ( & self ) -> RuntimeConfig ;
63- fn get_object_store ( & self ) -> Arc < dyn ObjectStorage > ;
64+ fn construct_client ( & self ) -> Arc < dyn ObjectStorage > ;
65+ fn get_object_store ( & self ) -> Arc < dyn ObjectStorage > {
66+ static STORE : OnceCell < Arc < dyn ObjectStorage > > = OnceCell :: new ( ) ;
67+
68+ STORE . get_or_init ( || self . construct_client ( ) ) . clone ( )
69+ }
6470 fn get_endpoint ( & self ) -> String ;
6571 fn register_store_metrics ( & self , handler : & PrometheusMetrics ) ;
6672}
Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ impl ObjectStorageProvider for S3Config {
298298 RuntimeConfig :: new ( ) . with_object_store_registry ( Arc :: new ( object_store_registry) )
299299 }
300300
301- fn get_object_store ( & self ) -> Arc < dyn ObjectStorage > {
301+ fn construct_client ( & self ) -> Arc < dyn ObjectStorage > {
302302 let s3 = self . get_default_builder ( ) . build ( ) . unwrap ( ) ;
303303
304304 // limit objectstore to a concurrent request limit
You can’t perform that action at this time.
0 commit comments