Skip to content

Commit

Permalink
rename feature name from opfs to wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
crwen committed Dec 7, 2024
1 parent f173695 commit c7f6834
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,4 @@ jobs:
- name: Run wasm-pack test on fusion-parquet
run: |
export PATH=$PATH:/tmp/chrome/chrome-linux64/:/tmp/chrome/chromedriver-linux64/
wasm-pack test --chrome --headless fusio-parquet --features opfs
wasm-pack test --chrome --headless fusio-parquet --features wasm
2 changes: 1 addition & 1 deletion examples/opfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib", "rlib"]
arrow = "53"
fusio = { path = "../../fusio", features = ["opfs"] }
fusio-dispatch = { path = "../../fusio-dispatch", features = ["opfs"] }
fusio-parquet = { path = "../../fusio-parquet", features = ["opfs"] }
fusio-parquet = { path = "../../fusio-parquet", features = ["wasm"] }
futures = { version = "0.3" }
parquet = { version = "53", default-features = false, features = [
"arrow",
Expand Down
2 changes: 1 addition & 1 deletion fusio-parquet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.2.2"

[features]
default = []
opfs = ["fusio/opfs"]
wasm = ["fusio/opfs"]
tokio = ["fusio/tokio"]

[dependencies]
Expand Down
10 changes: 5 additions & 5 deletions fusio-parquet/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use parquet::{
const PREFETCH_FOOTER_SIZE: usize = 512 * 1024;

pub struct AsyncReader {
#[cfg(feature = "opfs")]
#[cfg(feature = "wasm")]
inner: Arc<futures::lock::Mutex<Box<dyn DynFile>>>,
#[cfg(not(feature = "opfs"))]
#[cfg(not(feature = "wasm"))]
inner: Box<dyn DynFile>,
content_length: u64,
// The prefetch size for fetching file footer.
Expand All @@ -34,7 +34,7 @@ fn set_prefetch_footer_size(footer_size: usize, content_size: u64) -> usize {

impl AsyncReader {
pub async fn new(reader: Box<dyn DynFile>, content_length: u64) -> Result<Self, fusio::Error> {
#[cfg(feature = "opfs")]
#[cfg(feature = "wasm")]
#[allow(clippy::arc_with_non_send_sync)]
let reader = Arc::new(futures::lock::Mutex::new(reader));
Ok(Self {
Expand All @@ -57,7 +57,7 @@ impl AsyncFileReader for AsyncReader {
buf.resize(len, 0);

cfg_if::cfg_if! {
if #[cfg(all(feature = "opfs", target_arch = "wasm32"))] {
if #[cfg(all(feature = "wasm", target_arch = "wasm32"))] {
let (sender, receiver) = futures::channel::oneshot::channel::<Result<Bytes, ParquetError>>();

let reader = self.inner.clone();
Expand Down Expand Up @@ -97,7 +97,7 @@ impl AsyncFileReader for AsyncReader {
let content_length = self.content_length;

cfg_if::cfg_if! {
if #[cfg(all(feature = "opfs", target_arch = "wasm32"))] {
if #[cfg(all(feature = "wasm", target_arch = "wasm32"))] {
let mut buf = BytesMut::with_capacity(footer_size);
buf.resize(footer_size, 0);
let (sender, receiver) = futures::channel::oneshot::channel::<Result<Arc<ParquetMetaData>, ParquetError>>();
Expand Down
10 changes: 5 additions & 5 deletions fusio-parquet/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use futures::future::BoxFuture;
use parquet::{arrow::async_writer::AsyncFileWriter, errors::ParquetError};

pub struct AsyncWriter {
#[cfg(feature = "opfs")]
#[cfg(feature = "wasm")]
#[allow(clippy::arc_with_non_send_sync)]
inner: Option<std::sync::Arc<futures::lock::Mutex<Box<dyn DynFile>>>>,
#[cfg(not(feature = "opfs"))]
#[cfg(not(feature = "wasm"))]
inner: Option<Box<dyn DynFile>>,
}

unsafe impl Send for AsyncWriter {}
impl AsyncWriter {
pub fn new(writer: Box<dyn DynFile>) -> Self {
#[cfg(feature = "opfs")]
#[cfg(feature = "wasm")]
#[allow(clippy::arc_with_non_send_sync)]
let writer = std::sync::Arc::new(futures::lock::Mutex::new(writer));
{
Expand All @@ -29,7 +29,7 @@ impl AsyncWriter {
impl AsyncFileWriter for AsyncWriter {
fn write(&mut self, bs: Bytes) -> BoxFuture<'_, parquet::errors::Result<()>> {
cfg_if::cfg_if! {
if #[cfg(all(feature = "opfs", target_arch = "wasm32"))] {
if #[cfg(all(feature = "wasm", target_arch = "wasm32"))] {
match self.inner.as_mut() {
Some(writer) => {
let (sender, receiver) = futures::channel::oneshot::channel::<Result<(), ParquetError>>();
Expand Down Expand Up @@ -70,7 +70,7 @@ impl AsyncFileWriter for AsyncWriter {

fn complete(&mut self) -> BoxFuture<'_, parquet::errors::Result<()>> {
cfg_if::cfg_if! {
if #[cfg(all(feature = "opfs", target_arch = "wasm32"))] {
if #[cfg(all(feature = "wasm", target_arch = "wasm32"))] {
match self.inner.take() {
Some(writer) => {
let (sender, receiver) = futures::channel::oneshot::channel::<Result<(), ParquetError>>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(test)]
#[cfg(all(feature = "opfs", target_arch = "wasm32"))]
#[cfg(all(feature = "wasm", target_arch = "wasm32"))]
pub(crate) mod tests {

wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
Expand Down

0 comments on commit c7f6834

Please sign in to comment.