embulk-output-oracle 0.2.4 → 0.3.0

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.
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
@@ -1,99 +1,99 @@
1
- package org.embulk.output.oracle.oci;
2
-
3
- import java.nio.ByteBuffer;
4
- import java.nio.charset.Charset;
5
-
6
- public class RowBuffer
7
- {
8
- private final TableDefinition table;
9
- private final int rowCount;
10
- private final byte[] buffer;
11
- private int currentRow = 0;
12
- private int currentColumn = 0;
13
- private int currentPosition = 0;
14
- private final Charset charset;
15
-
16
-
17
- public RowBuffer(TableDefinition table, int rowCount, Charset charset)
18
- {
19
- this.table = table;
20
- this.rowCount = rowCount;
21
- this.charset = charset;
22
-
23
- int rowSize = 0;
24
- for (ColumnDefinition column : table.columns) {
25
- rowSize += column.columnSize;
26
- }
27
-
28
- buffer = new byte[rowSize * rowCount];
29
- }
30
-
31
- public void addValue(int value)
32
- {
33
- if (isFull()) {
34
- throw new IllegalStateException();
35
- }
36
-
37
- buffer[currentPosition] = (byte)value;
38
- buffer[currentPosition + 1] = (byte)(value >> 8);
39
- buffer[currentPosition + 2] = (byte)(value >> 16);
40
- buffer[currentPosition + 3] = (byte)(value >> 24);
41
-
42
- next();
43
- }
44
-
45
- public void addValue(String value)
46
- {
47
- if (isFull()) {
48
- throw new IllegalStateException();
49
- }
50
-
51
- ByteBuffer bytes = charset.encode(value);
52
- int length = bytes.remaining();
53
- // TODO:warning or error if truncated
54
- bytes.get(buffer, currentPosition, length);
55
- if (length < table.columns[currentColumn].columnSize) {
56
- buffer[currentPosition + length] = 0;
57
- }
58
-
59
- next();
60
- }
61
-
62
- private void next()
63
- {
64
- currentPosition += table.columns[currentColumn].columnSize;
65
- currentColumn++;
66
- if (currentColumn == table.columns.length) {
67
- currentColumn = 0;
68
- currentRow++;
69
- }
70
- }
71
-
72
- public byte[] getBuffer()
73
- {
74
- return buffer;
75
- }
76
-
77
- public int getCurrentColumn()
78
- {
79
- return currentColumn;
80
- }
81
-
82
- public int getRowCount()
83
- {
84
- return currentRow;
85
- }
86
-
87
- public boolean isFull()
88
- {
89
- return currentRow >= rowCount;
90
- }
91
-
92
- public void clear()
93
- {
94
- currentPosition = 0;
95
- currentRow = 0;
96
- currentColumn = 0;
97
- }
98
-
99
- }
1
+ package org.embulk.output.oracle.oci;
2
+
3
+ import java.nio.ByteBuffer;
4
+ import java.nio.charset.Charset;
5
+
6
+ public class RowBuffer
7
+ {
8
+ private final TableDefinition table;
9
+ private final int rowCount;
10
+ private final byte[] buffer;
11
+ private int currentRow = 0;
12
+ private int currentColumn = 0;
13
+ private int currentPosition = 0;
14
+ private final Charset charset;
15
+
16
+
17
+ public RowBuffer(TableDefinition table, int rowCount, Charset charset)
18
+ {
19
+ this.table = table;
20
+ this.rowCount = rowCount;
21
+ this.charset = charset;
22
+
23
+ int rowSize = 0;
24
+ for (ColumnDefinition column : table.columns) {
25
+ rowSize += column.columnSize;
26
+ }
27
+
28
+ buffer = new byte[rowSize * rowCount];
29
+ }
30
+
31
+ public void addValue(int value)
32
+ {
33
+ if (isFull()) {
34
+ throw new IllegalStateException();
35
+ }
36
+
37
+ buffer[currentPosition] = (byte)value;
38
+ buffer[currentPosition + 1] = (byte)(value >> 8);
39
+ buffer[currentPosition + 2] = (byte)(value >> 16);
40
+ buffer[currentPosition + 3] = (byte)(value >> 24);
41
+
42
+ next();
43
+ }
44
+
45
+ public void addValue(String value)
46
+ {
47
+ if (isFull()) {
48
+ throw new IllegalStateException();
49
+ }
50
+
51
+ ByteBuffer bytes = charset.encode(value);
52
+ int length = bytes.remaining();
53
+ // TODO:warning or error if truncated
54
+ bytes.get(buffer, currentPosition, length);
55
+ if (length < table.columns[currentColumn].columnSize) {
56
+ buffer[currentPosition + length] = 0;
57
+ }
58
+
59
+ next();
60
+ }
61
+
62
+ private void next()
63
+ {
64
+ currentPosition += table.columns[currentColumn].columnSize;
65
+ currentColumn++;
66
+ if (currentColumn == table.columns.length) {
67
+ currentColumn = 0;
68
+ currentRow++;
69
+ }
70
+ }
71
+
72
+ public byte[] getBuffer()
73
+ {
74
+ return buffer;
75
+ }
76
+
77
+ public int getCurrentColumn()
78
+ {
79
+ return currentColumn;
80
+ }
81
+
82
+ public int getRowCount()
83
+ {
84
+ return currentRow;
85
+ }
86
+
87
+ public boolean isFull()
88
+ {
89
+ return currentRow >= rowCount;
90
+ }
91
+
92
+ public void clear()
93
+ {
94
+ currentPosition = 0;
95
+ currentRow = 0;
96
+ currentColumn = 0;
97
+ }
98
+
99
+ }
@@ -1,24 +1,24 @@
1
- package org.embulk.output.oracle.oci;
2
-
3
- import java.util.List;
4
-
5
- public class TableDefinition
6
- {
7
-
8
- public final String tableName;
9
- public final short charsetId;
10
- public final ColumnDefinition[] columns;
11
-
12
-
13
- public TableDefinition(String tableName, short charsetId, ColumnDefinition... columns)
14
- {
15
- this.tableName = tableName;
16
- this.charsetId = charsetId;
17
- this.columns = columns;
18
- }
19
-
20
- public TableDefinition(String tableName, short charsetId, List<ColumnDefinition> columns)
21
- {
22
- this(tableName, charsetId, columns.toArray(new ColumnDefinition[columns.size()]));
23
- }
24
- }
1
+ package org.embulk.output.oracle.oci;
2
+
3
+ import java.util.List;
4
+
5
+ public class TableDefinition
6
+ {
7
+
8
+ public final String tableName;
9
+ public final short charsetId;
10
+ public final ColumnDefinition[] columns;
11
+
12
+
13
+ public TableDefinition(String tableName, short charsetId, ColumnDefinition... columns)
14
+ {
15
+ this.tableName = tableName;
16
+ this.charsetId = charsetId;
17
+ this.columns = columns;
18
+ }
19
+
20
+ public TableDefinition(String tableName, short charsetId, List<ColumnDefinition> columns)
21
+ {
22
+ this(tableName, charsetId, columns.toArray(new ColumnDefinition[columns.size()]));
23
+ }
24
+ }
@@ -1,69 +1,69 @@
1
- #include <stdio.h>
2
- #include <string.h>
3
- #include <dir-path-load.h>
4
-
5
-
6
- static int test(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *db, const char *user, const char *pass, const char *csvFileName)
7
- {
8
- if (embulk_output_oracle_prepareDirPathCtx(context, db, user, pass)) {
9
- return OCI_ERROR;
10
- }
11
-
12
- EMBULK_OUTPUT_ORACLE_OCI_COL_DEF colDefs[] = {
13
- {"ID", SQLT_INT, 4},
14
- //{"ID", SQLT_CHR, 8},
15
- {"NUM", SQLT_INT, 4},
16
- //{"NUM", SQLT_CHR, 12},
17
- {"VALUE1", SQLT_CHR, 60},
18
- {"VALUE2", SQLT_CHR, 60},
19
- {"VALUE3", SQLT_CHR, 60},
20
- {"VALUE4", SQLT_CHR, 60},
21
- {"VALUE5", SQLT_CHR, 60},
22
- {"VALUE6", SQLT_CHR, 60},
23
- {"VALUE7", SQLT_CHR, 60},
24
- {"VALUE8", SQLT_CHR, 60},
25
- {"VALUE9", SQLT_CHR, 60},
26
- {"VALUE10", SQLT_CHR, 60},
27
- {NULL, 0, 0}
28
- };
29
- if (embulk_output_oracle_prepareDirPathStream(context, "EXAMPLE", 832, colDefs)) {
30
- return OCI_ERROR;
31
- }
32
-
33
- if (embulk_output_oracle_loadCSV(context, colDefs, csvFileName)) {
34
- return OCI_ERROR;
35
- }
36
-
37
- if (embulk_output_oracle_commitDirPath(context)) {
38
- return OCI_ERROR;
39
- }
40
-
41
- return OCI_SUCCESS;
42
- }
43
-
44
-
45
- int main(int argc, char* argv[])
46
- {
47
- sword major_version;
48
- sword minor_version;
49
- sword update_num;
50
- sword patch_num;
51
- sword port_update_num;
52
- OCIClientVersion(&major_version, &minor_version, &update_num, &patch_num, &port_update_num);
53
- printf("OCI client version = %d.%d.%d.%d.%d\r\n", major_version, minor_version, update_num, patch_num, port_update_num);
54
-
55
- if (argc < 5) {
56
- printf("embulk-output-oracle-test <db> <user> <password> <csv file name>\r\n");
57
- return OCI_ERROR;
58
- }
59
-
60
- EMBULK_OUTPUT_ORACLE_OCI_CONTEXT context;
61
- memset(&context, 0, sizeof(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT));
62
- int result = test(&context, argv[1], argv[2], argv[3], argv[4]);
63
- if (result == OCI_ERROR) {
64
- printf("%s\r\n", context.message);
65
- }
66
- embulk_output_oracle_freeDirPathHandles(&context);
67
- return result;
68
- }
69
-
1
+ #include <stdio.h>
2
+ #include <string.h>
3
+ #include <dir-path-load.h>
4
+
5
+
6
+ static int test(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *db, const char *user, const char *pass, const char *csvFileName)
7
+ {
8
+ if (embulk_output_oracle_prepareDirPathCtx(context, db, user, pass)) {
9
+ return OCI_ERROR;
10
+ }
11
+
12
+ EMBULK_OUTPUT_ORACLE_OCI_COL_DEF colDefs[] = {
13
+ {"ID", SQLT_INT, 4},
14
+ //{"ID", SQLT_CHR, 8},
15
+ {"NUM", SQLT_INT, 4},
16
+ //{"NUM", SQLT_CHR, 12},
17
+ {"VALUE1", SQLT_CHR, 60},
18
+ {"VALUE2", SQLT_CHR, 60},
19
+ {"VALUE3", SQLT_CHR, 60},
20
+ {"VALUE4", SQLT_CHR, 60},
21
+ {"VALUE5", SQLT_CHR, 60},
22
+ {"VALUE6", SQLT_CHR, 60},
23
+ {"VALUE7", SQLT_CHR, 60},
24
+ {"VALUE8", SQLT_CHR, 60},
25
+ {"VALUE9", SQLT_CHR, 60},
26
+ {"VALUE10", SQLT_CHR, 60},
27
+ {NULL, 0, 0}
28
+ };
29
+ if (embulk_output_oracle_prepareDirPathStream(context, "EXAMPLE", 832, colDefs)) {
30
+ return OCI_ERROR;
31
+ }
32
+
33
+ if (embulk_output_oracle_loadCSV(context, colDefs, csvFileName)) {
34
+ return OCI_ERROR;
35
+ }
36
+
37
+ if (embulk_output_oracle_commitDirPath(context)) {
38
+ return OCI_ERROR;
39
+ }
40
+
41
+ return OCI_SUCCESS;
42
+ }
43
+
44
+
45
+ int main(int argc, char* argv[])
46
+ {
47
+ sword major_version;
48
+ sword minor_version;
49
+ sword update_num;
50
+ sword patch_num;
51
+ sword port_update_num;
52
+ OCIClientVersion(&major_version, &minor_version, &update_num, &patch_num, &port_update_num);
53
+ printf("OCI client version = %d.%d.%d.%d.%d\r\n", major_version, minor_version, update_num, patch_num, port_update_num);
54
+
55
+ if (argc < 5) {
56
+ printf("embulk-output-oracle-test <db> <user> <password> <csv file name>\r\n");
57
+ return OCI_ERROR;
58
+ }
59
+
60
+ EMBULK_OUTPUT_ORACLE_OCI_CONTEXT context;
61
+ memset(&context, 0, sizeof(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT));
62
+ int result = test(&context, argv[1], argv[2], argv[3], argv[4]);
63
+ if (result == OCI_ERROR) {
64
+ printf("%s\r\n", context.message);
65
+ }
66
+ embulk_output_oracle_freeDirPathHandles(&context);
67
+ return result;
68
+ }
69
+
@@ -1,19 +1,19 @@
1
- # gcc, g++ and Oracle Instant Client SDK are requred.
2
- #
3
- # ln libocci.so.x.x libocci.so
4
- # ln libclntsh.so.x.x libclntsh.so
5
- #
6
-
7
- if [ "$JAVA_HOME" = "" ]
8
- then
9
- echo "You should set the environment variable 'JAVA_HOME'."
10
- exit 1
11
- fi
12
-
13
- if [ "$OCI_PATH" = "" ]
14
- then
15
- echo "You should set the environment variable 'OCI_PATH'."
16
- exit 1
17
- fi
18
-
19
- gcc -I. -I"$JAVA_HOME/include" -I"$OCI_PATH/sdk/include" -I../../../main/cpp/common -L"$OCI_PATH" ../common/embulk-output-oracle-test.cpp ../../../main/cpp/common/embulk-output-oracle.cpp ../../../main/cpp/common/dir-path-load.cpp -locci -lclntsh -lstdc++ -o embulk-output-oracle-test
1
+ # gcc, g++ and Oracle Instant Client SDK are requred.
2
+ #
3
+ # ln libocci.so.x.x libocci.so
4
+ # ln libclntsh.so.x.x libclntsh.so
5
+ #
6
+
7
+ if [ "$JAVA_HOME" = "" ]
8
+ then
9
+ echo "You should set the environment variable 'JAVA_HOME'."
10
+ exit 1
11
+ fi
12
+
13
+ if [ "$OCI_PATH" = "" ]
14
+ then
15
+ echo "You should set the environment variable 'OCI_PATH'."
16
+ exit 1
17
+ fi
18
+
19
+ gcc -I. -I"$JAVA_HOME/include" -I"$OCI_PATH/sdk/include" -I../../../main/cpp/common -L"$OCI_PATH" ../common/embulk-output-oracle-test.cpp ../../../main/cpp/common/embulk-output-oracle.cpp ../../../main/cpp/common/dir-path-load.cpp -locci -lclntsh -lstdc++ -o embulk-output-oracle-test
@@ -1,29 +1,29 @@
1
- @ECHO OFF
2
-
3
- REM You should set the environment variable 'PATH' to CL.exe(x86_amd64) of Visual Studio.
4
-
5
- IF "%JAVA_HOME%" == "" (
6
- ECHO "You should set the environment variable 'JAVA_HOME'."
7
- EXIT /B 1
8
- )
9
-
10
-
11
- IF "%OCI_SDK_PATH%" == "" (
12
- ECHO "You should set the environment variable 'OCI_SDK_PATH'."
13
- EXIT /B 1
14
- )
15
-
16
- IF "%MSVC_PATH%" == "" (
17
- ECHO "You should set the environment variable 'MSVC_PATH'."
18
- ECHO "For example : SET MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"
19
- EXIT /B 1
20
- )
21
-
22
- IF "%MSSDK_PATH%" == "" (
23
- ECHO "You should set the environment variable 'MSSDK_PATH'."
24
- ECHO "For example : SET MSSDK_PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A"
25
- EXIT /B 1
26
- )
27
-
28
-
1
+ @ECHO OFF
2
+
3
+ REM You should set the environment variable 'PATH' to CL.exe(x86_amd64) of Visual Studio.
4
+
5
+ IF "%JAVA_HOME%" == "" (
6
+ ECHO "You should set the environment variable 'JAVA_HOME'."
7
+ EXIT /B 1
8
+ )
9
+
10
+
11
+ IF "%OCI_SDK_PATH%" == "" (
12
+ ECHO "You should set the environment variable 'OCI_SDK_PATH'."
13
+ EXIT /B 1
14
+ )
15
+
16
+ IF "%MSVC_PATH%" == "" (
17
+ ECHO "You should set the environment variable 'MSVC_PATH'."
18
+ ECHO "For example : SET MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"
19
+ EXIT /B 1
20
+ )
21
+
22
+ IF "%MSSDK_PATH%" == "" (
23
+ ECHO "You should set the environment variable 'MSSDK_PATH'."
24
+ ECHO "For example : SET MSSDK_PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A"
25
+ EXIT /B 1
26
+ )
27
+
28
+
29
29
  CL /I"..\..\..\main\cpp\common" /I"%MSSDK_PATH%\Include" /I"%MSVC_PATH%\include" /I"%OCI_SDK_PATH%\include" /I"%JAVA_HOME%\include" /I"%JAVA_HOME%\include\win32" /Zi /nologo /W3 /WX- /O2 /Oi /GL /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "EMBULKOUTPUTORACLE_EXPORTS" /D "_WINDLL" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:queue ..\common\embulk-output-oracle-test.cpp ..\..\..\main\cpp\common\dir-path-load.cpp /link /LIBPATH:"%MSVC_PATH%\lib\amd64" /LIBPATH:"%MSSDK_PATH%\Lib\x64" /LIBPATH:"%OCI_SDK_PATH%\lib\msvc" /INCREMENTAL:NO /NOLOGO /LIBPATH:"C:\Oracle\instantclient_12_1\x64\sdk\lib\msvc" "oci.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /ALLOWISOLATION /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ERRORREPORT:QUEUE