@@ -84,7 +84,6 @@ pub struct ObjectStore {
84
84
// Inner object store
85
85
pub inner : Arc < dyn OSObjectStore > ,
86
86
scheme : String ,
87
- base_path : Path ,
88
87
block_size : usize ,
89
88
}
90
89
@@ -94,9 +93,7 @@ impl DeepSizeOf for ObjectStore {
94
93
// shouldn't be too big. The only exception might be the write cache but, if
95
94
// the writer cache has data, it means we're using it somewhere else that isn't
96
95
// a cache and so that doesn't really count.
97
- self . scheme . deep_size_of_children ( context)
98
- + self . base_path . as_ref ( ) . deep_size_of_children ( context)
99
- + self . block_size . deep_size_of_children ( context)
96
+ self . scheme . deep_size_of_children ( context) + self . block_size . deep_size_of_children ( context)
100
97
}
101
98
}
102
99
@@ -356,15 +353,14 @@ impl ObjectStore {
356
353
uri : & str ,
357
354
params : & ObjectStoreParams ,
358
355
) -> Result < ( Self , Path ) > {
359
- let ( object_store, base_path ) = match Url :: parse ( uri) {
356
+ let ( object_store, path ) = match Url :: parse ( uri) {
360
357
Ok ( url) if url. scheme ( ) . len ( ) == 1 && cfg ! ( windows) => {
361
358
// On Windows, the drive is parsed as a scheme
362
359
Self :: from_path ( uri)
363
360
}
364
361
Ok ( url) => {
365
362
let store = Self :: new_from_url ( url. clone ( ) , params. clone ( ) ) . await ?;
366
- let path = Path :: from ( url. path ( ) ) ;
367
- Ok ( ( store, path) )
363
+ Ok ( ( store, Path :: from ( url. path ( ) ) ) )
368
364
}
369
365
Err ( _) => Self :: from_path ( uri) ,
370
366
} ?;
@@ -378,7 +374,7 @@ impl ObjectStore {
378
374
. unwrap_or ( object_store. inner ) ,
379
375
..object_store
380
376
} ,
381
- base_path ,
377
+ path ,
382
378
) )
383
379
}
384
380
@@ -399,7 +395,6 @@ impl ObjectStore {
399
395
Self {
400
396
inner : Arc :: new ( LocalFileSystem :: new ( ) ) . traced ( ) ,
401
397
scheme : String :: from ( scheme) ,
402
- base_path : Path :: from_absolute_path ( expanded_path. as_path ( ) ) ?,
403
398
block_size : 4 * 1024 , // 4KB block size
404
399
} ,
405
400
Path :: from_absolute_path ( expanded_path. as_path ( ) ) ?,
@@ -419,7 +414,6 @@ impl ObjectStore {
419
414
Self {
420
415
inner : Arc :: new ( LocalFileSystem :: new ( ) ) . traced ( ) ,
421
416
scheme : String :: from ( "file" ) ,
422
- base_path : Path :: from ( "/" ) ,
423
417
block_size : 4 * 1024 , // 4KB block size
424
418
}
425
419
}
@@ -429,7 +423,6 @@ impl ObjectStore {
429
423
Self {
430
424
inner : Arc :: new ( InMemory :: new ( ) ) . traced ( ) ,
431
425
scheme : String :: from ( "memory" ) ,
432
- base_path : Path :: from ( "/" ) ,
433
426
block_size : 64 * 1024 ,
434
427
}
435
428
}
@@ -447,10 +440,6 @@ impl ObjectStore {
447
440
self . block_size = new_size;
448
441
}
449
442
450
- pub fn base_path ( & self ) -> & Path {
451
- & self . base_path
452
- }
453
-
454
443
/// Open a file for path.
455
444
///
456
445
/// Parameters
@@ -747,11 +736,9 @@ async fn configure_store(url: &str, options: ObjectStoreParams) -> Result<Object
747
736
Ok ( ObjectStore {
748
737
inner : Arc :: new ( store) ,
749
738
scheme : String :: from ( url. scheme ( ) ) ,
750
- base_path : Path :: from ( url. path ( ) ) ,
751
739
block_size : 64 * 1024 ,
752
740
} )
753
741
}
754
-
755
742
"gs" => {
756
743
storage_options. with_env_gcs ( ) ;
757
744
let mut builder = GoogleCloudStorageBuilder :: new ( ) . with_url ( url. as_ref ( ) ) ;
@@ -763,23 +750,21 @@ async fn configure_store(url: &str, options: ObjectStoreParams) -> Result<Object
763
750
// object_store 0.10.0 is available.
764
751
let store = PatchedGoogleCloudStorage ( Arc :: new ( store) ) ;
765
752
let store = Arc :: new ( store) ;
753
+
766
754
Ok ( ObjectStore {
767
755
inner : store,
768
756
scheme : String :: from ( "gs" ) ,
769
- base_path : Path :: from ( url. path ( ) ) ,
770
757
block_size : 64 * 1024 ,
771
758
} )
772
759
}
773
760
"az" => {
774
761
storage_options. with_env_azure ( ) ;
775
-
776
762
let ( store, _) = parse_url_opts ( & url, storage_options. as_azure_options ( ) ) ?;
777
763
let store = Arc :: new ( store) ;
778
764
779
765
Ok ( ObjectStore {
780
766
inner : store,
781
767
scheme : String :: from ( "az" ) ,
782
- base_path : Path :: from ( url. path ( ) ) ,
783
768
block_size : 64 * 1024 ,
784
769
} )
785
770
}
@@ -794,7 +779,6 @@ async fn configure_store(url: &str, options: ObjectStoreParams) -> Result<Object
794
779
"memory" => Ok ( ObjectStore {
795
780
inner : Arc :: new ( InMemory :: new ( ) ) . traced ( ) ,
796
781
scheme : String :: from ( "memory" ) ,
797
- base_path : Path :: from ( url. path ( ) ) ,
798
782
block_size : 64 * 1024 ,
799
783
} ) ,
800
784
unknow_scheme => {
@@ -824,7 +808,6 @@ impl ObjectStore {
824
808
Self {
825
809
inner : store,
826
810
scheme : scheme. into ( ) ,
827
- base_path : location. path ( ) . into ( ) ,
828
811
block_size,
829
812
}
830
813
}
@@ -969,6 +952,26 @@ mod tests {
969
952
}
970
953
}
971
954
955
+ #[ tokio:: test]
956
+ async fn test_cloud_paths ( ) {
957
+ let uri = "s3://bucket/foo.lance" ;
958
+ let ( store, path) = ObjectStore :: from_uri ( uri) . await . unwrap ( ) ;
959
+ assert_eq ! ( store. scheme, "s3" ) ;
960
+ assert_eq ! ( path. to_string( ) , "foo.lance" ) ;
961
+
962
+ let ( store, path) = ObjectStore :: from_uri ( "s3+ddb://bucket/foo.lance" )
963
+ . await
964
+ . unwrap ( ) ;
965
+ assert_eq ! ( store. scheme, "s3" ) ;
966
+ assert_eq ! ( path. to_string( ) , "foo.lance" ) ;
967
+
968
+ let ( store, path) = ObjectStore :: from_uri ( "gs://bucket/foo.lance" )
969
+ . await
970
+ . unwrap ( ) ;
971
+ assert_eq ! ( store. scheme, "gs" ) ;
972
+ assert_eq ! ( path. to_string( ) , "foo.lance" ) ;
973
+ }
974
+
972
975
#[ tokio:: test]
973
976
async fn test_relative_paths ( ) {
974
977
let tmp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
0 commit comments