@@ -10,10 +10,9 @@ use std::collections::HashMap;
10
10
11
11
use :: object_store:: RetryConfig ;
12
12
use object_store:: { path:: Path , prefix:: PrefixStore , ObjectStore , ObjectStoreScheme } ;
13
- use tokio:: runtime:: Handle ;
14
13
15
- use super :: storage:: runtime:: RuntimeConfig ;
16
14
use super :: storage:: LimitConfig ;
15
+ use super :: { storage:: runtime:: RuntimeConfig , IORuntime } ;
17
16
use crate :: { DeltaResult , DeltaTableError } ;
18
17
19
18
pub trait TryUpdateKey : Default {
91
90
pub struct StorageConfig {
92
91
/// Runtime configuration.
93
92
///
94
- /// Configuration to set up a dedicated IO runtime to execute IO related operations.
95
- pub runtime : Option < RuntimeConfig > ,
93
+ /// Configuration to set up a dedicated IO runtime to execute IO related operations or
94
+ /// dedicated handle.
95
+ pub runtime : Option < IORuntime > ,
96
96
97
97
pub retry : :: object_store:: RetryConfig ,
98
98
@@ -119,21 +119,12 @@ impl StorageConfig {
119
119
/// Depending on the configuration, the following layers may be added:
120
120
/// - Retry layer: Adds retry logic to the object store.
121
121
/// - Limit layer: Limits the number of concurrent requests to the object store.
122
- /// - Runtime layer: Executes IO related operations on a dedicated runtime.
123
122
pub fn decorate_store < T : ObjectStore + Clone > (
124
123
& self ,
125
124
store : T ,
126
125
table_root : & url:: Url ,
127
- handle : Option < Handle > ,
128
126
) -> DeltaResult < Box < dyn ObjectStore > > {
129
- let inner = if let Some ( runtime) = & self . runtime {
130
- Box :: new ( runtime. decorate ( store, handle) ) as Box < dyn ObjectStore >
131
- } else {
132
- Box :: new ( store) as Box < dyn ObjectStore >
133
- } ;
134
-
135
- let inner = Self :: decorate_prefix ( inner, table_root) ?;
136
-
127
+ let inner = Self :: decorate_prefix ( store, table_root) ?;
137
128
Ok ( inner)
138
129
}
139
130
@@ -169,7 +160,9 @@ where
169
160
} ;
170
161
171
162
let result = ParseResult :: < RuntimeConfig > :: from_iter ( & config. raw ) ;
172
- config. runtime = ( !result. is_default ) . then_some ( result. config ) ;
163
+ if let Some ( runtime_config) = ( !result. is_default ) . then_some ( result. config ) {
164
+ config. runtime = Some ( IORuntime :: Config ( runtime_config) ) ;
165
+ } ;
173
166
174
167
let result = ParseResult :: < LimitConfig > :: from_iter ( result. unparsed ) ;
175
168
config. limit = ( !result. is_default ) . then_some ( result. config ) ;
@@ -218,7 +211,7 @@ impl StorageConfig {
218
211
let ( runtime, remainder) : ( RuntimeConfig , _ ) = try_parse_impl ( & props. raw ) ?;
219
212
// NOTE: we only want to assign an actual runtime config we consumed an option
220
213
if props. raw . len ( ) > remainder. len ( ) {
221
- props. runtime = Some ( runtime) ;
214
+ props. runtime = Some ( IORuntime :: Config ( runtime) ) ;
222
215
}
223
216
224
217
let result = ParseResult :: < LimitConfig > :: from_iter ( remainder) ;
@@ -235,6 +228,12 @@ impl StorageConfig {
235
228
props. unknown_properties = remainder;
236
229
Ok ( props)
237
230
}
231
+
232
+ // Provide an IO Runtime directly
233
+ pub fn with_io_runtime ( mut self , rt : IORuntime ) -> Self {
234
+ self . runtime = Some ( rt) ;
235
+ self
236
+ }
238
237
}
239
238
240
239
pub ( super ) fn try_parse_impl < T , K , V , I > ( options : I ) -> DeltaResult < ( T , HashMap < String , String > ) >
0 commit comments