This is an automated email from the ASF dual-hosted git repository. xuanwo pushed a commit to branch poll-write in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit c7c4819c2fdddc7cec9fc15f76ad5b2cfa39d4f9 Author: Xuanwo <[email protected]> AuthorDate: Fri Sep 8 16:08:43 2023 +0800 Fix build for hdfs Signed-off-by: Xuanwo <[email protected]> --- core/src/services/hdfs/writer.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/core/src/services/hdfs/writer.rs b/core/src/services/hdfs/writer.rs index 1b4f549ce..ced19efb9 100644 --- a/core/src/services/hdfs/writer.rs +++ b/core/src/services/hdfs/writer.rs @@ -16,10 +16,11 @@ // under the License. use std::io::Write; -use std::task::Context; +use std::pin::Pin; +use std::task::{Context, Poll}; use async_trait::async_trait; -use futures::AsyncWriteExt; +use futures::{AsyncWrite, AsyncWriteExt}; use super::error::parse_io_error; use crate::raw::*; @@ -38,20 +39,17 @@ impl<F> HdfsWriter<F> { #[async_trait] impl oio::Write for HdfsWriter<hdrs::AsyncFile> { fn poll_write(&mut self, cx: &mut Context<'_>, bs: &dyn oio::WriteBuf) -> Poll<Result<usize>> { - self.f.write(bs.chunk()).await.map_err(parse_io_error) + Pin::new(&mut self.f) + .poll_write(cx, bs.chunk()) + .map_err(parse_io_error) } - fn poll_abort(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> { - Err(Error::new( - ErrorKind::Unsupported, - "output writer doesn't support abort", - )) + fn poll_abort(&mut self, _: &mut Context<'_>) -> Poll<Result<()>> { + Poll::Ready(Ok(())) } fn poll_close(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>> { - self.f.close().await.map_err(parse_io_error)?; - - Ok(()) + Pin::new(&mut self.f).poll_close(cx).map_err(parse_io_error) } }
