embulk-output-oracle 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +155 -110
  3. data/build.gradle +6 -6
  4. data/classpath/embulk-output-jdbc-0.3.0.jar +0 -0
  5. data/classpath/embulk-output-oracle-0.3.0.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 +22 -66
  17. data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +289 -289
  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 -19
  20. data/src/main/java/org/embulk/output/oracle/OracleOutputConnection.java +165 -134
  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 +99 -99
  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 +187 -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/ChildFirstClassLoader.java +42 -42
  37. data/src/test/java/org/embulk/output/oracle/EmbulkPluginTester.java +120 -120
  38. data/src/test/java/org/embulk/output/oracle/EmptyConfigSource.java +100 -100
  39. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java +172 -161
  40. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java +445 -413
  41. data/src/test/java/org/embulk/output/oracle/TimestampFormatTest.java +57 -57
  42. data/src/test/resources/data/test1/test1.csv +3 -3
  43. data/src/test/resources/yml/test-insert-direct.yml +26 -26
  44. data/src/test/resources/yml/test-insert-oci-split.yml +26 -26
  45. data/src/test/resources/yml/test-insert-oci.yml +26 -26
  46. data/src/test/resources/yml/test-insert.yml +25 -25
  47. data/src/test/resources/yml/test-replace-long-name-multibyte.yml +25 -0
  48. data/src/test/resources/yml/test-replace-long-name.yml +25 -25
  49. data/src/test/resources/yml/test-replace.yml +25 -25
  50. data/src/test/resources/yml/test-string-timestamp.yml +25 -0
  51. data/src/test/resources/yml/test-url.yml +24 -24
  52. metadata +6 -5
  53. data/classpath/embulk-output-jdbc-0.2.4.jar +0 -0
  54. data/classpath/embulk-output-oracle-0.2.4.jar +0 -0
  55. data/src/main/java/org/embulk/output/oracle/setter/OracleColumnSetterFactory.java +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a7cad3add47cddbc5128dc4f5d72173f2fe5ad3
4
- data.tar.gz: 73a1a3548254ddda090c7261bca4a5ab51bfff54
3
+ metadata.gz: 216d1163436a4fe62fe244ab857d45e454a86213
4
+ data.tar.gz: 95dc5c8ef7de58c37f00973a03ef8d4ca8d059c7
5
5
  SHA512:
