drexler-sky commented on code in PR #1992:
URL: https://github.com/apache/datafusion-comet/pull/1992#discussion_r2191615824


##########
common/src/main/java/org/apache/comet/parquet/Native.java:
##########
@@ -292,4 +299,104 @@ public static native void currentColumnBatch(
    * @param handle
    */
   public static native void closeRecordBatchReader(long handle);
+

Review Comment:
   Yes, fixed.



##########
native/core/Cargo.toml:
##########
@@ -50,6 +50,7 @@ lazy_static = "1.4.0"
 prost = "0.13.5"
 jni = "0.21"
 snap = "1.1"
+chrono = { version = "0.4", default-features = false, features = ["clock"] }

Review Comment:
   Fixed.



##########
native/core/src/parquet/objectstore/jni.rs:
##########
@@ -0,0 +1,332 @@
+// 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.
+
+use std::collections::HashMap;
+use std::sync::Arc;
+
+use bytes::Bytes;
+use chrono::Utc;
+use futures::{stream, stream::BoxStream, StreamExt};
+use jni::{
+    objects::{JClass, JObject, JValue},
+    JNIEnv, JavaVM,
+};
+use object_store::{
+    path::Path, Attributes, Error as ObjectStoreError, GetOptions, GetRange, 
GetResult,
+    GetResultPayload, ListResult, MultipartUpload, ObjectMeta, ObjectStore, 
PutMultipartOpts,
+    PutOptions, PutPayload, PutResult,
+};
+use once_cell::sync::OnceCell;
+
+static JVM: OnceCell<JavaVM> = OnceCell::new();
+
+pub fn init_jvm(env: &JNIEnv) {
+    let _ = JVM.set(env.get_java_vm().expect("Failed to get JavaVM"));
+}
+
+fn get_jni_env<'a>() -> jni::AttachGuard<'a> {
+    JVM.get()
+        .expect("JVM not initialized")
+        .attach_current_thread()
+        .expect("Failed to attach thread")
+}
+
+mod jni_helpers {
+    use super::*;
+
+    pub fn create_jni_hashmap<'local>(
+        env: &mut JNIEnv<'local>,
+        configs: &HashMap<String, String>,
+    ) -> Result<JObject<'local>, ObjectStoreError> {
+        let map_class = 
env.find_class("java/util/HashMap").map_err(jni_error)?;
+        let jmap = env.new_object(map_class, "()V", &[]).map_err(jni_error)?;
+
+        for (k, v) in configs {
+            let jkey = env.new_string(k).map_err(jni_error)?;
+            let jval = env.new_string(v).map_err(jni_error)?;
+
+            env.call_method(
+                &jmap,
+                "put",
+                "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
+                &[JValue::Object(&jkey), JValue::Object(&jval)],
+            )
+            .map_err(jni_error)?;
+        }
+
+        Ok(jmap)
+    }
+
+    pub fn jni_error(e: jni::errors::Error) -> ObjectStoreError {
+        ObjectStoreError::Generic {
+            store: "jni",
+            source: Box::new(e),
+        }
+    }
+
+    pub fn get_native_class<'local>(
+        env: &mut JNIEnv<'local>,
+    ) -> Result<JClass<'local>, ObjectStoreError> {
+        env.find_class("org/apache/comet/parquet/Native")
+            .map_err(jni_error)
+    }
+}
+
+/// Retrieves the length (in bytes) of a file through JNI interface.
+///
+/// This method makes a JNI call to Java to get the size of the file at the 
specified path,
+/// using the provided configuration parameters for the storage backend.
+///
+/// # Arguments
+/// * `path` - The filesystem path or URI of the target file
+/// * `configs` - Configuration parameters for the storage backend as 
key-value pairs.
+///
+/// # Returns
+/// Returns `Ok(usize)` with the file size in bytes on success, or an 
`ObjectStoreError`
+/// if the operation fails.
+pub fn call_get_length(

Review Comment:
   Changed to `get_length`



-- 
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: github-unsubscr...@datafusion.apache.org

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


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

Reply via email to