Skip to content

Commit 7d7db9a

Browse files
committed
Replace org.embulk.spi.time.Timestamp to java.time.Instant
1 parent 9cc3249 commit 7d7db9a

27 files changed

+68
-74
lines changed

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/BatchInsert.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.util.Calendar;
55
import java.io.IOException;
66
import java.sql.SQLException;
7-
import org.embulk.spi.time.Timestamp;
7+
import java.time.Instant;
88

99
public interface BatchInsert
1010
{
@@ -47,9 +47,9 @@ public interface BatchInsert
4747

4848
public void setBytes(byte[] v) throws IOException, SQLException;
4949

50-
public void setSqlDate(Timestamp v, Calendar cal) throws IOException, SQLException;
50+
public void setSqlDate(Instant v, Calendar cal) throws IOException, SQLException;
5151

52-
public void setSqlTime(Timestamp v, Calendar cal) throws IOException, SQLException;
52+
public void setSqlTime(Instant v, Calendar cal) throws IOException, SQLException;
5353

54-
public void setSqlTimestamp(Timestamp v, Calendar cal) throws IOException, SQLException;
54+
public void setSqlTimestamp(Instant v, Calendar cal) throws IOException, SQLException;
5555
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/MemoryRecord.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package org.embulk.output.jdbc;
22

3+
import java.time.Instant;
34
import org.embulk.spi.Column;
4-
import org.embulk.spi.time.Timestamp;
55
import org.msgpack.value.Value;
66

7-
87
public class MemoryRecord implements Record
98
{
109
private final Object[] values;
@@ -40,9 +39,9 @@ public String getString(Column column)
4039
return (String)getValue(column);
4140
}
4241

43-
public Timestamp getTimestamp(Column column)
42+
public Instant getTimestamp(Column column)
4443
{
45-
return (Timestamp)getValue(column);
44+
return ((org.embulk.spi.time.Timestamp) getValue(column)).getInstant();
4645
}
4746

4847
public Value getJson(Column column)
@@ -60,4 +59,3 @@ public void setValue(Column column, Object value)
6059
values[column.getIndex()] = value;
6160
}
6261
}
63-

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/PageReaderRecord.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package org.embulk.output.jdbc;
22

3+
import java.time.Instant;
34
import java.util.ArrayList;
45
import java.util.List;
56

67
import org.embulk.spi.Column;
78
import org.embulk.spi.Page;
89
import org.embulk.spi.PageReader;
9-
import org.embulk.spi.time.Timestamp;
1010
import org.msgpack.value.Value;
1111

