avantgardnerio commented on code in PR #472:
URL: https://github.com/apache/arrow-ballista/pull/472#discussion_r1008605476


##########
ballista/core/src/config.rs:
##########
@@ -59,68 +58,51 @@ impl ConfigEntry {
         Self {
             name,
             _description,
-            _data_type,
+            data_type: _data_type,
             default_value,
         }
     }
 }
 
-/// Ballista configuration builder
-pub struct BallistaConfigBuilder {
-    settings: HashMap<String, String>,

Review Comment:
   Oh, it looks like this was already a HashMap based thing. I guess this PR is 
refactoring that pattern?



##########
ballista/core/src/config/query.rs:
##########
@@ -0,0 +1,204 @@
+// 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.
+//
+
+//! Ballista query configuration
+
+use crate::config::{ConfigEntry, ValidConfiguration, 
ValidConfigurationBuilder};
+use crate::error::Result;
+use datafusion::arrow::datatypes::DataType;
+use std::collections::HashMap;
+
+pub const BALLISTA_JOB_NAME: &str = "ballista.job.name";
+pub const BALLISTA_DEFAULT_SHUFFLE_PARTITIONS: &str = 
"ballista.shuffle.partitions";
+pub const BALLISTA_DEFAULT_BATCH_SIZE: &str = "ballista.batch.size";
+pub const BALLISTA_REPARTITION_JOINS: &str = "ballista.repartition.joins";
+pub const BALLISTA_REPARTITION_AGGREGATIONS: &str = 
"ballista.repartition.aggregations";
+pub const BALLISTA_REPARTITION_WINDOWS: &str = "ballista.repartition.windows";
+pub const BALLISTA_PARQUET_PRUNING: &str = "ballista.parquet.pruning";
+pub const BALLISTA_WITH_INFORMATION_SCHEMA: &str = 
"ballista.with_information_schema";
+/// give a plugin files dir, and then the dynamic library files in this dir 
will be load when scheduler state init.
+pub const BALLISTA_PLUGIN_DIR: &str = "ballista.plugin_dir";
+
+/// Ballista configuration, mainly for the query
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct BallistaConfig {
+    /// Settings stored in map for easy serde
+    valid_config: ValidConfiguration,
+}
+
+impl BallistaConfig {
+    /// Create a configuration builder
+    pub fn builder() -> BallistaConfigBuilder {

Review Comment:
   This is more of a philosophical nit: I don't love the builder patterns that 
are propagating through the codebase. AFAICT, builders came from Java and were 
built on nullability and mutable state, due to the fact that it didn't have a 
[using 
statement](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-statement)
 or a [spread 
operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax).
   
   In Rust we have the [equivalent of 
spread](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax),
 so I think we could just do:
   
   ```
   let my_config = {
     param_a,
     param_b,
     .. ValidConfig
   };
   ```
   
   To accomplish the same thing in a much more concise manner.



##########
ballista/core/src/config.rs:
##########
@@ -154,113 +191,27 @@ impl BallistaConfig {
 
         Ok(())
     }
+}
 
-    /// All available configuration options
-    pub fn valid_entries() -> HashMap<String, ConfigEntry> {

Review Comment:
   I feel like it would make more sense to just serde this once from untyped 
things like env vars into a typed struct and use that everywhere. A quick 
googling reveals: https://github.com/softprops/envy



##########
ballista/scheduler/src/main.rs:
##########
@@ -74,7 +79,7 @@ async fn start_server(
     addr: SocketAddr,
     scheduling_policy: TaskSchedulingPolicy,
     slots_policy: SlotsPolicy,
-    event_loop_buffer_size: usize,

Review Comment:
   This looks like the actual goal of the PR?
   
   1. To aid in PR review, I think it can really help if the author comments on 
a few of their own lines of code to highlight things like this
   2. @daltonmadolin I think you're currently working on the same thing, PTAL
   3. If merging this PR makes things no worse, and fixes the 8 arguments 
clippy issue, I'm fine with it.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to