embulk-output-oracle 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -0
  3. data/build.gradle +2 -2
  4. data/classpath/{embulk-output-jdbc-0.6.3.jar → embulk-output-jdbc-0.6.4.jar} +0 -0
  5. data/classpath/embulk-output-oracle-0.6.4.jar +0 -0
  6. data/lib/embulk/native/x86_64-linux/libembulk-output-oracle-oci.so +0 -0
  7. data/lib/embulk/native/x86_64-windows/embulk-output-oracle-oci.dll +0 -0
  8. data/src/main/cpp/common/embulk-output-oracle-oci.cpp +27 -0
  9. data/src/main/cpp/linux/build.sh +15 -0
  10. data/src/main/cpp/windows/build.bat +26 -0
  11. data/src/main/cpp/windows/dllmain.cpp +25 -0
  12. data/src/main/cpp/windows/embulk-output-oracle-oci.sln +20 -0
  13. data/src/main/cpp/windows/embulk-output-oracle-oci.vcxproj +171 -0
  14. data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +5 -39
  15. data/src/main/java/org/embulk/output/oracle/oci/BulkOCI.java +15 -0
  16. data/src/main/java/org/embulk/output/oracle/oci/OCI.java +1 -0
  17. data/src/main/java/org/embulk/output/oracle/oci/OCIManager.java +3 -2
  18. data/src/main/java/org/embulk/output/oracle/oci/OCIWrapper.java +103 -37
  19. data/src/main/java/org/embulk/output/oracle/oci/PrimitiveBulkOCI.java +47 -0
  20. data/src/main/java/org/embulk/output/oracle/oci/RowBuffer.java +50 -46
  21. data/src/main/java/org/embulk/output/oracle/oci/TableDefinition.java +9 -0
  22. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java +622 -133
  23. data/src/test/resources/oracle/data/test3/test3.csv +9999 -0
  24. data/src/test/resources/oracle/yml/test-insert-direct-oci-method-large.yml +29 -0
  25. metadata +19 -8
  26. data/classpath/embulk-output-oracle-0.6.3.jar +0 -0
  27. data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java +0 -620
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f9b6c624d5915f9d678ef5c41114f9357fb4775
4
- data.tar.gz: efd8caf50fdec1903b18bd25f8b688bdad7b464d
3
+ metadata.gz: 1074dcbca44c9b5e6cc3d80da2eea5b40538bb28
4
+ data.tar.gz: e560931b3c0dcb3851b4b330d06ed0a01103b34a
5
5
  SHA512:
6
- metadata.gz: 017964eef4b7809462040ce187e11faaf067fdb0a3e21e26f8c365e13f3a47723ec545f60b4893048727c482d7855c6ee20dabf2abb320127e020ccd38355970
7
- data.tar.gz: c3875ea7746f2f5fc4368dabf98e72bc239b8333b8b0caafbf770f512170ebd88daa9e267c60b96b97b89c1bead2f7983eff7121f48743ba9a5abd828fcae77d
6
+ metadata.gz: 919fc3fc46e0ded5c4e0983459659bde509898506f546932b4b5029fe45ef617279ed0895b24e7352936574090f2097ba1cc2d9dc2dbc4a05d6a98a58b1d65a4
7
+ data.tar.gz: 1ab155c13bf488e439f3951b31d257f75ee226d1f4b1352212147107d835cf270a8f2859fd8cd09269f88e16798929898d26a4a0af1eb5a87df3191a9a45a31f
data/README.md CHANGED
@@ -63,6 +63,9 @@ It requires Oracle JDBC driver too, but the version 12 driver doesn't work (the
63
63
  "oci" means direct path insert using OCI(Oracle Call Interface). It is fastest.
64
64
  It requires both Oracle JDBC driver and Oracle Instant Client (version 12.1.0.2.0).
65
65
  You must set the library loading path to the OCI library.
