From 2f4b70ecfe955700b0510e4d8006e379cc1d0850 Mon Sep 17 00:00:00 2001 From: Cory Grinstead Date: Tue, 28 May 2024 14:05:07 -0500 Subject: [PATCH] chore: clippy warnings inside java bindings (#1330) this was causing unrelated PR's to fail. https://github.com/lancedb/lancedb/actions/runs/9274579178/job/25517248069?pr=1308 --- java/core/lancedb-jni/src/error.rs | 11 ++++++++--- java/core/lancedb-jni/src/ffi.rs | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/java/core/lancedb-jni/src/error.rs b/java/core/lancedb-jni/src/error.rs index e6738c3b..793d0d8a 100644 --- a/java/core/lancedb-jni/src/error.rs +++ b/java/core/lancedb-jni/src/error.rs @@ -19,6 +19,8 @@ use jni::errors::Error as JniError; use serde_json::Error as JsonError; use snafu::{Location, Snafu}; +type BoxedError = Box; + /// Java Exception types pub enum JavaException { IllegalArgumentException, @@ -43,8 +45,11 @@ pub enum Error { Jni { message: String, location: Location }, #[snafu(display("Invalid argument: {message}, {location}"))] InvalidArgument { message: String, location: Location }, - #[snafu(display("IO error: {message}, {location}"))] - IO { message: String, location: Location }, + #[snafu(display("IO error: {source}, {location}"))] + IO { + source: BoxedError, + location: Location, + }, #[snafu(display("Arrow error: {message}, {location}"))] Arrow { message: String, location: Location }, #[snafu(display("Index error: {message}, {location}"))] @@ -171,7 +176,7 @@ impl From for Error { lance::Error::DatasetAlreadyExists { uri, location } => { Self::DatasetAlreadyExists { uri, location } } - lance::Error::IO { message, location } => Self::IO { message, location }, + lance::Error::IO { source, location } => Self::IO { source, location }, lance::Error::Arrow { message, location } => Self::Arrow { message, location }, lance::Error::Index { message, location } => Self::Index { message, location }, lance::Error::InvalidInput { source, location } => Self::InvalidArgument { diff --git a/java/core/lancedb-jni/src/ffi.rs b/java/core/lancedb-jni/src/ffi.rs index 032b938c..387c18a5 100644 --- a/java/core/lancedb-jni/src/ffi.rs +++ b/java/core/lancedb-jni/src/ffi.rs @@ -31,12 +31,14 @@ pub trait JNIEnvExt { /// Get strings from Java String[] object. /// Note that get Option> from Java Optional just doesn't work. + #[allow(unused)] fn get_strings_array(&mut self, obj: jobjectArray) -> Result>; /// Get Option from Java Optional. fn get_string_opt(&mut self, obj: &JObject) -> Result>; /// Get Option> from Java Optional>. + #[allow(unused)] fn get_strings_opt(&mut self, obj: &JObject) -> Result>>; /// Get Option from Java Optional. @@ -46,12 +48,15 @@ pub trait JNIEnvExt { fn get_ints_opt(&mut self, obj: &JObject) -> Result>>; /// Get Option from Java Optional. + #[allow(unused)] fn get_long_opt(&mut self, obj: &JObject) -> Result>; /// Get Option from Java Optional. + #[allow(unused)] fn get_u64_opt(&mut self, obj: &JObject) -> Result>; /// Get Option<&[u8]> from Java Optional. + #[allow(unused)] fn get_bytes_opt(&mut self, obj: &JObject) -> Result>; fn get_optional(&mut self, obj: &JObject, f: F) -> Result>