embulk-output-jdbc 0.8.3 → 0.8.4
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/classpath/{embulk-output-jdbc-0.8.3.jar → embulk-output-jdbc-0.8.4.jar} +0 -0
- data/src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputPlugin.java +11 -4
- data/src/main/java/org/embulk/output/jdbc/BatchInsert.java +3 -0
- data/src/main/java/org/embulk/output/jdbc/StandardBatchInsert.java +16 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ac7ae92de373b40dfa5153d7d3e0e3bf3f99600
|
4
|
+
data.tar.gz: eea167726affb1c31c282cc9aee5c2b45c445d67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48698e261cc369c0c594a4f7e50c9768e22b1ed6e527669688c95ec6d5dc0e8b8e1f7c114f18e15a77e1066334a966aa5aecd756cc627b2e8da533aff00e635b
|
7
|
+
data.tar.gz: f872b344503f72a42428fe20437ca9528cee34ad66db9d402be58806bf1ca2c71d0fbb210cd80bf300f2717e589f0ea869d1ecb9b87109f3397d4a073acd1fa2
|
Binary file
|
@@ -15,6 +15,7 @@ import java.net.URL;
|
|
15
15
|
import java.nio.charset.Charset;
|
16
16
|
import java.nio.file.Path;
|
17
17
|
import java.nio.file.Paths;
|
18
|
+
import java.sql.Statement;
|
18
19
|
import java.sql.Types;
|
19
20
|
import java.sql.ResultSet;
|
20
21
|
import java.sql.DatabaseMetaData;
|
@@ -1200,12 +1201,18 @@ public abstract class AbstractJdbcOutputPlugin
|
|
1200
1201
|
protected void retryColumnsSetters() throws IOException, SQLException
|
1201
1202
|
{
|
1202
1203
|
int size = columnVisitors.size();
|
1204
|
+
int[] updateCounts = batch.getLastUpdateCounts();
|
1205
|
+
int index = 0;
|
1203
1206
|
for (Record record : pageReader.getReadRecords()) {
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
+
// retry failed records
|
1208
|
+
if (index >= updateCounts.length || updateCounts[index] == Statement.EXECUTE_FAILED) {
|
1209
|
+
for (int i = 0; i < size; i++) {
|
1210
|
+
ColumnSetterVisitor columnVisitor = new ColumnSetterVisitor(record, columnSetters.get(i));
|
1211
|
+
columns.get(i).visit(columnVisitor);
|
1212
|
+
}
|
1213
|
+
batch.add();
|
1207
1214
|
}
|
1208
|
-
|
1215
|
+
index++;
|
1209
1216
|
}
|
1210
1217
|
}
|
1211
1218
|
}
|
@@ -18,6 +18,9 @@ public interface BatchInsert
|
|
18
18
|
|
19
19
|
public void flush() throws IOException, SQLException;
|
20
20
|
|
21
|
+
// should be implemented for retry
|
22
|
+
public int[] getLastUpdateCounts();
|
23
|
+
|
21
24
|
public void finish() throws IOException, SQLException;
|
22
25
|
|
23
26
|
public void setNull(int sqlType) throws IOException, SQLException;
|
@@ -3,6 +3,7 @@ package org.embulk.output.jdbc;
|
|
3
3
|
import java.util.Calendar;
|
4
4
|
import java.io.IOException;
|
5
5
|
import java.math.BigDecimal;
|
6
|
+
import java.sql.BatchUpdateException;
|
6
7
|
import java.sql.PreparedStatement;
|
7
8
|
import java.sql.SQLException;
|
8
9
|
import java.sql.Date;
|
@@ -26,6 +27,7 @@ public class StandardBatchInsert
|
|
26
27
|
private int batchWeight;
|
27
28
|
private int batchRows;
|
28
29
|
private long totalRows;
|
30
|
+
private int[] lastUpdateCounts;
|
29
31
|
|
30
32
|
public StandardBatchInsert(JdbcOutputConnector connector, Optional<MergeConfig> mergeConfig) throws IOException, SQLException
|
31
33
|
{
|
@@ -70,17 +72,24 @@ public class StandardBatchInsert
|
|
70
72
|
|
71
73
|
public void flush() throws IOException, SQLException
|
72
74
|
{
|
75
|
+
lastUpdateCounts = new int[]{};
|
76
|
+
|
73
77
|
if (batchWeight == 0) return;
|
74
78
|
|
75
79
|
logger.info(String.format("Loading %,d rows", batchRows));
|
76
80
|
long startTime = System.currentTimeMillis();
|
77
81
|
try {
|
78
|
-
batch.executeBatch(); // here can't use returned value because MySQL Connector/J returns SUCCESS_NO_INFO as a batch result
|
82
|
+
lastUpdateCounts = batch.executeBatch(); // here can't use returned value because MySQL Connector/J returns SUCCESS_NO_INFO as a batch result
|
79
83
|
double seconds = (System.currentTimeMillis() - startTime) / 1000.0;
|
80
84
|
|
81
85
|
totalRows += batchRows;
|
82
86
|
logger.info(String.format("> %.2f seconds (loaded %,d rows in total)", seconds, totalRows));
|
83
87
|
|
88
|
+
} catch (BatchUpdateException e) {
|
89
|
+
// will be used for retry
|
90
|
+
lastUpdateCounts = e.getUpdateCounts();
|
91
|
+
throw e;
|
92
|
+
|
84
93
|
} finally {
|
85
94
|
// clear for retry
|
86
95
|
batch.clearBatch();
|
@@ -89,6 +98,12 @@ public class StandardBatchInsert
|
|
89
98
|
}
|
90
99
|
}
|
91
100
|
|
101
|
+
@Override
|
102
|
+
public int[] getLastUpdateCounts()
|
103
|
+
{
|
104
|
+
return lastUpdateCounts;
|
105
|
+
}
|
106
|
+
|
92
107
|
public void finish() throws IOException, SQLException
|
93
108
|
{
|
94
109
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-jdbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -19,7 +19,7 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- README.md
|
21
21
|
- build.gradle
|
22
|
-
- classpath/embulk-output-jdbc-0.8.
|
22
|
+
- classpath/embulk-output-jdbc-0.8.4.jar
|
23
23
|
- lib/embulk/output/jdbc.rb
|
24
24
|
- src/main/java/org/embulk/output/JdbcOutputPlugin.java
|
25
25
|
- src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputConnector.java
|