66
+ And it uses an optional native library (embulk-output-oracle-oci) written in cpp to improve performance furthermore.
67
+ Not only the source codes of the library, but also the built libraries for Windows(x64) and Linux(x64) have bean committed.
68
+
66
69
 
67
70
  ### Supported types
68
71
 
@@ -123,6 +126,46 @@ out:
123
126
  $ ./gradlew gem
124
127
  ```
125
128
 
129
+ #### Build environment for native library
130
+
131
+ For Windows (x64)
132
+
133
+ (1) Install Microsoft Visual Studio (only 2010 is tested).
134
+
135
+ (2) Install Oracle Instant Client SDK 11.1.0.6.0 for Microsoft Windows (x64).
136
+
137
+ (3) Set environment variables.
138
+
139
+ * OCI\_SDK_PATH ("sdk" directory of Oracle Instant Client)
140
+
141
+ (4) Open src/main/cpp/win/embulk-output-oracle-oci.sln by Visual Studio and build.
142
+
143
+ For Windows command line, the following are needed in addition to (1) - (4).
144
+
145
+ (5) Set environment variables.
146
+
147
+ * MSVC_PATH (ex. C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC)
148
+ * MSSDK_PATH (ex. C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A)
149
+
150
+ (6) Execute src/main/cpp/win/build.bat .
151
+
152
+
153
+ For Linux (x64) (only Ubuntu Server 14.04 is tested)
154
+
155
+ (1) Install gcc and g++ .
156
+
157
+ (2) Install Oracle Instant Client Basic and SDK 11.1.0.6.0 for Linux (x64).
158
+
159
+ (3) Create symbolic links of OCI libraries.
160
+
161
+ ln -s libocci.so.11.1 libocci.so
162
+ ln -s libclntsh.so.11.1 libclntsh.so
163
+
164
+ (4) Set environment variables.
165
+
166
+ * OCI_PATH (the directory of Oracle Instant Client Basic and the parent of the "sdk" directory)
167
+
168
+ (5) Execute src/main/cpp/linux/build.sh .
126
169
 
127
170
  ***
128
171
  <img src="https://www.yourkit.com/images/yklogo.png" alt="YourKit"/> is used to improve performance of embulk-output-oracle.
data/build.gradle CHANGED
@@ -1,7 +1,7 @@
1
- [compileTestJava]*.options*.encoding = 'UTF-8'
2
-
3
1
  dependencies {
4
2
  compile project(':embulk-output-jdbc')
3
+
5
4
  testCompile 'org.embulk:embulk-standards:0.8.8'
6
5
  testCompile files('../embulk-output-jdbc/build/classes/test/')
6
+ testCompile files('driver/ojdbc7.jar')
7
7
  }
@@ -0,0 +1,27 @@
1
+ #include <occi.h>
2
+
3
+
4
+ extern "C"
5
+ #ifdef WIN32
6
+ __declspec(dllexport)
7
+ #endif
8
+ sword embulk_output_oracle_OCIDirPathColArrayEntriesSet(
9
+ OCIDirPathColArray *dpca,
10
+ OCIError *errhp,
11
+ ub2 columnCount,
12
+ ub4 rowCount,
13
+ ub1* data,
14
+ ub2* sizes)
15
+ {
16
+ for (ub4 row = 0; row < rowCount; row++) {
17
+ for (ub2 column = 0; column < columnCount; column++) {
18
+ ub2 size = *sizes++;
19
+ sword result = OCIDirPathColArrayEntrySet(dpca, errhp, row, column, data, size, OCI_DIRPATH_COL_COMPLETE);
20
+ if (result != OCI_SUCCESS) {
21
+ return result;
22
+ }
23
+ data += size;
24
+ }
25
+ }
26
+ return OCI_SUCCESS;
27
+ }
@@ -0,0 +1,15 @@
1
+ # gcc, g++ and Oracle Instant Client Basic and SDK are requred.
2
+ #
3
+ # ln libocci.so.x.x libocci.so
4
+ # ln libclntsh.so.x.x libclntsh.so
5
+ #
6
+
7
+ if [ "$OCI_PATH" = "" ]
8
+ then
9
+ echo "You should set the environment variable 'OCI_PATH'."
10
+ exit 1
11
+ fi
12
+
13
+ mkdir -p ../../../../lib/embulk/native/x86_64-linux
14
+
15
+ gcc -fPIC -I. -I"$OCI_PATH/sdk/include" -I../../../main/cpp/common -L"$OCI_PATH" -shared ../../../main/cpp/common/embulk-output-oracle-oci.cpp -locci -lclntsh -lstdc++ -o ../../../../lib/embulk/native/x86_64-linux/libembulk-output-oracle-oci.so
@@ -0,0 +1,26 @@
1
+ @ECHO OFF
2
+
3
+ REM Visual Studio and Oracle Instant Client SDK are requred.
4
+ REM You should set the environment variable 'PATH' to CL.exe(x86_amd64) of Visual Studio.
5
+
6
+ IF "%OCI_SDK_PATH%" == "" (
7
+ ECHO "You should set the environment variable 'OCI_SDK_PATH'."
8
+ EXIT /B 1
9
+ )
10
+
11
+ IF "%MSVC_PATH%" == "" (
12
+ ECHO "You should set the environment variable 'MSVC_PATH'."
13
+ ECHO "For example : SET MSVC_PATH=C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"
14
+ EXIT /B 1
15
+ )
16
+
17
+ IF "%MSSDK_PATH%" == "" (
18
+ ECHO "You should set the environment variable 'MSSDK_PATH'."
19
+ ECHO "For example : SET MSSDK_PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A"
20
+ EXIT /B 1
21
+ )
22
+
23
+
24
+ MKDIR ..\..\..\..\lib\embulk\native\x86_64-windows
25
+
26
+ CL /I"%MSSDK_PATH%\Include" /I"%MSVC_PATH%\include" /I"%OCI_SDK_PATH%\include" /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-oci.cpp dllmain.cpp /link /LIBPATH:"%MSVC_PATH%\lib\amd64" /LIBPATH:"%MSSDK_PATH%\Lib\x64" /LIBPATH:"%OCI_SDK_PATH%\lib\msvc" /INCREMENTAL:NO /NOLOGO /LIBPATH:"%OCI_SDK_PATH%\lib\msvc" /OUT:"..\..\..\..\lib\embulk\native\x86_64-windows\embulk-output-oracle-oci.dll" /DLL "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" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X64 /ERRORREPORT:QUEUE
@@ -0,0 +1,25 @@
1
+ #pragma once
2
+
3
+ #include <SDKDDKVer.h>
4
+
5
+ #define WIN32_LEAN_AND_MEAN
6
+
7
+ #include <windows.h>
8
+
9
+
10
+ BOOL APIENTRY DllMain( HMODULE hModule,
11
+ DWORD ul_reason_for_call,
12
+ LPVOID lpReserved
13
+ )
14
+ {
15
+ switch (ul_reason_for_call)
16
+ {
17
+ case DLL_PROCESS_ATTACH:
18
+ case DLL_THREAD_ATTACH:
19
+ case DLL_THREAD_DETACH:
20
+ case DLL_PROCESS_DETACH:
21
+ break;
22
+ }
23
+ return TRUE;
24
+ }
25
+
@@ -0,0 +1,20 @@
1
+ 
2
+ Microsoft Visual Studio Solution File, Format Version 11.00
3
+ # Visual Studio 2010
4
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "embulk-output-oracle-oci", "embulk-output-oracle-oci.vcxproj", "{2284D821-588E-419F-8790-F5BCC12F93BD}"
5
+ EndProject
6
+ Global
7
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
8
+ Debug|x64 = Debug|x64
9
+ Release|x64 = Release|x64
10
+ EndGlobalSection
11
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
12
+ {2284D821-588E-419F-8790-F5BCC12F93BD}.Debug|x64.ActiveCfg = Debug|x64
13
+ {2284D821-588E-419F-8790-F5BCC12F93BD}.Debug|x64.Build.0 = Debug|x64
14
+ {2284D821-588E-419F-8790-F5BCC12F93BD}.Release|x64.ActiveCfg = Release|x64
15
+ {2284D821-588E-419F-8790-F5BCC12F93BD}.Release|x64.Build.0 = Release|x64
16
+ EndGlobalSection
17
+ GlobalSection(SolutionProperties) = preSolution
18
+ HideSolutionNode = FALSE
19
+ EndGlobalSection
20
+ EndGlobal
@@ -0,0 +1,171 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ItemGroup Label="ProjectConfigurations">
4
+ <ProjectConfiguration Include="Debug|Win32">
5
+ <Configuration>Debug</Configuration>
6
+ <Platform>Win32</Platform>
7
+ </ProjectConfiguration>
8
+ <ProjectConfiguration Include="Debug|x64">
9
+ <Configuration>Debug</Configuration>
10
+ <Platform>x64</Platform>
11
+ </ProjectConfiguration>
12
+ <ProjectConfiguration Include="Release|Win32">
13
+ <Configuration>Release</Configuration>
14
+ <Platform>Win32</Platform>
15
+ </ProjectConfiguration>
16
+ <ProjectConfiguration Include="Release|x64">
17
+ <Configuration>Release</Configuration>
18
+ <Platform>x64</Platform>
19
+ </ProjectConfiguration>
20
+ </ItemGroup>
21
+ <PropertyGroup Label="Globals">
22
+ <ProjectGuid>{2284D821-588E-419F-8790-F5BCC12F93BD}</ProjectGuid>
23
+ <Keyword>Win32Proj</Keyword>
24
+ <RootNamespace>embulkoutputoracle</RootNamespace>
25
+ <ProjectName>embulk-output-oracle-oci</ProjectName>
26
+ </PropertyGroup>
27
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
30
+ <UseDebugLibraries>true</UseDebugLibraries>
31
+ <CharacterSet>Unicode</CharacterSet>
32
+ </PropertyGroup>
33
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
34
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
35
+ <UseDebugLibraries>true</UseDebugLibraries>
36
+ <CharacterSet>Unicode</CharacterSet>
37
+ </PropertyGroup>
38
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
39
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
40
+ <UseDebugLibraries>false</UseDebugLibraries>
41
+ <WholeProgramOptimization>true</WholeProgramOptimization>
42
+ <CharacterSet>Unicode</CharacterSet>
43
+ </PropertyGroup>
44
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
45
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
46
+ <UseDebugLibraries>false</UseDebugLibraries>
47
+ <WholeProgramOptimization>true</WholeProgramOptimization>
48
+ <CharacterSet>Unicode</CharacterSet>
49
+ </PropertyGroup>
50
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
51
+ <ImportGroup Label="ExtensionSettings">
52
+ </ImportGroup>
53
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
54
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
55
+ </ImportGroup>
56
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
57
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
58
+ </ImportGroup>
59
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
60
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61
+ </ImportGroup>
62
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
63
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64
+ </ImportGroup>
65
+ <PropertyGroup Label="UserMacros" />
66
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
67
+ <LinkIncremental>true</LinkIncremental>
68
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
69
+ </PropertyGroup>
70
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
71
+ <LinkIncremental>true</LinkIncremental>
72
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
73
+ </PropertyGroup>
74
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
75
+ <LinkIncremental>false</LinkIncremental>
76
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
77
+ </PropertyGroup>
78
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
79
+ <LinkIncremental>false</LinkIncremental>
80
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
81
+ </PropertyGroup>
82
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
83
+ <ClCompile>
84
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
85
+ <WarningLevel>Level3</WarningLevel>
86
+ <Optimization>Disabled</Optimization>
87
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;EMBULKOUTPUTORACLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
88
+ <AdditionalIncludeDirectories>$(OCI_SDK_PATH)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
89
+ </ClCompile>
90
+ <Link>
91
+ <SubSystem>Windows</SubSystem>
92
+ <GenerateDebugInformation>true</GenerateDebugInformation>
93
+ <AdditionalLibraryDirectories>$(OCI_SDK_PATH)\lib\msvc;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
94
+ <OutputFile>..\..\..\..\lib\$(TargetName)$(TargetExt)</OutputFile>
95
+ </Link>
96
+ </ItemDefinitionGroup>
97
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
98
+ <ClCompile>
99
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
100
+ <WarningLevel>Level3</WarningLevel>
101
+ <Optimization>Disabled</Optimization>
102
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;EMBULKOUTPUTORACLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
103
+ <AdditionalIncludeDirectories>$(OCI_SDK_PATH)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
104
+ </ClCompile>
105
+ <Link>
106
+ <SubSystem>Windows</SubSystem>
107
+ <GenerateDebugInformation>true</GenerateDebugInformation>
108
+ <AdditionalLibraryDirectories>$(OCI_SDK_PATH)\lib\msvc;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
109
+ <AdditionalDependencies>oci.lib;%(AdditionalDependencies)</AdditionalDependencies>
110
+ <OutputFile>..\..\..\..\lib\embulk\native\x86_64-windows\$(TargetName)$(TargetExt)</OutputFile>
111
+ </Link>
112
+ </ItemDefinitionGroup>
113
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
114
+ <ClCompile>
115
+ <WarningLevel>Level3</WarningLevel>
116
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
117
+ <Optimization>MaxSpeed</Optimization>
118
+ <FunctionLevelLinking>true</FunctionLevelLinking>
119
+ <IntrinsicFunctions>true</IntrinsicFunctions>
120
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;EMBULKOUTPUTORACLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
121
+ <AdditionalIncludeDirectories>$(OCI_SDK_PATH)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
122
+ </ClCompile>
123
+ <Link>
124
+ <SubSystem>Windows</SubSystem>
125
+ <GenerateDebugInformation>true</GenerateDebugInformation>
126
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
127
+ <OptimizeReferences>true</OptimizeReferences>
128
+ <OutputFile>..\..\..\..\lib\$(TargetName)$(TargetExt)</OutputFile>
129
+ </Link>
130
+ </ItemDefinitionGroup>
131
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
132
+ <ClCompile>
133
+ <WarningLevel>Level3</WarningLevel>
134
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
135
+ <Optimization>MaxSpeed</Optimization>
136
+ <FunctionLevelLinking>true</FunctionLevelLinking>
137
+ <IntrinsicFunctions>true</IntrinsicFunctions>
138
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;EMBULKOUTPUTORACLE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
139
+ <AdditionalIncludeDirectories>$(OCI_SDK_PATH)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
140
+ </ClCompile>
141
+ <Link>
142
+ <SubSystem>Windows</SubSystem>
143
+ <GenerateDebugInformation>true</GenerateDebugInformation>
144
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
145
+ <OptimizeReferences>true</OptimizeReferences>
146
+ <AdditionalLibraryDirectories>$(OCI_SDK_PATH)\lib\msvc;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
147
+ <AdditionalDependencies>oci.lib;%(AdditionalDependencies)</AdditionalDependencies>
148
+ <OutputFile>..\..\..\..\lib\embulk\native\x86_64-windows\$(TargetName)$(TargetExt)</OutputFile>
149
+ </Link>
150
+ </ItemDefinitionGroup>
151
+ <ItemGroup>
152
+ <ClCompile Include="..\common\embulk-output-oracle-oci.cpp" />
153
+ <ClCompile Include="dllmain.cpp">
154
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
155
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
156
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
157
+ </PrecompiledHeader>
158
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
159
+ </PrecompiledHeader>
160
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
161
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
162
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
163
+ </PrecompiledHeader>
164
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
165
+ </PrecompiledHeader>
166
+ </ClCompile>
167
+ </ItemGroup>
168
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
169
+ <ImportGroup Label="ExtensionTargets">
170
+ </ImportGroup>
171
+ </Project>
@@ -21,16 +21,12 @@ import org.embulk.output.oracle.oci.OCIManager;
21
21
  import org.embulk.output.oracle.oci.OCIWrapper;
22
22
  import org.embulk.output.oracle.oci.RowBuffer;
23
23
  import org.embulk.output.oracle.oci.TableDefinition;
24
- import org.embulk.spi.Exec;
25
24
  import org.embulk.spi.time.Timestamp;
26
- import org.slf4j.Logger;
27
25
 
28
26
  public class DirectBatchInsert implements BatchInsert
29
27
  {
30
28
  private static OCIManager ociManager = new OCIManager();
31
29
 
32
- private final Logger logger = Exec.getLogger(DirectBatchInsert.class);
33
-
34
30
  private List<String> ociKey;
35
31
  private final String database;
36
32
  private final String user;
@@ -40,9 +36,6 @@ public class DirectBatchInsert implements BatchInsert
40
36
  private final OracleCharset nationalCharset;
41
37
  private final int batchSize;
42
38
  private RowBuffer buffer;
43
- private long totalRows;
44
- private int rowSize;
45
- private int batchWeight;
46
39
  private boolean closed;
47
40
 
48
41
  private DateFormat[] formats;
@@ -148,31 +141,23 @@ public class DirectBatchInsert implements BatchInsert
148
141
 
149
142
  }
150
143
 
151
- rowSize = 0;
152
- for (ColumnDefinition column : columns) {
153
- rowSize += column.getDataSize();
154
- }
155
-
156
144
  TableDefinition tableDefinition = new TableDefinition(schema, loadTable, columns);
157
145
  ociKey = Arrays.asList(database, user, loadTable);
158
- ociManager.open(ociKey, database, user, password, tableDefinition);
146
+ OCIWrapper oci = ociManager.open(ociKey, database, user, password, tableDefinition, batchSize);
159
147
 
160
- buffer = new RowBuffer(tableDefinition, Math.max(batchSize / rowSize, 8));
148
+ buffer = new RowBuffer(oci, tableDefinition);
161
149
  }
162
150
 
163
151
  @Override
164
152
  public int getBatchWeight()
165
153
  {
166
- return batchWeight;
154
+ // Automatically flushed in RowBuffer
155
+ return 0;
167
156
  }
168
157
 
169
158
  @Override
170
159
  public void add() throws IOException, SQLException
171
160
  {
172
- batchWeight += rowSize;
173
- if (buffer.isFull()) {
174
- flush();
175
- }
176
161
  }
177
162
 
178
163
  @Override
@@ -187,26 +172,7 @@ public class DirectBatchInsert implements BatchInsert
187
172
  @Override
188
173
  public void flush() throws IOException, SQLException
189
174
  {
190
- if (buffer.getRowCount() > 0) {
191
- try {
192
- logger.info(String.format("Loading %,d rows", buffer.getRowCount()));
193
-
194
- long startTime = System.currentTimeMillis();
195
-
196
- OCIWrapper oci = ociManager.get(ociKey);
197
- synchronized (oci) {
198
- oci.loadBuffer(buffer);
199
- }
200
-
201
- totalRows += buffer.getRowCount();
202
- double seconds = (System.currentTimeMillis() - startTime) / 1000.0;
203
- logger.info(String.format("> %.2f seconds (loaded %,d rows in total)", seconds, totalRows));
204
-
205
- } finally {
206
- buffer.clear();
207
- batchWeight = 0;
208
- }
209
- }
175
+ buffer.flush();
210
176
  }
211
177
 
212
178
  @Override