12-
1312
/**
1413
* Record read by PageReader.
1514
* The class will save read records for retry.
@@ -62,9 +61,9 @@ public String getString(Column column)
6261
return save(column, pageReader.getString(column));
6362
}
6463

65-
public Timestamp getTimestamp(Column column)
64+
public Instant getTimestamp(Column column)
6665
{
67-
return save(column, pageReader.getTimestamp(column));
66+
return save(column, pageReader.getTimestamp(column).getInstant());
6867
}
6968

7069
public Value getJson(Column column)
@@ -93,4 +92,3 @@ private <T> T save(Column column, T value)
9392
return value;
9493
}
9594
}
96-

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/Record.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.embulk.output.jdbc;
22

3+
import java.time.Instant;
34
import org.embulk.spi.Column;
4-
import org.embulk.spi.time.Timestamp;
55
import org.msgpack.value.Value;
66

77
public interface Record
@@ -16,8 +16,7 @@ public interface Record
1616

1717
String getString(Column column);
1818

19-
Timestamp getTimestamp(Column column);
19+
Instant getTimestamp(Column column);
2020

2121
Value getJson(Column column);
2222
}
23-

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/StandardBatchInsert.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import java.sql.SQLException;
99
import java.sql.Date;
1010
import java.sql.Time;
11+
import java.time.Instant;
1112
import java.util.Optional;
1213
import org.slf4j.Logger;
1314
import org.slf4j.LoggerFactory;
14-
import org.embulk.spi.time.Timestamp;
1515

1616
public class StandardBatchInsert
1717
implements BatchInsert
@@ -184,7 +184,7 @@ public void setBytes(byte[] v) throws IOException, SQLException
184184
nextColumn(v.length + 4);
185185
}
186186

187-
public void setSqlDate(Timestamp v, Calendar cal) throws IOException, SQLException
187+
public void setSqlDate(final Instant v, final Calendar cal) throws IOException, SQLException
188188
{
189189
// JavaDoc of java.sql.Time says:
190190
// >> To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.
@@ -197,14 +197,14 @@ public void setSqlDate(Timestamp v, Calendar cal) throws IOException, SQLExcepti
197197
nextColumn(32);
198198
}
199199

200-
public void setSqlTime(Timestamp v, Calendar cal) throws IOException, SQLException
200+
public void setSqlTime(final Instant v, final Calendar cal) throws IOException, SQLException
201201
{
202202
Time t = new Time(v.toEpochMilli());
203203
batch.setTime(index, t, cal);
204204
nextColumn(32);
205205
}
206206

207-
public void setSqlTimestamp(Timestamp v, Calendar cal) throws IOException, SQLException
207+
public void setSqlTimestamp(final Instant v, final Calendar cal) throws IOException, SQLException
208208
{
209209
java.sql.Timestamp t = new java.sql.Timestamp(v.toEpochMilli());
210210
t.setNanos(v.getNano());

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BigDecimalColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.math.BigDecimal;
44
import java.io.IOException;
55
import java.sql.SQLException;
6+
import java.time.Instant;
67

7-
import org.embulk.spi.time.Timestamp;
88
import org.embulk.output.jdbc.JdbcColumn;
99
import org.embulk.output.jdbc.BatchInsert;
1010
import org.msgpack.value.Value;
@@ -63,7 +63,7 @@ public void stringValue(String v) throws IOException, SQLException
6363
}
6464

6565
@Override
66-
public void timestampValue(Timestamp v) throws IOException, SQLException
66+
public void timestampValue(final Instant v) throws IOException, SQLException
6767
{
6868
defaultValue.setBigDecimal();
6969
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BooleanColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.time.Instant;
56

6-
import org.embulk.spi.time.Timestamp;
77
import org.embulk.output.jdbc.JdbcColumn;
88
import org.embulk.output.jdbc.BatchInsert;
99
import org.msgpack.value.Value;
@@ -48,7 +48,7 @@ public void stringValue(String v) throws IOException, SQLException
4848
}
4949

5050
@Override
51-
public void timestampValue(Timestamp v) throws IOException, SQLException
51+
public void timestampValue(final Instant v) throws IOException, SQLException
5252
{
5353
defaultValue.setBoolean();
5454
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ByteColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import java.io.IOException;
44
import java.sql.SQLException;
55
import java.math.RoundingMode;
6+
import java.time.Instant;
67

78
import com.google.common.math.DoubleMath;
89

9-
import org.embulk.spi.time.Timestamp;
1010
import org.embulk.output.jdbc.JdbcColumn;
1111
import org.embulk.output.jdbc.BatchInsert;
1212
import org.msgpack.value.Value;
@@ -71,7 +71,7 @@ public void stringValue(String v) throws IOException, SQLException
7171
}
7272

7373
@Override
74-
public void timestampValue(Timestamp v) throws IOException, SQLException
74+
public void timestampValue(final Instant v) throws IOException, SQLException
7575
{
7676
defaultValue.setByte();
7777
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.time.Instant;
56

67
import org.embulk.output.jdbc.BatchInsert;
78
import org.embulk.output.jdbc.JdbcColumn;
8-
import org.embulk.spi.time.Timestamp;
99
import org.msgpack.value.Value;
1010

1111
public abstract class ColumnSetter
@@ -42,7 +42,7 @@ public int getSqlType()
4242

4343
public abstract void stringValue(String v) throws IOException, SQLException;
4444

45-
public abstract void timestampValue(Timestamp v) throws IOException, SQLException;
45+
public abstract void timestampValue(final Instant v) throws IOException, SQLException;
4646

4747
public abstract void jsonValue(Value v) throws IOException, SQLException;
4848
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/DoubleColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.time.Instant;
56

6-
import org.embulk.spi.time.Timestamp;
77
import org.embulk.output.jdbc.JdbcColumn;
88
import org.embulk.output.jdbc.BatchInsert;
99
import org.msgpack.value.Value;
@@ -55,7 +55,7 @@ public void stringValue(String v) throws IOException, SQLException
5555
}
5656

5757
@Override
58-
public void timestampValue(Timestamp v) throws IOException, SQLException
58+
public void timestampValue(final Instant v) throws IOException, SQLException
5959
{
6060
defaultValue.setDouble();
6161
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/FloatColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.time.Instant;
56

6-
import org.embulk.spi.time.Timestamp;
77
import org.embulk.output.jdbc.JdbcColumn;
88
import org.embulk.output.jdbc.BatchInsert;
99
import org.msgpack.value.Value;
@@ -55,7 +55,7 @@ public void stringValue(String v) throws IOException, SQLException
5555
}
5656

5757
@Override
58-
public void timestampValue(Timestamp v) throws IOException, SQLException
58+
public void timestampValue(final Instant v) throws IOException, SQLException
5959
{
6060
defaultValue.setFloat();
6161
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/IntColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import java.io.IOException;
44
import java.sql.SQLException;
55
import java.math.RoundingMode;
6+
import java.time.Instant;
67

78
import com.google.common.math.DoubleMath;
89

9-
import org.embulk.spi.time.Timestamp;
1010
import org.embulk.output.jdbc.JdbcColumn;
1111
import org.embulk.output.jdbc.BatchInsert;
1212
import org.msgpack.value.Value;
@@ -71,7 +71,7 @@ public void stringValue(String v) throws IOException, SQLException
7171
}
7272

7373
@Override
74-
public void timestampValue(Timestamp v) throws IOException, SQLException
74+
public void timestampValue(final Instant v) throws IOException, SQLException
7575
{
7676
defaultValue.setInt();
7777
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/JsonColumnSetter.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.time.Instant;
56

6-
import org.embulk.spi.time.Timestamp;
77
import org.embulk.output.jdbc.JdbcColumn;
88
import org.embulk.output.jdbc.BatchInsert;
99
import org.msgpack.value.Value;
@@ -48,7 +48,7 @@ public void stringValue(String v) throws IOException, SQLException
4848
}
4949

5050
@Override
51-
public void timestampValue(Timestamp v) throws IOException, SQLException
51+
public void timestampValue(final Instant v) throws IOException, SQLException
5252
{
5353
defaultValue.setJson();
5454
}
@@ -58,4 +58,3 @@ public void jsonValue(Value v) throws IOException, SQLException {
5858
batch.setString(v.toJson());
5959
}
6060
}
61-

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/LongColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import java.io.IOException;
44
import java.sql.SQLException;
55
import java.math.RoundingMode;
6+
import java.time.Instant;
67

78
import com.google.common.math.DoubleMath;
89

9-
import org.embulk.spi.time.Timestamp;
1010
import org.embulk.output.jdbc.JdbcColumn;
1111
import org.embulk.output.jdbc.BatchInsert;
1212
import org.msgpack.value.Value;
@@ -67,7 +67,7 @@ public void stringValue(String v) throws IOException, SQLException
6767
}
6868

6969
@Override
70-
public void timestampValue(Timestamp v) throws IOException, SQLException
70+
public void timestampValue(final Instant v) throws IOException, SQLException
7171
{
7272
defaultValue.setLong();
7373
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NStringColumnSetter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.time.Instant;
56

6-
import org.embulk.spi.time.Timestamp;
77
import org.embulk.output.jdbc.JdbcColumn;
88
import org.embulk.output.jdbc.BatchInsert;
99
import org.embulk.util.timestamp.TimestampFormatter;
@@ -53,9 +53,9 @@ public void stringValue(String v) throws IOException, SQLException
5353
}
5454

5555
@Override
56-
public void timestampValue(Timestamp v) throws IOException, SQLException
56+
public void timestampValue(final Instant v) throws IOException, SQLException
5757
{
58-
batch.setNString(timestampFormatter.format(v.getInstant()));
58+
batch.setNString(timestampFormatter.format(v));
5959
}
6060

6161
@Override

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NullColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.io.IOException;
44
import java.sql.SQLException;
5+
import java.time.Instant;
56

6-
import org.embulk.spi.time.Timestamp;
77
import org.embulk.output.jdbc.JdbcColumn;
88
import org.embulk.output.jdbc.BatchInsert;
99
import org.msgpack.value.Value;
@@ -42,7 +42,7 @@ public void stringValue(String v) throws IOException, SQLException
4242
}
4343

4444
@Override
45-
public void timestampValue(Timestamp v) throws IOException, SQLException
45+
public void timestampValue(final Instant v) throws IOException, SQLException
4646
{
4747
defaultValue.setNull();
4848
}

Diff for: embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/PassThroughColumnSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Calendar;
44
import java.io.IOException;
55
import java.sql.SQLException;
6+
import java.time.Instant;
67

7-
import org.embulk.spi.time.Timestamp;
88
import org.embulk.output.jdbc.JdbcColumn;
99
import org.embulk.output.jdbc.BatchInsert;
1010
import org.msgpack.value.Value;
@@ -53,7 +53,7 @@ public void stringValue(String v) throws IOException, SQLException
5353
}
5454

5555
@Override
56-
public void timestampValue(Timestamp v) throws IOException, SQLException
56+
public void timestampValue(final Instant v) throws IOException, SQLException
5757
{
5858
batch.setSqlTimestamp(v, calendar);
5959
}

0 commit comments

Comments
 (0)