You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "odysa (via GitHub)" <gi...@apache.org> on 2024/03/07 04:15:08 UTC
[PR] [WIP] POC of runtime module [iceberg-rust]
odysa opened a new pull request, #233:
URL: https://github.com/apache/iceberg-rust/pull/233
Create a `runtime` module exposing functions like `spawn`
Example usage:
```rust
let tasks = manifest_list
.entries()
.iter()
.map(|manifest| {
let cloned_manifest = Arc::new(manifest.clone());
let file_io = self.file_io.clone();
async move { cloned_manifest.load_manifest(file_io).await }
})
.map(runtime::spawn)
.collect_vec();
let manifests: Vec<Manifest> = try_join_all(tasks).await?;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: runtime module [iceberg-rust]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #233:
URL: https://github.com/apache/iceberg-rust/pull/233#issuecomment-2197860098
> Thanks @odysa , generally it LGTM. But I think we should resolve #418 first to unblock this.
Got it. I will work on #418 first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] [WIP] POC of runtime module [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #233:
URL: https://github.com/apache/iceberg-rust/pull/233#issuecomment-2089454899
cc @odysa Is this pr ready for review?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] [WIP] POC of runtime module [iceberg-rust]
Posted by "odysa (via GitHub)" <gi...@apache.org>.
odysa commented on PR #233:
URL: https://github.com/apache/iceberg-rust/pull/233#issuecomment-2090540873
Sorry, my bad. I thought I marked this PR ready for review, but I didn't remove the [WIP]. There are some code changes needed to resolve conflicts.
Let me know if you have any comments about the idea of the runtime module. It should be good for review.
There is a struct `JoinHandle` wrapping handlers from different async runtimes. Implement the `JoinHandleExt` trait for them so they fit in this wrapper.
The `poll` from async-std returns `Poll<T>`, but that from tokio returns `Poll<Result<T, JoinError>>`. This is why we need to wrap them in our own `poll`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: runtime module [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #233:
URL: https://github.com/apache/iceberg-rust/pull/233#discussion_r1665146620
##########
crates/iceberg/Cargo.toml:
##########
@@ -82,3 +86,4 @@ iceberg_test_utils = { path = "../test_utils", features = ["tests"] }
pretty_assertions = { workspace = true }
tempfile = { workspace = true }
tera = { workspace = true }
+tokio = { workspace = true }
Review Comment:
Hi, @odysa seems this is still not removed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: runtime module [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #233:
URL: https://github.com/apache/iceberg-rust/pull/233#discussion_r1650082866
##########
Cargo.toml:
##########
@@ -16,7 +16,6 @@
# under the License.
[workspace]
-resolver = "2"
Review Comment:
Why remove this?
##########
crates/iceberg/src/spec/values.rs:
##########
@@ -684,10 +684,10 @@ impl Datum {
/// ```
pub fn time_from_hms_micro(hour: u32, min: u32, sec: u32, micro: u32) -> Result<Self> {
let t = NaiveTime::from_hms_micro_opt(hour, min, sec, micro)
- .ok_or_else(|| Error::new(
- ErrorKind::DataInvalid,
- format!("Can't create time from hour: {hour}, min: {min}, second: {sec}, microsecond: {micro}"),
- ))?;
+ .ok_or_else(|| Error::new(
Review Comment:
Why change this?
##########
crates/iceberg/src/runtime/mod.rs:
##########
@@ -0,0 +1,103 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// This module contains the async runtime abstraction for iceberg.
+
+use std::future::Future;
+use std::pin::Pin;
+use std::task::{Context, Poll};
+
+pub enum JoinHandle<T> {
+ #[cfg(feature = "tokio")]
+ Tokio(tokio::task::JoinHandle<T>),
+ #[cfg(all(feature = "async-std", not(feature = "tokio")))]
+ AsyncStd(async_std::task::JoinHandle<T>),
+}
+
+impl<T: Send + 'static> Future for JoinHandle<T> {
+ type Output = T;
+
+ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+ match self.get_mut() {
+ #[cfg(feature = "tokio")]
+ JoinHandle::Tokio(handle) => Pin::new(handle)
+ .poll(cx)
+ .map(|h| h.expect("tokio spawned task failed")),
+ #[cfg(all(feature = "async-std", not(feature = "tokio")))]
+ JoinHandle::AsyncStd(handle) => Pin::new(handle).poll(cx),
+ }
+ }
+}
+
+#[allow(dead_code)]
+pub fn spawn<F>(f: F) -> JoinHandle<F::Output>
+where
+ F: Future + Send + 'static,
+ F::Output: Send + 'static,
+{
+ #[cfg(feature = "tokio")]
+ return JoinHandle::Tokio(tokio::task::spawn(f));
+
+ #[cfg(all(feature = "async-std", not(feature = "tokio")))]
+ return JoinHandle::AsyncStd(async_std::task::spawn(f));
+}
+
+#[allow(dead_code)]
+pub fn spawn_blocking<F, T>(f: F) -> JoinHandle<T>
+where
+ F: FnOnce() -> T + Send + 'static,
+ T: Send + 'static,
+{
+ #[cfg(feature = "tokio")]
+ return JoinHandle::Tokio(tokio::task::spawn_blocking(f));
+
+ #[cfg(all(feature = "async-std", not(feature = "tokio")))]
+ return JoinHandle::AsyncStd(async_std::task::spawn_blocking(f));
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[cfg(feature = "tokio")]
+ #[tokio::test]
Review Comment:
To make things simpler, I would suggest to always have tokio as dev-dependency?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: runtime module [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #233:
URL: https://github.com/apache/iceberg-rust/pull/233#issuecomment-2184992611
> Made code change. Now tokio is always a dependency since traits like `AsyncWrite` are used. Do you have any plan for them? I made `tokio` a default feature to avoid breaking change.
I think latest main has removed dependencies on tokio? See https://github.com/apache/iceberg-rust/blob/3b8121eaa9e9628536093836dcc41119716afd9e/crates/iceberg/src/io.rs#L296
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] feat: runtime module [iceberg-rust]
Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 merged PR #233:
URL: https://github.com/apache/iceberg-rust/pull/233
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org