-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: specify features in vortex-serde & test default features (#1168)
- Loading branch information
Showing
7 changed files
with
64 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::sync::Arc; | ||
|
||
use object_store::aws::AmazonS3Builder; | ||
use object_store::azure::MicrosoftAzureBuilder; | ||
use object_store::gcp::GoogleCloudStorageBuilder; | ||
use object_store::http::HttpBuilder; | ||
use object_store::local::LocalFileSystem; | ||
use object_store::path::Path; | ||
use object_store::{ObjectStore, ObjectStoreScheme}; | ||
use url::Url; | ||
use vortex_error::{vortex_bail, VortexResult}; | ||
use vortex_serde::io::ObjectStoreReadAt; | ||
|
||
fn better_parse_url(url_str: &str) -> VortexResult<(Box<dyn ObjectStore>, Path)> { | ||
let url = Url::parse(url_str)?; | ||
|
||
let (scheme, path) = ObjectStoreScheme::parse(&url).map_err(object_store::Error::from)?; | ||
let store: Box<dyn ObjectStore> = match scheme { | ||
ObjectStoreScheme::Local => Box::new(LocalFileSystem::default()), | ||
ObjectStoreScheme::AmazonS3 => { | ||
Box::new(AmazonS3Builder::from_env().with_url(url_str).build()?) | ||
} | ||
ObjectStoreScheme::GoogleCloudStorage => Box::new( | ||
GoogleCloudStorageBuilder::from_env() | ||
.with_url(url_str) | ||
.build()?, | ||
), | ||
ObjectStoreScheme::MicrosoftAzure => Box::new( | ||
MicrosoftAzureBuilder::from_env() | ||
.with_url(url_str) | ||
.build()?, | ||
), | ||
ObjectStoreScheme::Http => Box::new( | ||
HttpBuilder::new() | ||
.with_url(&url[..url::Position::BeforePath]) | ||
.build()?, | ||
), | ||
otherwise => vortex_bail!("unrecognized object store scheme: {:?}", otherwise), | ||
}; | ||
|
||
Ok((store, path)) | ||
} | ||
|
||
pub async fn vortex_read_at_from_url(url: &str) -> VortexResult<ObjectStoreReadAt> { | ||
let (object_store, location) = better_parse_url(url)?; | ||
Ok(ObjectStoreReadAt::new(Arc::from(object_store), location)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters