julianhyde commented on a change in pull request #1059: [CALCITE-2859] 
Centralize Calcite system properties
URL: https://github.com/apache/calcite/pull/1059#discussion_r261350210
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java
 ##########
 @@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+package org.apache.calcite.config;
+
+import com.google.common.collect.ImmutableSet;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.AccessControlException;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Stream;
+
+/**
+ * A Calcite specific system property that is used to configure various 
aspects of the framework.
+ *
+ * <p>Calcite system properties must always be in the "calcite" root 
namespace.</p>
+ *
+ * @param <T> the type of the property value
+ */
+public final class CalciteSystemProperty<T> {
+  /**
+   * Holds all system properties related with the Calcite.
+   *
+   * <p>Deprecated <code>"saffron.properties"</code> (in namespaces"saffron" 
and "net.sf.saffron")
+   * are also kept here but under "calcite" namespace.</p>
+   */
+  private static final Properties PROPERTIES = loadProperties();
+  /**
+   * Whether to run Calcite in debug mode.
+   *
+   * <p>When debug mode is activated significantly more information is 
gathered and printed to
+   * STDOUT. It is most commonly used to print and identify problems in 
generated java code. Debug
+   * mode is also used to perform more verifications at runtime, which are not 
performed during
+   * normal execution.</p>
+   */
+  public static final CalciteSystemProperty<Boolean> DEBUG =
+      booleanProperty("calcite.debug", false);
+  /**
+   * Whether to exploit join commutative property.
+   */
+  // TODO review zabetak:
+  // Does the property control join commutativity or rather join 
associativity? The property is
+  // associated with {@link org.apache.calcite.rel.rules.JoinAssociateRule} 
and not with
+  // {@link org.apache.calcite.rel.rules.JoinCommuteRule}.
+  public static final CalciteSystemProperty<Boolean> COMMUTE =
+      booleanProperty("calcite.enable.join.commute", false);
+  /**
+   *  Whether to follow the SQL standard strictly.
+   */
+  public static final CalciteSystemProperty<Boolean> STRICT =
+      booleanProperty("calcite.strict.sql", false);
+  /**
+   * Whether to include a GraphViz representation when dumping the state of 
the Volcano planner.
+   */
+  public static final CalciteSystemProperty<Boolean> DUMP_GRAPHVIZ =
+      booleanProperty("calcite.volcano.dump.graphviz", true);
+  /**
+   * Whether to include <code>RelSet</code> information when dumping the state 
of the Volcano
+   * planner.
+   */
+  public static final CalciteSystemProperty<Boolean> DUMP_SETS =
+      booleanProperty("calcite.volcano.dump.sets", true);
+  /**
+   * Whether to run integration tests.
+   */
+  // TODO review zabetak:
+  // The property is used in only one place and it is associated with mongodb. 
Should we drop this
+  // property and just use TEST_MONGODB?
+  public static final CalciteSystemProperty<Boolean> INTEGRATION_TEST =
+      booleanProperty("calcite.integrationTest", false);
+
+  /**
+   * Which database to use for tests that require a JDBC data source.
+   *
+   * The property can take one of the following values:
+   * <ul>
+   *   <li>HSQLDB(default)</li>
+   *   <li>H2</li>
+   *   <li>MYSQL</li>
+   *   <li>ORACLE</li>
+   *   <li>POSTGRESQL</li>
+   * </ul>
+   * If the specified value is not included in the previous list the default 
is used.
+   *
+   * <p>We recommend that casual users use hsqldb, and frequent Calcite 
developers use MySQL.
+   * The test suite runs faster against the MySQL database (mainly because of 
the 0.1s versus 6s
+   * startup time). You have to populate MySQL manually with the foodmart data 
set, otherwise there
+   * will be test failures.</p>
+   * */
+  public static final CalciteSystemProperty<String> TEST_DB =
+      stringProperty("calcite.test.db", "HSQLDB",
+          ImmutableSet.of(
+              "HSQLDB",
+              "H2",
+              "MYSQL",
+              "ORACLE",
+              "POSTGRESQL"));
+
+  /**
+   * Path to the dataset file that should used for integration tests.
+   *
+   * If a path is not set, then one of the following values will be used:
+   * <ul>
+   *   <li>../calcite-test-dataset</li>
+   *   <li>../../calcite-test-dataset</li>
+   *   <li>.</li>
+   * </ul>
+   * The first valid path that exists in the filesystem will be chosen.
+   */
+  public static final CalciteSystemProperty<String> TEST_DATASET_PATH =
+      new CalciteSystemProperty<>("calcite.test.dataset", v -> {
+        if (v != null) {
+          return v;
+        }
+        final String[] dirs = {
+            "../calcite-test-dataset",
+            "../../calcite-test-dataset"
+        };
+        for (String s : dirs) {
+          if (new File(s).exists() && new File(s, "vm").exists()) {
+            return s;
+          }
+        }
+        return ".";
+      });
+  /**
+   * Whether to run slow tests.
+   */
+  public static final CalciteSystemProperty<Boolean> TEST_SLOW =
+      booleanProperty("calcite.test.slow", false);
+  /**
+   * Whether to run MongoDB tests.
+   */
+  public static final CalciteSystemProperty<Boolean> TEST_MONGODB =
+      booleanProperty("calcite.test.mongodb", true);
+  /**
+   * Whether to run Splunk tests.
+   *
+   * Disabled by default, because we do not expect Splunk to be installed and 
populated data set.
+   */
+  public static final CalciteSystemProperty<Boolean> TEST_SPLUNK =
+      booleanProperty("calcite.test.splunk", false);
+  /**
+   * Whether to run Druid tests.
+   */
+  public static final CalciteSystemProperty<Boolean> TEST_DRUID =
+      booleanProperty("calcite.test.druid", true);
+  /**
+   * Whether to run Cassandra tests.
+   */
+  public static final CalciteSystemProperty<Boolean> TEST_CASSANDRA =
+      booleanProperty("calcite.test.cassandra", true);
 
 Review comment:
   Let's be clear that the purpose of this class is to get all properties in 
one place.
   
   That directly contradicts the goal to separate properties used in tests from 
properties that have other purposes. So, I declare that a non-goal.
   
   Would it help if we clarified that this class is NOT a public API? It's a 
single place that Calcite developers can go to.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to