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-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to