6
- metadata.gz: ffce5efa888d957bf96d71654afa0abc9952fd04945d5dfc4cb4d10b09faaa55ca2ed0b8c81973330eab4f1f0309bee61f731183d22331d0680abd6a7072bfba
7
- data.tar.gz: 9ec7a37715a78d391ba6979103cb3d441a11b95d7ea4bcfcef28f0e6307b237737af41161cce44aea9bd150f6163f7a7eb230231d08e03c0813e716765ea9153
6
+ metadata.gz: bacf819a6d2f2c60dd957310bd03558f4212f24f829301576dd7b50b3ca780e2ad32612b5b76eb4459c8950dbe44bc22875cf6a033c6a6ba74faee280f3d261d
7
+ data.tar.gz: e1dc2c39559cde175cdbc217b0076b71a759bc5bdaef09429146f783a2497a95d81f2df9de67c6ced280695ed0906a38d5e759bc00a9ea2a1560229f0e1b2039
data/README.md CHANGED
@@ -1,110 +1,155 @@
1
- # Oracle output plugins for Embulk
2
-
3
- Oracle output plugins for Embulk loads records to Oracle.
4
-
5
- ## Overview
6
-
7
- * **Plugin type**: output
8
- * **Load all or nothing**: depends on the mode:
9
- * **insert**: no
10
- * **replace**: yes
11
- * **Resume supported**: no
12
-
13
- ## Configuration
14
-
15
- - **driver_path**: path to the jar file of the Oracle JDBC driver (string)
16
- - **host**: database host name (string, required if url is not set or insert_method is "oci")
17
- - **port**: database port number (integer, default: 1521)
18
- - **user**: database login user name (string, required)
19
- - **password**: database login password (string, default: "")
20
- - **database**: destination database name (string, required if url is not set or insert_method is "oci")
21
- - **url**: URL of the JDBC connection (string, optional)
22
- - **table**: destination table name (string, required)
23
- - **mode**: "replace" or "insert" (string, required)
24
- - **insert_method**: see below
25
- - **batch_size**: size of a single batch insert (integer, default: 16777216)
26
- - **options**: extra connection properties (hash, default: {})
27
-
28
- insert_method supports three options.
29
-
30
- "normal" means normal insert (default). It requires Oracle JDBC driver.
31
-
32
- "direct" means direct path insert. It is faster than 'normal.
33
- It requires Oracle JDBC driver too, but the version 12 driver doesn't work (the version 11 driver works).
34
-
35
- "oci" means direct path insert using OCI(Oracle Call Interface). It is fastest.
36
- It requires both Oracle JDBC driver and Oracle Instant Client (version 12.1.0.2.0).
37
- You must set the library loading path to the OCI library.
38
-
39
- If you use "oci", platform dependent library written in cpp is required.
40
- Windows(x64) library and Linux(x64) are bundled, but others are not bundled.
41
- You should build by yourself and set the library loading path to it.
42
-
43
-
44
- ### Example
45
-
46
- ```yaml
47
- out:
48
- type: oracle
49
- driver_path: /opt/oracle/ojdbc6.jar
50
- host: localhost
51
- user: root
52
- password: ""
53
- database: my_database
54
- table: my_table
55
- mode: insert
56
- insert_method: direct
57
- ```
58
-
59
- ### Build
60
-
61
- ```
62
- $ ./gradlew gem
63
- ```
64
-
65
- #### Build environment for native library
66
-
67
- For Windows (x64)
68
-
69
- (1) Install JDK.
70
-
71
- (2) Install Microsoft Visual Studio (only 2010 is tested).
72
-
73
- (3) Install Oracle Instant Client SDK 11.1.0.6.0 for Microsoft Windows (x64).
74
-
75
- (4) Set environment variables.
76
-
77
- * JAVA_HOME
78
- * OCI\_SDK_PATH ("sdk" directory of Oracle Instant Client)
79
-
80
- (5) Open src/main/cpp/win/embulk-output-oracle.sln by Visual Studio and build.
81
-
82
- For Windows command line, the following are needed in addition to (1) - (4).
83
-
84
- (6) Set environment variables.
85
-
86
- * MSVC_PATH (ex. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC)
87
- * MSSDK_PATH (ex. C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A)
88
-
89
- (7) Execute src/main/cpp/win/build.bat .
90
-
91
-
92
- For Linux (x64) (only Ubuntu Server 14.04 is tested)
93
-
94
- (1) Install JDK.
95
-
96
- (2) Install gcc and g++ .
97
-
98
- (3) Install Oracle Instant Client Basic and SDK 11.1.0.6.0 for Linux (x64).
99
-
100
- (4) Create symbolic links of OCI libraries.
101
-
102
- ln -s libocci.so.11.1 libocci.so
103
- ln -s libclntsh.so.11.1 libclntsh.so
104
-
105
- (5) Set environment variables.
106
-
107
- * JAVA_HOME
108
- * OCI_PATH (the directory of Oracle Instant Client Basic and the parent of the "sdk" directory)
109
-
110
- (6) Execute src/main/cpp/linux/build.sh .
1
+ # Oracle output plugins for Embulk
2
+
3
+ Oracle output plugins for Embulk loads records to Oracle.
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: output
8
+ * **Load all or nothing**: depnds on the mode. see bellow.
9
+ * **Resume supported**: depnds on the mode. see bellow.
10
+
11
+ ## Configuration
12
+
13
+ - **driver_path**: path to the jar file of the Oracle JDBC driver (string)
14
+ - **host**: database host name (string, required if url is not set or insert_method is "oci")
15
+ - **port**: database port number (integer, default: 1521)
16
+ - **user**: database login user name (string, required)
17
+ - **password**: database login password (string, default: "")
18
+ - **database**: destination database name (string, required if url is not set or insert_method is "oci")
19
+ - **url**: URL of the JDBC connection (string, optional)
20
+ - **table**: destination table name (string, required)
21
+ - **options**: extra connection properties (hash, default: {})
22
+ - **mode**: "insert", "insert_direct", "truncate_insert", or "replace". See bellow. (string, required)
23
+ - **insert_method**: see below
24
+ - **batch_size**: size of a single batch insert (integer, default: 16777216)
25
+ - **default_timezone**: If input column type (embulk type) is timestamp and destination column type is `string` or `nstring`, this plugin needs to format the timestamp into a string. This default_timezone option is used to control the timezone. You can overwrite timezone for each columns using column_options option. (string, default: `UTC`)
26
+ - **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
27
+ - **type**: type of a column when this plugin creates new tables (e.g. `VARCHAR(255)`, `INTEGER NOT NULL UNIQUE`). This used when this plugin creates intermediate tables (insert, truncate_insert and merge modes), when it creates the target table (insert_direct and replace modes), and when it creates nonexistent target table automatically. (string, default: depends on input column type. `BIGINT` if input column type is long, `BOOLEAN` if boolean, `DOUBLE PRECISION` if double, `CLOB` if string, `TIMESTAMP` if timestamp)
28
+ - **value_type**: This plugin converts input column type (embulk type) into a database type to build a INSERT statement. This value_type option controls the type of the value in a INSERT statement. (string, default: depends on input column type. Available values options are: `byte`, `short`, `int`, `long`, `double`, `float`, `boolean`, `string`, `nstring`, `date`, `time`, `timestamp`, `decimal`, `null`, `pass`)
29
+ - **timestamp_format**: If input column type (embulk type) is timestamp and value_type is `string` or `nstring`, this plugin needs to format the timestamp value into a string. This timestamp_format option is used to control the format of the timestamp. (string, default: `%Y-%m-%d %H:%M:%S.%6N`)
30
+ - **timezone**: If input column type (embulk type) is timestamp and value_type is `string` or `nstring`, this plugin needs to format the timestamp value into a string. And if the input column type is timestamp and value_type is `date`, this plugin needs to consider timezone. In those cases, this timezone option is used to control the timezone. (string, value of default_timezone option is used by default)
31
+
32
+ ### Modes
33
+
34
+ * **insert**:
35
+ * Behavior: This mode writes rows to some intermediate tables first. If all those tasks run correctly, runs `INSERT INTO <target_table> SELECT * FROM <intermediate_table_1> UNION ALL SELECT * FROM <intermediate_table_2> UNION ALL ...` query.
36
+ * Transactional: Yes. This mode successfully writes all rows, or fails with writing zero rows.
37
+ * Resumable: Yes.
38
+ * **insert_direct**:
39
+ * Behavior: This mode inserts rows to the target table directly.
40
+ * Transactional: No. If fails, the target table could have some rows inserted.
41
+ * Resumable: No.
42
+ * **truncate_insert**:
43
+ * Behavior: Same with `insert` mode excepting that it truncates the target table right before the last `INSERT ...` query.
44
+ * Transactional: Yes.
45
+ * Resumable: Yes.
46
+ * **replace**:
47
+ * Behavior: Same with `insert` mode excepting that it truncates the target table right before the last `INSERT ...` query.
48
+ * Transactional: Yes.
49
+ * Resumable: No.
50
+
51
+ ### Insert modes
52
+
53
+ insert_method supports three options.
54
+
55
+ "normal" means normal insert (default). It requires Oracle JDBC driver.
56
+
57
+ "direct" means direct path insert. It is faster than 'normal.
58
+ It requires Oracle JDBC driver too, but the version 12 driver doesn't work (the version 11 driver works).
59
+
60
+ "oci" means direct path insert using OCI(Oracle Call Interface). It is fastest.
61
+ It requires both Oracle JDBC driver and Oracle Instant Client (version 12.1.0.2.0).
62
+ You must set the library loading path to the OCI library.
63
+
64
+ If you use "oci", platform dependent library written in cpp is required.
65
+ Windows(x64) library and Linux(x64) are bundled, but others are not bundled.
66
+ You should build by yourself and set the library loading path to it.
67
+
68
+ ### Example
69
+
70
+ ```yaml
71
+ out:
72
+ type: oracle
73
+ driver_path: /opt/oracle/ojdbc6.jar
74
+ host: localhost
75
+ user: root
76
+ password: ""
77
+ database: my_database
78
+ table: my_table
79
+ mode: insert
80
+ insert_method: direct
81
+ ```
82
+
83
+ Advanced configuration:
84
+
85
+ ```yaml
86
+ out:
87
+ type: oracle
88
+ driver_path: /opt/oracle/ojdbc6.jar
89
+ host: localhost
90
+ user: root
91
+ password: ""
92
+ database: my_database
93
+ table: my_table
94
+ options: {LoginTimeout: 20000}
95
+ mode: insert_direct
96
+ insert_method: direct
97
+ column_options:
98
+ my_col_1: {type: 'VARCHAR(255)'}
99
+ my_col_3: {type: 'INT NOT NULL'}
100
+ my_col_4: {value_type: string, timestamp_format: `%Y-%m-%d %H:%M:%S %z`, timezone: '-0700'}
101
+ my_col_5: {type: 'DECIMAL(18,9)', value_type: pass}
102
+ ```
103
+
104
+ ### Build
105
+
106
+ ```
107
+ $ ./gradlew gem
108
+ ```
109
+
110
+ #### Build environment for native library
111
+
112
+ For Windows (x64)
113
+
114
+ (1) Install JDK.
115
+
116
+ (2) Install Microsoft Visual Studio (only 2010 is tested).
117
+
118
+ (3) Install Oracle Instant Client SDK 11.1.0.6.0 for Microsoft Windows (x64).
119
+
120
+ (4) Set environment variables.
121
+
122
+ * JAVA_HOME
123
+ * OCI\_SDK_PATH ("sdk" directory of Oracle Instant Client)
124
+
125
+ (5) Open src/main/cpp/win/embulk-output-oracle.sln by Visual Studio and build.
126
+
127
+ For Windows command line, the following are needed in addition to (1) - (4).
128
+
129
+ (6) Set environment variables.
130
+
131
+ * MSVC_PATH (ex. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC)
132
+ * MSSDK_PATH (ex. C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A)
133
+
134
+ (7) Execute src/main/cpp/win/build.bat .
135
+
136
+
137
+ For Linux (x64) (only Ubuntu Server 14.04 is tested)
138
+
139
+ (1) Install JDK.
140
+
141
+ (2) Install gcc and g++ .
142
+
143
+ (3) Install Oracle Instant Client Basic and SDK 11.1.0.6.0 for Linux (x64).
144
+
145
+ (4) Create symbolic links of OCI libraries.
146
+
147
+ ln -s libocci.so.11.1 libocci.so
148
+ ln -s libclntsh.so.11.1 libclntsh.so
149
+
150
+ (5) Set environment variables.
151
+
152
+ * JAVA_HOME
153
+ * OCI_PATH (the directory of Oracle Instant Client Basic and the parent of the "sdk" directory)
154
+
155
+ (6) Execute src/main/cpp/linux/build.sh .
data/build.gradle CHANGED
@@ -1,6 +1,6 @@
1
- [compileTestJava]*.options*.encoding = 'UTF-8'
2
-
3
- dependencies {
4
- compile project(':embulk-output-jdbc')
5
- testCompile 'org.embulk:embulk-standards:0.5.5'
6
- }
1
+ [compileTestJava]*.options*.encoding = 'UTF-8'
2
+
3
+ dependencies {
4
+ compile project(':embulk-output-jdbc')
5
+ testCompile 'org.embulk:embulk-standards:0.5.5'
6
+ }
@@ -1,3 +1,3 @@
1
- Embulk::JavaPlugin.register_output(
2
- :oracle, "org.embulk.output.OracleOutputPlugin",
3
- File.expand_path('../../../../classpath', __FILE__))
1
+ Embulk::JavaPlugin.register_output(
2
+ :oracle, "org.embulk.output.OracleOutputPlugin",
3
+ File.expand_path('../../../../classpath', __FILE__))