@@ -32,7 +32,9 @@ use crate::errors::{try_unwrap_or_throw, JniResult};
3232use crate :: runtime;
3333
3434#[ no_mangle]
35- pub extern "system" fn Java_org_apache_datafusion_SessionContext_createDataFrameFromProto < ' local > (
35+ pub extern "system" fn Java_org_apache_datafusion_SessionContext_createDataFrameFromProto <
36+ ' local ,
37+ > (
3638 mut env : JNIEnv < ' local > ,
3739 _class : JClass < ' local > ,
3840 handle : jlong ,
@@ -60,22 +62,26 @@ pub extern "system" fn Java_org_apache_datafusion_SessionContext_tableSchemaIpc<
6062 handle : jlong ,
6163 name : JString < ' local > ,
6264) -> jbyteArray {
63- try_unwrap_or_throw ( & mut env, std:: ptr:: null_mut ( ) , |env| -> JniResult < jbyteArray > {
64- if handle == 0 {
65- return Err ( "SessionContext handle is null" . into ( ) ) ;
66- }
67- let ctx = unsafe { & * ( handle as * const SessionContext ) } ;
68- let name: String = env. get_string ( & name) ?. into ( ) ;
65+ try_unwrap_or_throw (
66+ & mut env,
67+ std:: ptr:: null_mut ( ) ,
68+ |env| -> JniResult < jbyteArray > {
69+ if handle == 0 {
70+ return Err ( "SessionContext handle is null" . into ( ) ) ;
71+ }
72+ let ctx = unsafe { & * ( handle as * const SessionContext ) } ;
73+ let name: String = env. get_string ( & name) ?. into ( ) ;
6974
70- let df = runtime ( ) . block_on ( ctx. table ( name. as_str ( ) ) ) ?;
71- let schema: SchemaRef = Arc :: new ( df. schema ( ) . as_arrow ( ) . clone ( ) ) ;
75+ let df = runtime ( ) . block_on ( ctx. table ( name. as_str ( ) ) ) ?;
76+ let schema: SchemaRef = Arc :: new ( df. schema ( ) . as_arrow ( ) . clone ( ) ) ;
7277
73- let mut buf: Vec < u8 > = Vec :: new ( ) ;
74- {
75- let mut writer = StreamWriter :: try_new ( & mut buf, schema. as_ref ( ) ) ?;
76- writer. finish ( ) ?;
77- }
78- let arr = env. byte_array_from_slice ( & buf) ?;
79- Ok ( arr. into_raw ( ) )
80- } )
78+ let mut buf: Vec < u8 > = Vec :: new ( ) ;
79+ {
80+ let mut writer = StreamWriter :: try_new ( & mut buf, schema. as_ref ( ) ) ?;
81+ writer. finish ( ) ?;
82+ }
83+ let arr = env. byte_array_from_slice ( & buf) ?;
84+ Ok ( arr. into_raw ( ) )
85+ } ,
86+ )
8187}
0 commit comments