You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/05/25 09:06:22 UTC

[GitHub] [flink] beyond1920 commented on a change in pull request #8294: [FLINK-12348][table-planner-blink]Use TableConfig in api module to replace TableConfig in blink-planner module.

beyond1920 commented on a change in pull request #8294: [FLINK-12348][table-planner-blink]Use TableConfig in api module to replace TableConfig in blink-planner module.
URL: https://github.com/apache/flink/pull/8294#discussion_r287556574
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/api/ConfigurationUtils.java
 ##########
 @@ -0,0 +1,123 @@
+/*
+ * 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.flink.table.api;
+
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.configuration.Configuration;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.apache.flink.table.api.OptimizerConfigOptions.SQL_OPTIMIZER_AGG_PHASE_ENFORCER;
+import static org.apache.flink.table.api.TableConfigOptions.SQL_EXEC_STATE_TTL_MAX_MS;
+import static org.apache.flink.table.api.TableConfigOptions.SQL_EXEC_STATE_TTL_MS;
+
+/**
+ * Utility class for {@link Configuration} related helper functions.
+ */
+public class ConfigurationUtils {
+
+	/**
+	 * Updates configuration with a specified minimum and a maximum time interval for how long idle state, i.e., state
+	 * which was not updated, will be retained.
+	 * State will never be cleared until it was idle for less than the minimum time and will never
+	 * be kept if it was idle for more than the maximum time.
+	 * When new data arrives for previously cleaned-up state, the new data will be handled as if it
+	 * was the first data. This can result in previous results being overwritten.
+	 * Set to 0 (zero) to never clean-up the state.
+	 *
+	 * @param minTime The minimum time interval for which idle state is retained. Set to 0 (zero) to
+	 * never clean-up the state.
+	 * @param maxTime The maximum time interval for which idle state is retained. May not be smaller
+	 * than than minTime. Set to 0 (zero) to never clean-up the state.
+	 * @param configuration configuration to update.
+	 */
+	public static Configuration withIdleStateRetentionTime(Configuration configuration, Time minTime, Time maxTime) {
+		configuration.setLong(SQL_EXEC_STATE_TTL_MS, minTime.toMilliseconds());
+		configuration.setLong(SQL_EXEC_STATE_TTL_MAX_MS, maxTime.toMilliseconds());
+		return configuration;
+	}
+
+	/**
+	 * Gets the maximum time until state which was not updated will be retained.
+	 *
+	 * @param configuration the configuration object
+	 * @return the maximum time until state which was not updated will be retained.
+	 */
+	public static Long getMinIdleStateRetentionTime(Configuration configuration) {
+		return configuration.getLong(SQL_EXEC_STATE_TTL_MS);
+	}
+
+	/**
+	 * Returns the maximum time until state which was not updated will be retained.
+	 *
+	 * @param configuration the configuration object
+	 * @return the maximum time until state which was not updated will be retained.
+	 */
+	public static Long getMaxIdleStateRetentionTime(Configuration configuration) {
+		if (configuration.contains(SQL_EXEC_STATE_TTL_MS) && !configuration.contains(SQL_EXEC_STATE_TTL_MAX_MS)) {
+			configuration.setLong(SQL_EXEC_STATE_TTL_MAX_MS, getMinIdleStateRetentionTime(configuration) * 2);
+		}
+		return configuration.getLong(SQL_EXEC_STATE_TTL_MAX_MS);
+	}
+
+	/**
+	 * Returns whether a operator is disabled.
+	 *
+	 * @param configuration the configuration object
+	 * @return return true if the operator is disabled, else false.
+	 */
+	public static boolean isOperatorDisabled(Configuration configuration, DisabledOperatorType operatorType) {
+		String disabledOperators = configuration.getString(TableConfigOptions.SQL_EXEC_DISABLED_OPERATORS);
+		String[] splittedDisabledOperators = disabledOperators.split(",");
+		Set<DisabledOperatorType> disabledOperatorSet = new HashSet<>();
+		for (String splittedDisabledOperator : splittedDisabledOperators) {
+			splittedDisabledOperator = splittedDisabledOperator.trim();
+			if (splittedDisabledOperator.isEmpty()) {
+				continue;
+			}
+			if (splittedDisabledOperator.equals("HashJoin")) {
 
 Review comment:
   If config 'HashJoin', means to disable 'BroadcastHashJoin'  and 'ShuffleHashJoin'.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services