Skip to content

Commit 113c403

Browse files
committed
feat: add support for wasm targets
Signed-off-by: Ho Kim <[email protected]>
1 parent ba487fc commit 113c403

File tree

39 files changed

+171
-82
lines changed

39 files changed

+171
-82
lines changed

crates/catalog/glue/src/catalog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ impl GlueCatalog {
198198
}
199199
}
200200

201-
#[async_trait]
201+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
202+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
202203
impl Catalog for GlueCatalog {
203204
/// List namespaces from glue catalog.
204205
///

crates/catalog/hms/src/catalog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ impl HmsCatalog {
210210
}
211211
}
212212

213-
#[async_trait]
213+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
214+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
214215
impl Catalog for HmsCatalog {
215216
/// HMS doesn't support nested namespaces.
216217
///

crates/catalog/loader/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ pub fn supported_types() -> Vec<&'static str> {
4141
CATALOG_REGISTRY.iter().map(|(k, _)| *k).collect()
4242
}
4343

44-
#[async_trait]
44+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
45+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
4546
pub trait BoxedCatalogBuilder {
4647
async fn load(
4748
self: Box<Self>,
@@ -50,7 +51,8 @@ pub trait BoxedCatalogBuilder {
5051
) -> Result<Arc<dyn Catalog>>;
5152
}
5253

53-
#[async_trait]
54+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
55+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
5456
impl<T: CatalogBuilder + 'static> BoxedCatalogBuilder for T {
5557
async fn load(
5658
self: Box<Self>,

crates/catalog/rest/src/catalog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ impl RestCatalog {
435435

436436
/// All requests and expected responses are derived from the REST catalog API spec:
437437
/// https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml
438-
#[async_trait]
438+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
439+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
439440
impl Catalog for RestCatalog {
440441
async fn list_namespaces(
441442
&self,

crates/catalog/s3tables/src/catalog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ impl S3TablesCatalog {
191191
}
192192
}
193193

194-
#[async_trait]
194+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
195+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
195196
impl Catalog for S3TablesCatalog {
196197
/// List namespaces from s3tables catalog.
197198
///

crates/catalog/sql/src/catalog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ impl SqlCatalog {
218218
}
219219
}
220220

221-
#[async_trait]
221+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
222+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
222223
impl Catalog for SqlCatalog {
223224
async fn list_namespaces(
224225
&self,

crates/iceberg/Cargo.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ storage-oss = ["opendal/services-oss"]
4040
storage-s3 = ["opendal/services-s3", "reqsign"]
4141

4242
smol = ["dep:smol"]
43-
tokio = ["tokio/rt-multi-thread"]
43+
tokio = []
4444

4545
[dependencies]
4646
anyhow = { workspace = true }
@@ -74,8 +74,8 @@ opendal = { workspace = true }
7474
ordered-float = { workspace = true }
7575
parquet = { workspace = true, features = ["async"] }
7676
rand = { workspace = true }
77-
reqwest = { workspace = true }
7877
reqsign = { version = "0.16.3", optional = true, default-features = false }
78+
reqwest = { workspace = true }
7979
roaring = { workspace = true }
8080
rust_decimal = { workspace = true }
8181
serde = { workspace = true }
@@ -87,7 +87,6 @@ serde_with = { workspace = true }
8787
smol = { workspace = true, optional = true }
8888
strum = { workspace = true, features = ["derive"] }
8989
thrift = { workspace = true }
90-
tokio = { workspace = true, optional = false, features = ["sync"] }
9190
typed-builder = { workspace = true }
9291
url = { workspace = true }
9392
uuid = { workspace = true }
@@ -104,6 +103,15 @@ regex = { workspace = true }
104103
tempfile = { workspace = true }
105104
tera = { workspace = true }
106105

106+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
107+
tokio = { workspace = true, optional = false, features = [
108+
"rt-multi-thread",
109+
"sync",
110+
] }
111+
112+
[target.'cfg(target_arch = "wasm32")'.dependencies]
113+
tokio = { workspace = true, optional = false, features = ["rt", "sync"] }
114+
107115
[package.metadata.cargo-machete]
108116
# These dependencies are added to ensure minimal dependency version
109117
ignored = ["tap"]

crates/iceberg/src/arrow/delete_file_loader.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ use crate::{Error, ErrorKind, Result};
2828

2929
/// Delete File Loader
3030
#[allow(unused)]
31-
#[async_trait::async_trait]
31+
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
32+
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
3233
pub trait DeleteFileLoader {
3334
/// Read the delete file referred to in the task
3435
///
@@ -96,7 +97,8 @@ impl BasicDeleteFileLoader {
9697
}
9798
}
9899

99-
#[async_trait::async_trait]
100+
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
101+
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
100102
impl DeleteFileLoader for BasicDeleteFileLoader {
101103
async fn read_delete_file(
102104
&self,

crates/iceberg/src/arrow/reader.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use arrow_schema::{
3232
use arrow_string::like::starts_with;
3333
use bytes::Bytes;
3434
use fnv::FnvHashSet;
35-
use futures::future::BoxFuture;
36-
use futures::{FutureExt, StreamExt, TryFutureExt, TryStreamExt, try_join};
35+
use futures::{StreamExt, TryFutureExt, TryStreamExt, try_join};
36+
use opendal::raw::BoxedFuture;
3737
use parquet::arrow::arrow_reader::{
3838
ArrowPredicateFn, ArrowReaderOptions, RowFilter, RowSelection, RowSelector,
3939
};
@@ -1373,7 +1373,7 @@ impl<R: FileRead> ArrowFileReader<R> {
13731373
}
13741374

13751375
impl<R: FileRead> AsyncFileReader for ArrowFileReader<R> {
1376-
fn get_bytes(&mut self, range: Range<u64>) -> BoxFuture<'_, parquet::errors::Result<Bytes>> {
1376+
fn get_bytes(&mut self, range: Range<u64>) -> BoxedFuture<'_, parquet::errors::Result<Bytes>> {
13771377
Box::pin(
13781378
self.r
13791379
.read(range.start..range.end)
@@ -1386,8 +1386,8 @@ impl<R: FileRead> AsyncFileReader for ArrowFileReader<R> {
13861386
fn get_metadata(
13871387
&mut self,
13881388
_options: Option<&'_ ArrowReaderOptions>,
1389-
) -> BoxFuture<'_, parquet::errors::Result<Arc<ParquetMetaData>>> {
1390-
async move {
1389+
) -> BoxedFuture<'_, parquet::errors::Result<Arc<ParquetMetaData>>> {
1390+
Box::pin(async move {
13911391
let reader = ParquetMetaDataReader::new()
13921392
.with_prefetch_hint(self.metadata_size_hint)
13931393
.with_column_indexes(self.preload_column_index)
@@ -1397,8 +1397,7 @@ impl<R: FileRead> AsyncFileReader for ArrowFileReader<R> {
13971397
let meta = reader.load_and_finish(self, size).await?;
13981398

13991399
Ok(Arc::new(meta))
1400-
}
1401-
.boxed()
1400+
})
14021401
}
14031402
}
14041403

crates/iceberg/src/catalog/memory/catalog.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ impl MemoryCatalog {
140140
}
141141
}
142142

143-
#[async_trait]
143+
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
144+
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
144145
impl Catalog for MemoryCatalog {
145146
/// List namespaces inside the catalog.
146147
async fn list_namespaces(

0 commit comments

Comments
 (0)