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 {
163
163
RuntimeConfig :: new ( ) . with_object_store_registry ( Arc :: new ( object_store_registry) )
164
164
}
165
165
166
- fn get_object_store ( & self ) -> Arc < dyn super :: ObjectStorage > {
166
+ fn construct_client ( & self ) -> Arc < dyn super :: ObjectStorage > {
167
167
let azure = self . get_default_builder ( ) . build ( ) . unwrap ( ) ;
168
168
// limit objectstore to a concurrent request limit
169
169
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 {
67
67
RuntimeConfig :: new ( )
68
68
}
69
69
70
- fn get_object_store ( & self ) -> Arc < dyn ObjectStorage > {
70
+ fn construct_client ( & self ) -> Arc < dyn ObjectStorage > {
71
71
Arc :: new ( LocalFS :: new ( self . root . clone ( ) ) )
72
72
}
73
73
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ use bytes::Bytes;
46
46
use chrono:: Local ;
47
47
use datafusion:: { datasource:: listing:: ListingTableUrl , execution:: runtime_env:: RuntimeConfig } ;
48
48
use itertools:: Itertools ;
49
+ use once_cell:: sync:: OnceCell ;
49
50
use relative_path:: RelativePath ;
50
51
use relative_path:: RelativePathBuf ;
51
52
@@ -60,7 +61,12 @@ use std::{
60
61
61
62
pub trait ObjectStorageProvider : StorageMetrics + std:: fmt:: Debug + Send + Sync {
62
63
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
+ }
64
70
fn get_endpoint ( & self ) -> String ;
65
71
fn register_store_metrics ( & self , handler : & PrometheusMetrics ) ;
66
72
}
Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ impl ObjectStorageProvider for S3Config {
298
298
RuntimeConfig :: new ( ) . with_object_store_registry ( Arc :: new ( object_store_registry) )
299
299
}
300
300
301
- fn get_object_store ( & self ) -> Arc < dyn ObjectStorage > {
301
+ fn construct_client ( & self ) -> Arc < dyn ObjectStorage > {
302
302
let s3 = self . get_default_builder ( ) . build ( ) . unwrap ( ) ;
303
303
304
304
// limit objectstore to a concurrent request limit
You can’t perform that action at this time.
0 commit comments