@@ -78,6 +78,10 @@ use crate::execution::spark_plan::SparkPlan;
7878
7979use crate :: execution:: tracing:: { log_memory_usage, trace_begin, trace_end, with_trace} ;
8080
81+ use crate :: execution:: spark_config:: {
82+ SparkConfig , COMET_DEBUG_ENABLED , COMET_EXPLAIN_NATIVE_ENABLED , COMET_MAX_TEMP_DIRECTORY_SIZE ,
83+ COMET_TRACING_ENABLED ,
84+ } ;
8185use crate :: parquet:: encryption_support:: { CometEncryptionFactory , ENCRYPTION_FACTORY_ID } ;
8286use datafusion_comet_proto:: spark_operator:: operator:: OpStruct ;
8387use log:: info;
@@ -168,14 +172,23 @@ pub unsafe extern "system" fn Java_org_apache_comet_Native_createPlan(
168172 memory_limit : jlong ,
169173 memory_limit_per_task : jlong ,
170174 task_attempt_id : jlong ,
171- debug_native : jboolean ,
172- explain_native : jboolean ,
173- tracing_enabled : jboolean ,
174- max_temp_directory_size : jlong ,
175175 key_unwrapper_obj : JObject ,
176176) -> jlong {
177177 try_unwrap_or_throw ( & e, |mut env| {
178- with_trace ( "createPlan" , tracing_enabled != JNI_FALSE , || {
178+ // Deserialize Spark configs
179+ let array = unsafe { JPrimitiveArray :: from_raw ( serialized_spark_configs) } ;
180+ let bytes = env. convert_byte_array ( array) ?;
181+ let spark_configs = serde:: deserialize_config ( bytes. as_slice ( ) ) ?;
182+ let spark_config: HashMap < String , String > = spark_configs. entries . into_iter ( ) . collect ( ) ;
183+
184+ // Access Comet configs
185+ let debug_native = spark_config. get_bool ( COMET_DEBUG_ENABLED ) ;
186+ let explain_native = spark_config. get_bool ( COMET_EXPLAIN_NATIVE_ENABLED ) ;
187+ let tracing_enabled = spark_config. get_bool ( COMET_TRACING_ENABLED ) ;
188+ let max_temp_directory_size =
189+ spark_config. get_u64 ( COMET_MAX_TEMP_DIRECTORY_SIZE , 100 * 1024 * 1024 * 1024 ) ;
190+
191+ with_trace ( "createPlan" , tracing_enabled, || {
179192 // Init JVM classes
180193 JVMClasses :: init ( & mut env) ;
181194
@@ -186,15 +199,6 @@ pub unsafe extern "system" fn Java_org_apache_comet_Native_createPlan(
186199 let bytes = env. convert_byte_array ( array) ?;
187200 let spark_plan = serde:: deserialize_op ( bytes. as_slice ( ) ) ?;
188201
189- // Deserialize Spark configs
190- let array = unsafe { JPrimitiveArray :: from_raw ( serialized_spark_configs) } ;
191- let bytes = env. convert_byte_array ( array) ?;
192- let spark_configs = serde:: deserialize_config ( bytes. as_slice ( ) ) ?;
193-
194- // Convert Spark configs to HashMap
195- let _spark_config_map: HashMap < String , String > =
196- spark_configs. entries . into_iter ( ) . collect ( ) ;
197-
198202 let metrics = Arc :: new ( jni_new_global_ref ! ( env, metrics_node) ?) ;
199203
200204 // Get the global references of input sources
@@ -238,7 +242,7 @@ pub unsafe extern "system" fn Java_org_apache_comet_Native_createPlan(
238242 batch_size as usize ,
239243 memory_pool,
240244 local_dirs,
241- max_temp_directory_size as u64 ,
245+ max_temp_directory_size,
242246 ) ?;
243247
244248 let plan_creation_time = start. elapsed ( ) ;
@@ -274,10 +278,10 @@ pub unsafe extern "system" fn Java_org_apache_comet_Native_createPlan(
274278 metrics_last_update_time : Instant :: now ( ) ,
275279 plan_creation_time,
276280 session_ctx : Arc :: new ( session) ,
277- debug_native : debug_native == 1 ,
278- explain_native : explain_native == 1 ,
281+ debug_native,
282+ explain_native,
279283 memory_pool_config,
280- tracing_enabled : tracing_enabled != JNI_FALSE ,
284+ tracing_enabled,
281285 } ) ;
282286
283287 Ok ( Box :: into_raw ( exec_context) as i64 )
0 commit comments