Skip to content

Commit 7312ade

Browse files
authored
Merge pull request #571 from juripetersen/log-explains-into-directory
Use conf/wayang-defaults.properties to load directory and explain con…
2 parents 7fdb266 + d5b77a9 commit 7312ade

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

conf/wayang-defaults.properties

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# Configure statistics collection.
19+
wayang.core.log.enabled = true
20+
21+
wayang.core.explain.enabled = false
22+
wayang.core.explain.directrory = ~/.wayang/

wayang-api/wayang-api-sql/src/main/java/org/apache/wayang/api/sql/context/SqlContext.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.apache.wayang.core.api.Configuration;
4040
import org.apache.wayang.core.plugin.Plugin;
4141
import org.apache.wayang.core.api.WayangContext;
42+
import org.apache.wayang.core.util.ReflectionUtils;
4243
import org.apache.wayang.core.plan.wayangplan.WayangPlan;
4344
import org.apache.wayang.java.Java;
4445
import org.apache.wayang.postgres.Postgres;
@@ -84,14 +85,14 @@ public SqlContext(final Configuration configuration, final List<Plugin> plugins)
8485
for (final Plugin plugin : plugins) {
8586
this.withPlugin(plugin);
8687
}
87-
88+
8889
calciteSchema = SchemaUtils.getSchema(configuration);
8990
}
9091

9192
/**
9293
* Entry point for executing SQL statements while providing arguments.
9394
* You need to provide at least a JDBC source.
94-
*
95+
*
9596
* @param args args[0] = SQL statement path, args[1] = JDBC driver, args[2] =
9697
* JDBC URL, args[3] = JDBC user,
9798
*              args[4] = JDBC password, args[5] = outputPath,
@@ -138,6 +139,7 @@ public static void main(final String[] args) throws Exception {
138139
jdbcDriver, jdbcUrl, jdbcUser, jdbcPassword);
139140

140141
final Configuration configuration = new Configuration();
142+
configuration.load(ReflectionUtils.loadResource("wayang-defaults.properties"));
141143

142144
configuration.setProperty("wayang.calcite.model", calciteModel);
143145
configuration.setProperty(String.format("wayang.%s.jdbc.url", driverPlatform), jdbcUrl);

wayang-commons/wayang-core/src/main/java/org/apache/wayang/core/api/Job.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,13 +306,15 @@ protected void doExecute() {
306306
}
307307

308308
if (this.configuration.getBooleanProperty("wayang.core.explain.enabled")) {
309+
long unixTime = System.currentTimeMillis() / 1000L;
310+
309311
ExplainUtils.write(
310312
ExplainUtils.parsePlan(this.wayangPlan, true),
311-
this.configuration.getStringProperty("wayang.core.explain.logical.file")
313+
this.configuration.getStringProperty("wayang.core.explain.directory") + "job-" + this.name + "-" + unixTime + "-logical.json"
312314
);
313315
ExplainUtils.write(
314316
ExplainUtils.parsePlan(executionPlan, true),
315-
this.configuration.getStringProperty("wayang.core.explain.execution.file")
317+
this.configuration.getStringProperty("wayang.core.explain.directory") + "job-" + this.name + "-" + unixTime + "-execution.json"
316318
);
317319
}
318320

wayang-commons/wayang-core/src/main/java/org/apache/wayang/core/api/WayangContext.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,15 @@ public void explain(WayangPlan wayangPlan, String... udfJars) {
149149
public void explain(WayangPlan wayangPlan, boolean toJson, String... udfJars) {
150150
Job job = this.createJob(null, null, wayangPlan, udfJars);
151151
ExecutionPlan executionPlan = job.buildInitialExecutionPlan();
152+
long unixTime = System.currentTimeMillis() / 1000L;
152153

153154
ExplainUtils.write(
154155
ExplainUtils.parsePlan(wayangPlan, true),
155-
this.configuration.getStringProperty("wayang.core.explain.logical.file")
156+
this.configuration.getStringProperty("wayang.core.explain.directory") + "job-" + job.getName() + "-" + unixTime + "-logical.json"
156157
);
157158
ExplainUtils.write(
158159
ExplainUtils.parsePlan(executionPlan, true),
159-
this.configuration.getStringProperty("wayang.core.explain.execution.file")
160+
this.configuration.getStringProperty("wayang.core.explain.directory") + "job-" + job.getName() + "-" + unixTime + "-execution.json"
160161
);
161162
}
162163

wayang-commons/wayang-core/src/main/resources/wayang-core-defaults.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ wayang.core.log.enabled = true
3030
# wayang.core.log.cardinalities = ~/.wayang/cardinalities.json
3131
# wayang.core.log.executions = ~/.wayang/executions.json
3232
wayang.core.explain.enabled = false
33+
wayang.core.explain.directrory = ~/.wayang/
3334

3435
# Configure re-optimization.
3536
wayang.core.optimizer.reoptimize = false

0 commit comments

Comments
 (0)