Skip to content

Commit c74c813

Browse files
committed
fix: allow AsyncArrowWriter to be not Send
1 parent 950f4d0 commit c74c813

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

parquet/src/arrow/async_writer/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,53 +70,53 @@ use crate::{
7070
use arrow_array::RecordBatch;
7171
use arrow_schema::SchemaRef;
7272
use bytes::Bytes;
73-
use futures::future::BoxFuture;
73+
use futures::future::LocalBoxFuture;
7474
use futures::FutureExt;
7575
use std::mem;
7676
use tokio::io::{AsyncWrite, AsyncWriteExt};
7777

7878
/// The asynchronous interface used by [`AsyncArrowWriter`] to write parquet files.
79-
pub trait AsyncFileWriter: Send {
79+
pub trait AsyncFileWriter {
8080
/// Write the provided bytes to the underlying writer
8181
///
8282
/// The underlying writer CAN decide to buffer the data or write it immediately.
8383
/// This design allows the writer implementer to control the buffering and I/O scheduling.
8484
///
8585
/// The underlying writer MAY implement retry logic to prevent breaking users write process.
86-
fn write(&mut self, bs: Bytes) -> BoxFuture<'_, Result<()>>;
86+
fn write(&mut self, bs: Bytes) -> LocalBoxFuture<'_, Result<()>>;
8787

8888
/// Flush any buffered data to the underlying writer and finish writing process.
8989
///
9090
/// After `complete` returns `Ok(())`, caller SHOULD not call write again.
91-
fn complete(&mut self) -> BoxFuture<'_, Result<()>>;
91+
fn complete(&mut self) -> LocalBoxFuture<'_, Result<()>>;
9292
}
9393

9494
impl AsyncFileWriter for Box<dyn AsyncFileWriter + '_> {
95-
fn write(&mut self, bs: Bytes) -> BoxFuture<'_, Result<()>> {
95+
fn write(&mut self, bs: Bytes) -> LocalBoxFuture<'_, Result<()>> {
9696
self.as_mut().write(bs)
9797
}
9898

99-
fn complete(&mut self) -> BoxFuture<'_, Result<()>> {
99+
fn complete(&mut self) -> LocalBoxFuture<'_, Result<()>> {
100100
self.as_mut().complete()
101101
}
102102
}
103103

104-
impl<T: AsyncWrite + Unpin + Send> AsyncFileWriter for T {
105-
fn write(&mut self, bs: Bytes) -> BoxFuture<'_, Result<()>> {
104+
impl<T: AsyncWrite + Unpin> AsyncFileWriter for T {
105+
fn write(&mut self, bs: Bytes) -> LocalBoxFuture<'_, Result<()>> {
106106
async move {
107107
self.write_all(&bs).await?;
108108
Ok(())
109109
}
110-
.boxed()
110+
.boxed_local()
111111
}
112112

113-
fn complete(&mut self) -> BoxFuture<'_, Result<()>> {
113+
fn complete(&mut self) -> LocalBoxFuture<'_, Result<()>> {
114114
async move {
115115
self.flush().await?;
116116
self.shutdown().await?;
117117
Ok(())
118118
}
119-
.boxed()
119+
.boxed_local()
120120
}
121121
}
122122

parquet/src/arrow/async_writer/store.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// under the License.
1717

1818
use bytes::Bytes;
19-
use futures::future::BoxFuture;
19+
use futures::future::LocalBoxFuture;
2020
use std::sync::Arc;
2121

2222
use crate::arrow::async_writer::AsyncFileWriter;
@@ -93,7 +93,7 @@ impl ParquetObjectWriter {
9393
}
9494

9595
impl AsyncFileWriter for ParquetObjectWriter {
96-
fn write(&mut self, bs: Bytes) -> BoxFuture<'_, Result<()>> {
96+
fn write(&mut self, bs: Bytes) -> LocalBoxFuture<'_, Result<()>> {
9797
Box::pin(async {
9898
self.w
9999
.put(bs)
@@ -102,7 +102,7 @@ impl AsyncFileWriter for ParquetObjectWriter {
102102
})
103103
}
104104

105-
fn complete(&mut self) -> BoxFuture<'_, Result<()>> {
105+
fn complete(&mut self) -> LocalBoxFuture<'_, Result<()>> {
106106
Box::pin(async {
107107
self.w
108108
.shutdown()

0 commit comments

Comments
 (0)