embulk-filter-calcite 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/build.gradle +1 -1
- data/settings.gradle +1 -0
- data/src/main/java/org/embulk/filter/calcite/CalciteFilterPlugin.java +32 -14
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6676613c81d60cb8384827212e101894fa32b91
|
|
4
|
+
data.tar.gz: 6cca5546a143dd654b42433a70a9ec15099b8714
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4dafb13d6f15b29790c118669fc93254e7ba769c519a60f1de4c656a6f2381c3d2653361164ec021b63d506372445cc2a42366e9d06adf8c36413c7e88484af
|
|
7
|
+
data.tar.gz: d259c8c92690dade9e49caa83543f34e0e59defd33502c7dc39f80e830b51dcd6ac13fde7b3d2fa9d78e03113277d6a9f0e8e57bd0b1f69eef0a99d353f28c27
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.1.3 - 2017-05-18
|
|
2
|
+
|
|
3
|
+
* [maintenance] Use PreparedStatement to improve the performance. [#23]
|
|
4
|
+
|
|
5
|
+
* [maintenance] Deduplicate redundant logging to fix #24. [#25]
|
|
6
|
+
|
|
7
|
+
* [maintenance] Add settings.gradle. [#26]
|
|
8
|
+
|
|
1
9
|
## 0.1.2 - 2017-05-15
|
|
2
10
|
|
|
3
11
|
* [new feature] Add warning to change default of case sensitive. [#18]
|
data/build.gradle
CHANGED
data/settings.gradle
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rootProject.name = 'embulk-filter-calcite'
|
|
@@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList;
|
|
|
6
6
|
import com.google.common.collect.ImmutableMap;
|
|
7
7
|
import com.google.inject.Inject;
|
|
8
8
|
import java.sql.Connection;
|
|
9
|
+
import java.sql.PreparedStatement;
|
|
9
10
|
import java.sql.ResultSet;
|
|
10
11
|
import java.sql.ResultSetMetaData;
|
|
11
12
|
import java.sql.SQLException;
|
|
@@ -55,7 +56,7 @@ public class CalciteFilterPlugin implements FilterPlugin {
|
|
|
55
56
|
public void transaction(ConfigSource config, Schema inputSchema, FilterPlugin.Control control) {
|
|
56
57
|
PluginTask task = config.loadConfig(PluginTask.class);
|
|
57
58
|
Properties props = System.getProperties(); // TODO should be configured as config option
|
|
58
|
-
|
|
59
|
+
setupPropertiesFromTransaction(task, props);
|
|
59
60
|
|
|
60
61
|
// Set input schema in PageSchema
|
|
61
62
|
PageSchema.schema = inputSchema;
|
|
@@ -81,14 +82,19 @@ public class CalciteFilterPlugin implements FilterPlugin {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
private void
|
|
85
|
-
// @see https://calcite.apache.org/docs/adapter.html#jdbc-connect-string-parameters
|
|
85
|
+
private void setupPropertiesFromTransaction(PluginTask task, Properties props) {
|
|
86
86
|
final ToStringMap options = task.getOptions();
|
|
87
87
|
if (!options.containsKey("caseSensitive")) {
|
|
88
88
|
log.warn("JDBC parameter 'caseSensitive' is implicitly set to false as default in");
|
|
89
89
|
log.warn("embulk-filter-calcite 0.1 but, it's scheduled to change default with true");
|
|
90
90
|
log.warn("in 0.2. Please use 'options' option to set 'caseSensitive' to false.");
|
|
91
91
|
}
|
|
92
|
+
setupProperties(task, props);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private void setupProperties(PluginTask task, Properties props) {
|
|
96
|
+
// @see https://calcite.apache.org/docs/adapter.html#jdbc-connect-string-parameters
|
|
97
|
+
final ToStringMap options = task.getOptions();
|
|
92
98
|
props.setProperty("caseSensitive", "false"); // Relax case-sensitive
|
|
93
99
|
props.setProperty("timeZone", task.getDefaultTimeZone().getID());
|
|
94
100
|
|
|
@@ -110,6 +116,14 @@ public class CalciteFilterPlugin implements FilterPlugin {
|
|
|
110
116
|
}
|
|
111
117
|
}
|
|
112
118
|
|
|
119
|
+
private PreparedStatement createPreparedStatement(Connection conn, String query) {
|
|
120
|
+
try {
|
|
121
|
+
return conn.prepareStatement(query);
|
|
122
|
+
} catch (SQLException e) {
|
|
123
|
+
throw Throwables.propagate(e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
113
127
|
private String buildJdbcUrl() {
|
|
114
128
|
// build a json model to apply Page storage adaptor
|
|
115
129
|
// @see https://github.com/apache/calcite/blob/master/example/csv/src/test/resources/model.json
|
|
@@ -214,12 +228,13 @@ public class CalciteFilterPlugin implements FilterPlugin {
|
|
|
214
228
|
List<ColumnGetter> getters = newColumnGetters(factory, task.getQuerySchema());
|
|
215
229
|
Properties props = System.getProperties(); // TODO should be configured as config option
|
|
216
230
|
setupProperties(task, props);
|
|
231
|
+
final Connection conn = newConnection(buildJdbcUrl(), props);
|
|
232
|
+
final PreparedStatement preparedStatement = createPreparedStatement(conn, task.getQuery());
|
|
217
233
|
return new FilterPageOutput(outputSchema,
|
|
218
|
-
task.getQuery(),
|
|
219
234
|
pageBuilder,
|
|
220
235
|
pageConverter,
|
|
221
236
|
getters,
|
|
222
|
-
|
|
237
|
+
preparedStatement); // Transfer ownership of preparedStatement to FilterPageOutput
|
|
223
238
|
}
|
|
224
239
|
|
|
225
240
|
public interface PluginTask
|
|
@@ -251,21 +266,21 @@ public class CalciteFilterPlugin implements FilterPlugin {
|
|
|
251
266
|
implements PageOutput {
|
|
252
267
|
|
|
253
268
|
private final Schema outputSchema;
|
|
254
|
-
private final String query;
|
|
255
269
|
private final PageBuilder pageBuilder;
|
|
256
270
|
private final PageConverter pageConverter;
|
|
257
271
|
private final List<ColumnGetter> getters;
|
|
258
|
-
private final
|
|
272
|
+
private final PreparedStatement preparedStatement;
|
|
259
273
|
|
|
260
|
-
private FilterPageOutput(Schema outputSchema,
|
|
274
|
+
private FilterPageOutput(Schema outputSchema,
|
|
275
|
+
PageBuilder pageBuilder,
|
|
261
276
|
PageConverter pageConverter,
|
|
262
|
-
List<ColumnGetter> getters,
|
|
277
|
+
List<ColumnGetter> getters,
|
|
278
|
+
PreparedStatement preparedStatement) {
|
|
263
279
|
this.outputSchema = outputSchema;
|
|
264
|
-
this.query = query;
|
|
265
280
|
this.pageBuilder = pageBuilder;
|
|
266
281
|
this.pageConverter = pageConverter;
|
|
267
282
|
this.getters = getters;
|
|
268
|
-
this.
|
|
283
|
+
this.preparedStatement = preparedStatement;
|
|
269
284
|
}
|
|
270
285
|
|
|
271
286
|
@Override
|
|
@@ -276,10 +291,8 @@ public class CalciteFilterPlugin implements FilterPlugin {
|
|
|
276
291
|
// Set page as TLS variable in PageTable
|
|
277
292
|
PageTable.page.set(page);
|
|
278
293
|
|
|
279
|
-
try (Connection conn = newConnection(buildJdbcUrl(), props);
|
|
280
|
-
Statement stat = conn.createStatement();
|
|
281
|
-
ResultSet result = executeQuery(stat, query)) {
|
|
282
294
|
|
|
295
|
+
try (ResultSet result = preparedStatement.executeQuery()) {
|
|
283
296
|
while (result.next()) {
|
|
284
297
|
for (int i = 0; i < getters.size(); i++) {
|
|
285
298
|
int index = i + 1; // JDBC column index begins from 1
|
|
@@ -303,6 +316,11 @@ public class CalciteFilterPlugin implements FilterPlugin {
|
|
|
303
316
|
@Override
|
|
304
317
|
public void close() {
|
|
305
318
|
pageBuilder.close();
|
|
319
|
+
try {
|
|
320
|
+
preparedStatement.close();
|
|
321
|
+
} catch (SQLException e) {
|
|
322
|
+
throw Throwables.propagate(e);
|
|
323
|
+
}
|
|
306
324
|
}
|
|
307
325
|
}
|
|
308
326
|
}
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: embulk-filter-calcite
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Muga Nishizawa
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-05-
|
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -59,6 +59,7 @@ files:
|
|
|
59
59
|
- gradlew
|
|
60
60
|
- gradlew.bat
|
|
61
61
|
- lib/embulk/filter/calcite.rb
|
|
62
|
+
- settings.gradle
|
|
62
63
|
- src/main/java/org/embulk/filter/calcite/CalciteFilterPlugin.java
|
|
63
64
|
- src/main/java/org/embulk/filter/calcite/PageConverter.java
|
|
64
65
|
- src/main/java/org/embulk/filter/calcite/adapter/page/PageEnumerator.java
|
|
@@ -105,7 +106,7 @@ files:
|
|
|
105
106
|
- classpath/commons-lang3-3.2.jar
|
|
106
107
|
- classpath/commons-logging-1.2.jar
|
|
107
108
|
- classpath/commons-pool-1.5.4.jar
|
|
108
|
-
- classpath/embulk-filter-calcite-0.1.
|
|
109
|
+
- classpath/embulk-filter-calcite-0.1.3.jar
|
|
109
110
|
- classpath/embulk-input-jdbc-0.8.2.jar
|
|
110
111
|
- classpath/guava-19.0.jar
|
|
111
112
|
- classpath/httpclient-4.5.2.jar
|