embulk-output-oracle 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +160 -160
  3. data/build.gradle +6 -6
  4. data/classpath/embulk-output-jdbc-0.4.2.jar +0 -0
  5. data/classpath/{embulk-output-oracle-0.4.1.jar → embulk-output-oracle-0.4.2.jar} +0 -0
  6. data/lib/embulk/output/oracle.rb +3 -3
  7. data/src/main/cpp/common/dir-path-load.cpp +424 -424
  8. data/src/main/cpp/common/dir-path-load.h +36 -36
  9. data/src/main/cpp/common/embulk-output-oracle.cpp +196 -196
  10. data/src/main/cpp/common/org_embulk_output_oracle_oci_OCI.h +77 -77
  11. data/src/main/cpp/linux/build.sh +21 -21
  12. data/src/main/cpp/win/build.bat +31 -31
  13. data/src/main/cpp/win/dllmain.cpp +25 -25
  14. data/src/main/cpp/win/embulk-output-oracle.sln +39 -39
  15. data/src/main/cpp/win/embulk-output-oracle.vcxproj +175 -175
  16. data/src/main/java/org/embulk/output/OracleOutputPlugin.java +151 -153
  17. data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +290 -290
  18. data/src/main/java/org/embulk/output/oracle/InsertMethod.java +8 -8
  19. data/src/main/java/org/embulk/output/oracle/OracleCharset.java +32 -32
  20. data/src/main/java/org/embulk/output/oracle/OracleOutputConnection.java +179 -165
  21. data/src/main/java/org/embulk/output/oracle/OracleOutputConnector.java +49 -49
  22. data/src/main/java/org/embulk/output/oracle/TimestampFormat.java +37 -37
  23. data/src/main/java/org/embulk/output/oracle/oci/ColumnDefinition.java +26 -26
  24. data/src/main/java/org/embulk/output/oracle/oci/OCI.java +139 -139
  25. data/src/main/java/org/embulk/output/oracle/oci/OCIManager.java +64 -64
  26. data/src/main/java/org/embulk/output/oracle/oci/OCIWrapper.java +96 -96
  27. data/src/main/java/org/embulk/output/oracle/oci/RowBuffer.java +105 -105
  28. data/src/main/java/org/embulk/output/oracle/oci/TableDefinition.java +24 -24
  29. data/src/test/cpp/common/embulk-output-oracle-test.cpp +69 -69
  30. data/src/test/cpp/linux/build.sh +19 -19
  31. data/src/test/cpp/win/build.bat +28 -28
  32. data/src/test/cpp/win/embulk-output-oracle-test.vcxproj +154 -154
  33. data/src/test/java/org/embulk/input/filesplit/LocalFileSplitInputPlugin.java +185 -187
  34. data/src/test/java/org/embulk/input/filesplit/PartialFile.java +49 -49
  35. data/src/test/java/org/embulk/input/filesplit/PartialFileInputStream.java +154 -154
  36. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java +50 -25
  37. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java +548 -540
  38. data/src/test/java/org/embulk/output/oracle/TimestampFormatTest.java +57 -57
  39. data/src/test/java/org/embulk/output/tester/EmbulkPluginTester.java +79 -0
  40. data/src/test/resources/data/test1/test1.csv +3 -3
  41. data/src/test/resources/dummy.txt +1 -0
  42. data/src/test/resources/yml/test-insert-direct-direct-method.yml +26 -26
  43. data/src/test/resources/yml/test-insert-direct-empty.yml +25 -25
  44. data/src/test/resources/yml/test-insert-direct-oci-method-split.yml +28 -28
  45. data/src/test/resources/yml/test-insert-direct-oci-method.yml +28 -28
  46. data/src/test/resources/yml/test-insert-direct.yml +25 -25
  47. data/src/test/resources/yml/test-insert-empty.yml +27 -27
  48. data/src/test/resources/yml/test-insert.yml +25 -27
  49. data/src/test/resources/yml/test-replace-empty.yml +31 -31
  50. data/src/test/resources/yml/test-replace-long-name-multibyte.yml +31 -31
  51. data/src/test/resources/yml/test-replace-long-name.yml +31 -31
  52. data/src/test/resources/yml/test-replace.yml +31 -31
  53. data/src/test/resources/yml/test-string-timestamp.yml +28 -28
  54. data/src/test/resources/yml/test-url.yml +24 -24
  55. metadata +6 -8
  56. data/classpath/embulk-output-jdbc-0.4.1.jar +0 -0
  57. data/lib/embulk/linux_x64/libembulk-output-oracle.so +0 -0
  58. data/src/test/java/org/embulk/output/oracle/ChildFirstClassLoader.java +0 -42
  59. data/src/test/java/org/embulk/output/oracle/EmbulkPluginTester.java +0 -124
  60. data/src/test/java/org/embulk/output/oracle/EmptyConfigSource.java +0 -105
@@ -1,57 +1,57 @@
1
- package org.embulk.output.oracle;
2
-
3
- import java.sql.Timestamp;
4
- import java.text.ParseException;
5
- import java.text.SimpleDateFormat;
6
- import java.util.Date;
7
-
8
- import org.junit.Test;
9
- import static org.junit.Assert.assertEquals;
10
-
11
- public class TimestampFormatTest {
12
-
13
- @Test
14
- public void test() throws ParseException
15
- {
16
- Date date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2015/03/04 17:08:09");
17
- Timestamp t = new Timestamp(date.getTime());
18
-
19
- {
20
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9);
21
- assertEquals("2015-03-04 17:08:09.000000000", format.format(t));
22
- }
23
- {
24
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 0);
25
- assertEquals("2015-03-04 17:08:09", format.format(t));
26
- }
27
- {
28
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 1);
29
- assertEquals("2015-03-04 17:08:09.0", format.format(t));
30
- }
31
-
32
- t.setNanos(1234567);
33
- {
34
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9);
35
- assertEquals("2015-03-04 17:08:09.001234567", format.format(t));
36
- }
37
- {
38
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 2);
39
- assertEquals("2015-03-04 17:08:09.00", format.format(t));
40
- }
41
- {
42
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 3);
43
- assertEquals("2015-03-04 17:08:09.001", format.format(t));
44
- }
45
-
46
- t.setNanos(123456789);
47
- {
48
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9);
49
- assertEquals("2015-03-04 17:08:09.123456789", format.format(t));
50
- }
51
- {
52
- TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 1);
53
- assertEquals("2015-03-04 17:08:09.1", format.format(t));
54
- }
55
- }
56
-
57
- }
1
+ package org.embulk.output.oracle;
2
+
3
+ import java.sql.Timestamp;
4
+ import java.text.ParseException;
5
+ import java.text.SimpleDateFormat;
6
+ import java.util.Date;
7
+
8
+ import org.junit.Test;
9
+ import static org.junit.Assert.assertEquals;
10
+
11
+ public class TimestampFormatTest {
12
+
13
+ @Test
14
+ public void test() throws ParseException
15
+ {
16
+ Date date = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse("2015/03/04 17:08:09");
17
+ Timestamp t = new Timestamp(date.getTime());
18
+
19
+ {
20
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9);
21
+ assertEquals("2015-03-04 17:08:09.000000000", format.format(t));
22
+ }
23
+ {
24
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 0);
25
+ assertEquals("2015-03-04 17:08:09", format.format(t));
26
+ }
27
+ {
28
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 1);
29
+ assertEquals("2015-03-04 17:08:09.0", format.format(t));
30
+ }
31
+
32
+ t.setNanos(1234567);
33
+ {
34
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9);
35
+ assertEquals("2015-03-04 17:08:09.001234567", format.format(t));
36
+ }
37
+ {
38
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 2);
39
+ assertEquals("2015-03-04 17:08:09.00", format.format(t));
40
+ }
41
+ {
42
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 3);
43
+ assertEquals("2015-03-04 17:08:09.001", format.format(t));
44
+ }
45
+
46
+ t.setNanos(123456789);
47
+ {
48
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 9);
49
+ assertEquals("2015-03-04 17:08:09.123456789", format.format(t));
50
+ }
51
+ {
52
+ TimestampFormat format = new TimestampFormat("yyyy-MM-dd HH:mm:ss", 1);
53
+ assertEquals("2015-03-04 17:08:09.1", format.format(t));
54
+ }
55
+ }
56
+
57
+ }
@@ -0,0 +1,79 @@
1
+ package org.embulk.output.tester;
2
+
3
+ import java.io.File;
4
+ import java.util.ArrayList;
5
+ import java.util.List;
6
+
7
+ import org.embulk.EmbulkEmbed;
8
+ import org.embulk.EmbulkEmbed.Bootstrap;
9
+ import org.embulk.config.ConfigSource;
10
+ import org.embulk.plugin.InjectedPluginSource;
11
+
12
+ import com.google.inject.Binder;
13
+ import com.google.inject.Module;
14
+
15
+ public class EmbulkPluginTester
16
+ {
17
+ private static class PluginDefinition
18
+ {
19
+ public final Class<?> iface;
20
+ public final String name;
21
+ public final Class<?> impl;
22
+
23
+
24
+ public PluginDefinition(Class<?> iface, String name, Class<?> impl)
25
+ {
26
+ this.iface = iface;
27
+ this.name = name;
28
+ this.impl = impl;
29
+ }
30
+
31
+ }
32
+
33
+ private final List<PluginDefinition> plugins = new ArrayList<PluginDefinition>();
34
+
35
+ private EmbulkEmbed embulk;
36
+
37
+ public EmbulkPluginTester()
38
+ {
39
+ }
40
+
41
+ public EmbulkPluginTester(Class<?> iface, String name, Class<?> impl)
42
+ {
43
+ addPlugin(iface, name, impl);
44
+ }
45
+
46
+ public void addPlugin(Class<?> iface, String name, Class<?> impl)
47
+ {
48
+ plugins.add(new PluginDefinition(iface, name, impl));
49
+ }
50
+
51
+ public void run(String ymlPath) throws Exception
52
+ {
53
+ if (embulk == null) {
54
+ Bootstrap bootstrap = new EmbulkEmbed.Bootstrap();
55
+ bootstrap.addModules(new Module()
56
+ {
57
+ @Override
58
+ public void configure(Binder binder)
59
+ {
60
+ for (PluginDefinition plugin : plugins) {
61
+ InjectedPluginSource.registerPluginTo(binder, plugin.iface, plugin.name, plugin.impl);
62
+ }
63
+ }
64
+ });
65
+ embulk = bootstrap.initializeCloseable();
66
+ }
67
+
68
+ ConfigSource config = embulk.newConfigLoader().fromYamlFile(new File(ymlPath));
69
+ embulk.run(config);
70
+ }
71
+
72
+ public void destroy() {
73
+ if (embulk != null) {
74
+ embulk.destroy();
75
+ embulk = null;
76
+ }
77
+ }
78
+
79
+ }
@@ -1,3 +1,3 @@
1
- A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
2
- A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
3
- A003,,,,,
1
+ A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
2
+ A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
3
+ A003,,,,,
@@ -0,0 +1 @@
1
+ dummy
@@ -1,26 +1,26 @@
1
- in:
2
- type: file
3
- path_prefix: '/data/test1/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: ID, type: string}
12
- - {name: VARCHAR2_ITEM, type: string}
13
- - {name: INTEGER_ITEM, type: long}
14
- - {name: NUMBER_ITEM, type: string}
15
- - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
- - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
- out:
18
- type: oracle
19
- host: localhost
20
- database: TESTDB
21
- user: TEST_USER
22
- password: test_pw
23
- table: TEST1
24
- mode: insert_direct
25
- insert_method: direct
26
- #driver_path: driver/ojdbc7.jar
1
+ in:
2
+ type: file
3
+ path_prefix: '/data/test1/test1.csv'
4
+ parser:
5
+ charset: UTF-8
6
+ newline: CRLF
7
+ type: csv
8
+ delimiter: ','
9
+ quote: ''
10
+ columns:
11
+ - {name: ID, type: string}
12
+ - {name: VARCHAR2_ITEM, type: string}
13
+ - {name: INTEGER_ITEM, type: long}
14
+ - {name: NUMBER_ITEM, type: string}
15
+ - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
+ - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
+ out:
18
+ type: oracle
19
+ host: localhost
20
+ database: TESTDB
21
+ user: TEST_USER
22
+ password: test_pw
23
+ table: TEST1
24
+ mode: insert_direct
25
+ insert_method: direct
26
+ #driver_path: driver/ojdbc7.jar
@@ -1,25 +1,25 @@
1
- in:
2
- type: file
3
- path_prefix: '/data/test2/'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: ID, type: string}
12
- - {name: VARCHAR2_ITEM, type: string}
13
- - {name: INTEGER_ITEM, type: long}
14
- - {name: NUMBER_ITEM, type: string}
15
- - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
- - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
- out:
18
- type: oracle
19
- host: localhost
20
- database: TESTDB
21
- user: TEST_USER
22
- password: test_pw
23
- table: TEST1
24
- mode: insert_direct
25
- #driver_path: driver/ojdbc7.jar
1
+ in:
2
+ type: file
3
+ path_prefix: '/data/test2/'
4
+ parser:
5
+ charset: UTF-8
6
+ newline: CRLF
7
+ type: csv
8
+ delimiter: ','
9
+ quote: ''
10
+ columns:
11
+ - {name: ID, type: string}
12
+ - {name: VARCHAR2_ITEM, type: string}
13
+ - {name: INTEGER_ITEM, type: long}
14
+ - {name: NUMBER_ITEM, type: string}
15
+ - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
+ - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
+ out:
18
+ type: oracle
19
+ host: localhost
20
+ database: TESTDB
21
+ user: TEST_USER
22
+ password: test_pw
23
+ table: TEST1
24
+ mode: insert_direct
25
+ #driver_path: driver/ojdbc7.jar
@@ -1,28 +1,28 @@
1
- in:
2
- type: filesplit
3
- path: '/data/test1/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: ID, type: string}
12
- - {name: VARCHAR2_ITEM, type: string}
13
- - {name: INTEGER_ITEM, type: long}
14
- - {name: NUMBER_ITEM, type: string}
15
- - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
- - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
- out:
18
- type: oracle
19
- host: localhost
20
- database: TESTDB
21
- user: TEST_USER
22
- password: test_pw
23
- table: TEST1
24
- mode: insert_direct
25
- insert_method: oci
26
- column_options:
27
- INTEGER_ITEM: {value_type: pass}
28
- #driver_path: driver/ojdbc7.jar
1
+ in:
2
+ type: filesplit
3
+ path: '/data/test1/test1.csv'
4
+ parser:
5
+ charset: UTF-8
6
+ newline: CRLF
7
+ type: csv
8
+ delimiter: ','
9
+ quote: ''
10
+ columns:
11
+ - {name: ID, type: string}
12
+ - {name: VARCHAR2_ITEM, type: string}
13
+ - {name: INTEGER_ITEM, type: long}
14
+ - {name: NUMBER_ITEM, type: string}
15
+ - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
+ - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
+ out:
18
+ type: oracle
19
+ host: localhost
20
+ database: TESTDB
21
+ user: TEST_USER
22
+ password: test_pw
23
+ table: TEST1
24
+ mode: insert_direct
25
+ insert_method: oci
26
+ column_options:
27
+ INTEGER_ITEM: {value_type: pass}
28
+ #driver_path: driver/ojdbc7.jar
@@ -1,28 +1,28 @@
1
- in:
2
- type: file
3
- path_prefix: '/data/test1/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: ID, type: string}
12
- - {name: VARCHAR2_ITEM, type: string}
13
- - {name: INTEGER_ITEM, type: long}
14
- - {name: NUMBER_ITEM, type: string}
15
- - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
- - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
- out:
18
- type: oracle
19
- host: localhost
20
- database: TESTDB
21
- user: TEST_USER
22
- password: test_pw
23
- table: TEST1
24
- mode: insert_direct
25
- insert_method: oci
26
- column_options:
27
- INTEGER_ITEM: {value_type: pass}
28
- #driver_path: driver/ojdbc7.jar
1
+ in:
2
+ type: file
3
+ path_prefix: '/data/test1/test1.csv'
4
+ parser:
5
+ charset: UTF-8
6
+ newline: CRLF
7
+ type: csv
8
+ delimiter: ','
9
+ quote: ''
10
+ columns:
11
+ - {name: ID, type: string}
12
+ - {name: VARCHAR2_ITEM, type: string}
13
+ - {name: INTEGER_ITEM, type: long}
14
+ - {name: NUMBER_ITEM, type: string}
15
+ - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
+ - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
+ out:
18
+ type: oracle
19
+ host: localhost
20
+ database: TESTDB
21
+ user: TEST_USER
22
+ password: test_pw
23
+ table: TEST1
24
+ mode: insert_direct
25
+ insert_method: oci
26
+ column_options:
27
+ INTEGER_ITEM: {value_type: pass}
28
+ #driver_path: driver/ojdbc7.jar
@@ -1,25 +1,25 @@
1
- in:
2
- type: file
3
- path_prefix: '/data/test1/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: ID, type: string}
12
- - {name: VARCHAR2_ITEM, type: string}
13
- - {name: INTEGER_ITEM, type: long}
14
- - {name: NUMBER_ITEM, type: string}
15
- - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
- - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
- out:
18
- type: oracle
19
- host: localhost
20
- database: TESTDB
21
- user: TEST_USER
22
- password: test_pw
23
- table: TEST1
24
- mode: insert_direct
25
- #driver_path: driver/ojdbc7.jar
1
+ in:
2
+ type: file
3
+ path_prefix: '/data/test1/test1.csv'
4
+ parser:
5
+ charset: UTF-8
6
+ newline: CRLF
7
+ type: csv
8
+ delimiter: ','
9
+ quote: ''
10
+ columns:
11
+ - {name: ID, type: string}
12
+ - {name: VARCHAR2_ITEM, type: string}
13
+ - {name: INTEGER_ITEM, type: long}
14
+ - {name: NUMBER_ITEM, type: string}
15
+ - {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
16
+ - {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
17
+ out:
18
+ type: oracle
19
+ host: localhost
20
+ database: TESTDB
21
+ user: TEST_USER
22
+ password: test_pw
23
+ table: TEST1
24
+ mode: insert_direct
25
+ #driver_path: driver/ojdbc7.jar