You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ma...@apache.org on 2015/07/15 11:42:47 UTC
[14/14] incubator-kylin git commit: add odbc driver to maven
repository
add odbc driver to maven repository
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/d1dcfd15
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/d1dcfd15
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/d1dcfd15
Branch: refs/heads/0.8
Commit: d1dcfd155c480e31a5a29af165c8a5e1ae87f140
Parents: 480453e
Author: honma <ho...@ebay.com>
Authored: Wed Jul 15 17:42:00 2015 +0800
Committer: honma <ho...@ebay.com>
Committed: Wed Jul 15 17:42:15 2015 +0800
----------------------------------------------------------------------
odbc/.gitignore | 36 +
odbc/Common/Common.vcxproj | 205 +
odbc/Common/Common.vcxproj.filters | 75 +
odbc/Common/Common.vcxproj.user | 4 +
odbc/Common/Dump.cpp | 65 +
odbc/Common/Dump.h | 3 +
odbc/Common/Gzip.cpp | 68 +
odbc/Common/Gzip.h | 4 +
odbc/Common/JDBCODBC.cpp | 131 +
odbc/Common/JDBCODBC.h | 443 ++
odbc/Common/JsonConverter.cpp | 154 +
odbc/Common/JsonConverter.h | 13 +
odbc/Common/MsgTypes.h | 415 ++
odbc/Common/QueryCache.cpp | 69 +
odbc/Common/QueryCache.h | 5 +
odbc/Common/REST.cpp | 363 ++
odbc/Common/REST.h | 16 +
odbc/Common/ReadMe.txt | 29 +
odbc/Common/StringUtils.cpp | 165 +
odbc/Common/StringUtils.h | 25 +
odbc/Common/Win32/Release/.gitignore | 1 +
odbc/Common/base64.cpp | 97 +
odbc/Common/base64.h | 10 +
odbc/Common/x64/Release/.gitignore | 1 +
odbc/Driver/.gitignore | 2 +
odbc/Driver/GODBC.RC | 177 +
odbc/Driver/KO_ALLOC.CPP | 608 ++
odbc/Driver/KO_ATTR.CPP | 897 +++
odbc/Driver/KO_CONN.CPP | 1010 +++
odbc/Driver/KO_CTLG.CPP | 341 ++
odbc/Driver/KO_Config.cpp | 677 +++
odbc/Driver/KO_DESC.CPP | 2778 +++++++++
odbc/Driver/KO_DIAG.CPP | 934 +++
odbc/Driver/KO_DTYPE.CPP | 361 ++
odbc/Driver/KO_EXEC.CPP | 321 +
odbc/Driver/KO_FETCH.CPP | 1213 ++++
odbc/Driver/KO_INFO.CPP | 1152 ++++
odbc/Driver/KO_PARAM.CPP | 85 +
odbc/Driver/KO_UTILS.CPP | 566 ++
odbc/Driver/KylinODBC.CPP | 352 ++
odbc/Driver/KylinODBC.H | 644 ++
odbc/Driver/TypeConvertion.h | 539 ++
.../Win32/Release/Intermediate/.gitignore | 2 +
odbc/Driver/driver.DEF | 85 +
odbc/Driver/driver.dsp | 247 +
odbc/Driver/driver.vcxproj | 374 ++
odbc/Driver/driver.vcxproj.filters | 85 +
odbc/Driver/driver.vcxproj.user | 4 +
odbc/Driver/resource.h | 32 +
odbc/Driver/stdafx.cpp | 1 +
odbc/Driver/stdafx.h | 3 +
odbc/Driver/version.props | 14 +
odbc/Driver/x64/Release/Intermediate/.gitignore | 2 +
odbc/Installer(64bit)/Installer(64bit).isl | 5736 ++++++++++++++++++
odbc/Installer(64bit)/Installer(64bit).isproj | 37 +
.../Installer(64bit)/Express/Interm/.gitignore | 1 +
.../SingleImage/DiskImages/DISK1/.gitignore | 1 +
.../Express/SingleImage/LogFiles/.gitignore | 1 +
.../Express/SingleImage/Reports/.gitignore | 1 +
odbc/Installer/Installer.isl | 5716 +++++++++++++++++
odbc/Installer/Installer.isproj | 37 +
.../Installer/Express/Interm/.gitignore | 1 +
.../SingleImage/DiskImages/DISK1/.gitignore | 1 +
.../Express/SingleImage/LogFiles/.gitignore | 1 +
.../Express/SingleImage/Reports/.gitignore | 1 +
odbc/KylinODBC.sln | 296 +
odbc/LICENSE | 202 +
odbc/README.md | 61 +
odbc/ReadMe.txt | 53 +
odbc/TestDLL/ColorPrint.cpp | 44 +
odbc/TestDLL/ColorPrint.h | 5 +
odbc/TestDLL/CompareQueryTests.cpp | 530 ++
odbc/TestDLL/QueryFlowTest.cpp | 32 +
odbc/TestDLL/Report.cpp | 9 +
odbc/TestDLL/RestAPITest.cpp | 20 +
odbc/TestDLL/SimpleQueryTest.cpp | 30 +
odbc/TestDLL/Source.cpp | 13 +
odbc/TestDLL/TestDLL.vcxproj | 107 +
odbc/TestDLL/TestDLL.vcxproj.filters | 48 +
odbc/TestDLL/TestDLL.vcxproj.user | 7 +
odbc/TestDLL/Tests.h | 29 +
odbc/TestDLL/testqueries.txt | 82 +
odbc/ThirdPartyLibraries.txt | 9 +
odbc/doc/reference/0205agarwal.zip | Bin 0 -> 858699 bytes
odbc/doc/reference/ODBC Driver Development.docx | Bin 0 -> 238372 bytes
...61\345\212\250\347\250\213\345\272\217.docx" | Bin 0 -> 681289 bytes
odbc/ipch/driver-646534d9/.gitignore | 1 +
87 files changed, 29015 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/.gitignore
----------------------------------------------------------------------
diff --git a/odbc/.gitignore b/odbc/.gitignore
new file mode 100644
index 0000000..bc31b54
--- /dev/null
+++ b/odbc/.gitignore
@@ -0,0 +1,36 @@
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.out
+*.app
+
+*.opensdf
+*.sdf
+*.log
+*.tlog
+*.pdb
+*.suo
+
+
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/Common.vcxproj
----------------------------------------------------------------------
diff --git a/odbc/Common/Common.vcxproj b/odbc/Common/Common.vcxproj
new file mode 100644
index 0000000..fe2f63b
--- /dev/null
+++ b/odbc/Common/Common.vcxproj
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{6EE1C577-1826-4EA2-86AC-FE8047D396A9}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>Common</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v110</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <IncludePath>$(CPPREST_HOME)\Release\include;$(IncludePath)</IncludePath>
+ <LibraryPath>$(CPPREST_HOME)\Binaries\Win32\Release;$(LibraryPath)</LibraryPath>
+ <OutDir>$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <IncludePath>$(CPPREST_HOME)\Release\include;$(IncludePath)</IncludePath>
+ <LibraryPath>$(CPPREST_HOME)\Binaries\Release64;$(LibraryPath)</LibraryPath>
+ <OutDir>$(Platform)\$(Configuration)\</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <IncludePath>$(CPPREST_HOME)\Release\include;C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
+ <LibraryPath>$(CPPREST_HOME)\Binaries\Win32\Debug;C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
+ <OutDir>$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <IncludePath>$(CPPREST_HOME)\Release\include;$(IncludePath)</IncludePath>
+ <LibraryPath>$(CPPREST_HOME)\Binaries\Debug64;$(LibraryPath)</LibraryPath>
+ <OutDir>$(Platform)\$(Configuration)\</OutDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;ASMV;ASMINF;ZLIB_WINAPI;WIN32;_DEBUG;_LIB;_NO_ASYNCRTIMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(ZLIB_HOME);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ <Lib>
+ <AdditionalDependencies>zlibstat.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Lib>
+ <Lib>
+ <AdditionalLibraryDirectories>$(ZLIB_HOME)\contrib\vstudio\vc11\x86\ZlibDllDebug;$(ZLIB_HOME)\contrib\vstudio\vc11\x86\ZlibStatDebug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;ASMV;ASMINF;ZLIB_WINAPI;WIN32;NDEBUG;_DEBUG;_LIB;_NO_ASYNCRTIMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(ZLIB_HOME);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ <Lib>
+ <AdditionalLibraryDirectories>$(ZLIB_HOME)\contrib\vstudio\vc11\x64\ZlibStatDebug;$(ZLIB_HOME)\contrib\vstudio\vc11\x64\ZlibDllDebug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>zlibstat.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;ASMV;ASMINF;ZLIB_WINAPI;WIN32;NDEBUG;_LIB;_NO_ASYNCRTIMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(ZLIB_HOME);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ <Lib>
+ <AdditionalLibraryDirectories>$(ZLIB_HOME)\contrib\vstudio\vc11\x86\ZlibStatRelease;$(ZLIB_HOME)\contrib\vstudio\vc11\x86\ZlibDllRelease;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>zlibstat.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;ASMV;ASMINF;ZLIB_WINAPI;WIN32;NDEBUG;_LIB;_NO_ASYNCRTIMP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <AdditionalIncludeDirectories>$(ZLIB_HOME);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ <Lib>
+ <AdditionalDependencies>zlibstat.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ZLIB_HOME)\contrib\vstudio\vc11\x64\ZlibStatRelease;$(ZLIB_HOME)\contrib\vstudio\vc11\x64\ZlibDllRelease;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Base64.h" />
+ <ClInclude Include="Dump.h" />
+ <ClInclude Include="Gzip.h" />
+ <ClInclude Include="JDBCODBC.h" />
+ <ClInclude Include="JsonConverter.h" />
+ <ClInclude Include="MsgTypes.h" />
+ <ClInclude Include="QueryCache.h" />
+ <ClInclude Include="REST.h" />
+ <ClInclude Include="StringUtils.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="Base64.cpp" />
+ <ClCompile Include="Dump.cpp" />
+ <ClCompile Include="Gzip.cpp" />
+ <ClCompile Include="JDBCODBC.cpp" />
+ <ClCompile Include="JsonConverter.cpp" />
+ <ClCompile Include="QueryCache.cpp" />
+ <ClCompile Include="REST.cpp" />
+ <ClCompile Include="StringUtils.cpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/Common.vcxproj.filters
----------------------------------------------------------------------
diff --git a/odbc/Common/Common.vcxproj.filters b/odbc/Common/Common.vcxproj.filters
new file mode 100644
index 0000000..790f9df
--- /dev/null
+++ b/odbc/Common/Common.vcxproj.filters
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="JDBCODBC.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="MsgTypes.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="REST.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="StringUtils.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Dump.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Base64.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="QueryCache.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Gzip.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="JsonConverter.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="JDBCODBC.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="REST.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="StringUtils.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Dump.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Base64.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="QueryCache.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Gzip.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="JsonConverter.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/Common.vcxproj.user
----------------------------------------------------------------------
diff --git a/odbc/Common/Common.vcxproj.user b/odbc/Common/Common.vcxproj.user
new file mode 100644
index 0000000..a375ae3
--- /dev/null
+++ b/odbc/Common/Common.vcxproj.user
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup />
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/Dump.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/Dump.cpp b/odbc/Common/Dump.cpp
new file mode 100644
index 0000000..e085861
--- /dev/null
+++ b/odbc/Common/Dump.cpp
@@ -0,0 +1,65 @@
+#include <assert.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+void displayHexRecord ( char* data, int count, int record_length ) {
+ int i;
+
+ for ( i = 0; i < count; i++ ) { printf ( "%02x ", data[i] & 0xff ); }
+
+ for ( ; i < record_length; i++ ) { printf ( " " ); }
+
+ printf ( ": " );
+
+ for ( i = 0; i < count; i++ ) {
+ if ( isgraph ( data[i] ) ) { putchar ( data[i] ); }
+
+ else { putchar ( '.' ); }
+ }
+
+ putchar ( '\n' );
+}
+
+void bufferHexRecord ( char* data, int count, int record_length, char* buffer ) {
+ int i;
+
+ for ( i = 0; i < count; i++ ) {
+ sprintf ( buffer + strlen ( buffer ), "%02x ", data[i] & 0xff );
+ }
+
+ for ( ; i < record_length; i++ )
+ { sprintf ( buffer + strlen ( buffer ), " " ); }
+
+ sprintf ( buffer + strlen ( buffer ), ": " );
+
+ for ( i = 0; i < count; i++ ) {
+ if ( isgraph ( data[i] ) ) {
+ buffer[strlen ( buffer ) + 1] = '\0';
+ buffer[strlen ( buffer )] = data[i];
+ }
+
+ else {
+ buffer[strlen ( buffer ) + 1] = '\0';
+ buffer[strlen ( buffer )] = '.';
+ }
+ }
+
+ buffer[strlen ( buffer ) + 1] = '\0';
+ buffer[strlen ( buffer )] = '\n';
+}
+
+//dump 16 * lines bytes, readable test stored in buffer, reserve 100 bytes in buffer for one line
+void hexDump ( char* data, int lines, char* buffer, bool forward ) {
+ if ( !forward ) {
+ data -= lines * 16;
+ }
+
+ buffer[0] = '\0';
+
+ for ( int i = 0 ; i < lines ; ++i ) {
+ sprintf ( buffer + strlen ( buffer ), "%10d ", data );
+ bufferHexRecord ( data, 16, 16, buffer );
+ data += 16;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/Dump.h
----------------------------------------------------------------------
diff --git a/odbc/Common/Dump.h b/odbc/Common/Dump.h
new file mode 100644
index 0000000..36f7430
--- /dev/null
+++ b/odbc/Common/Dump.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void hexDump ( char* data, int lines, char* buffer, bool forward );
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/Gzip.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/Gzip.cpp b/odbc/Common/Gzip.cpp
new file mode 100644
index 0000000..995540a
--- /dev/null
+++ b/odbc/Common/Gzip.cpp
@@ -0,0 +1,68 @@
+#include <cstdio>
+#include <string>
+#include <cstring>
+#include <cstdlib>
+#include "zlib.h"
+#include "zconf.h"
+
+using namespace std;
+
+bool gzipInflate ( const std::string& compressedBytes, std::string& uncompressedBytes ) {
+ if ( compressedBytes.size() == 0 ) {
+ uncompressedBytes = compressedBytes ;
+ return true ;
+ }
+
+ uncompressedBytes.clear() ;
+ unsigned full_length = compressedBytes.size() ;
+ unsigned half_length = compressedBytes.size() / 2;
+ unsigned uncompLength = full_length ;
+ char* uncomp = ( char* ) calloc ( sizeof ( char ), uncompLength );
+ z_stream strm;
+ strm.next_in = ( Bytef* ) compressedBytes.c_str();
+ strm.avail_in = compressedBytes.size() ;
+ strm.total_out = 0;
+ strm.zalloc = Z_NULL;
+ strm.zfree = Z_NULL;
+ bool done = false ;
+
+ if ( inflateInit2 ( &strm, ( 16 + MAX_WBITS ) ) != Z_OK ) {
+ free ( uncomp );
+ return false;
+ }
+
+ while ( !done ) {
+ // If our output buffer is too small
+ if ( strm.total_out >= uncompLength ) {
+ // Increase size of output buffer
+ char* uncomp2 = ( char* ) calloc ( sizeof ( char ), uncompLength + half_length );
+ memcpy ( uncomp2, uncomp, uncompLength );
+ uncompLength += half_length ;
+ free ( uncomp );
+ uncomp = uncomp2 ;
+ }
+
+ strm.next_out = ( Bytef* ) ( uncomp + strm.total_out );
+ strm.avail_out = uncompLength - strm.total_out;
+ // Inflate another chunk.
+ int err = inflate ( &strm, Z_SYNC_FLUSH );
+
+ if ( err == Z_STREAM_END ) { done = true; }
+
+ else if ( err != Z_OK ) {
+ break;
+ }
+ }
+
+ if ( inflateEnd ( &strm ) != Z_OK ) {
+ free ( uncomp );
+ return false;
+ }
+
+ for ( size_t i = 0; i < strm.total_out; ++i ) {
+ uncompressedBytes += uncomp[ i ];
+ }
+
+ free ( uncomp );
+ return true ;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/Gzip.h
----------------------------------------------------------------------
diff --git a/odbc/Common/Gzip.h b/odbc/Common/Gzip.h
new file mode 100644
index 0000000..2fb4b88
--- /dev/null
+++ b/odbc/Common/Gzip.h
@@ -0,0 +1,4 @@
+#pragma once
+#include <string>
+
+bool gzipInflate ( const std::string& compressedBytes, std::string& uncompressedBytes );
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/JDBCODBC.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/JDBCODBC.cpp b/odbc/Common/JDBCODBC.cpp
new file mode 100644
index 0000000..39e8278
--- /dev/null
+++ b/odbc/Common/JDBCODBC.cpp
@@ -0,0 +1,131 @@
+#include "JDBCODBC.h"
+
+ODBCTypes JDBC2ODBC ( int jtype ) {
+ JDBCTypes temp = ( JDBCTypes ) jtype;
+
+ switch ( temp ) {
+ case JDBC_BOOLEAN:
+ return ODBCTypes::ODBC_Bit ;
+ break;
+
+ case JDBC_BIT:
+ return ODBCTypes::ODBC_Bit;
+ break;
+
+ case JDBC_TINYINT:
+ return ODBCTypes::ODBC_TinyInt;
+ break;
+
+ case JDBC_SMALLINT:
+ return ODBCTypes::ODBC_SmallInt;
+ break;
+
+ case JDBC_INTEGER:
+ return ODBCTypes::ODBC_Integer;
+ break;
+
+ case JDBC_BIGINT:
+ return ODBCTypes::ODBC_BigInt;
+ break;
+
+ case JDBC_FLOAT:
+ return ODBCTypes::ODBC_Float;
+ break;
+
+ case JDBC_REAL:
+ return ODBCTypes::ODBC_Real;
+ break;
+
+ case JDBC_DOUBLE:
+ return ODBCTypes::ODBC_Double;
+ break;
+
+ case JDBC_NUMERIC:
+ return ODBCTypes::ODBC_Numeric;
+ break;
+
+ case JDBC_DECIMAL:
+ return ODBCTypes::ODBC_Decimal;
+ break;
+
+ case JDBC_CHAR:
+ //return ODBCTypes::ODBC_Char;
+ return ODBCTypes::ODBC_WChar;//it's a unicode dirver
+ break;
+
+ case JDBC_VARCHAR:
+ //return ODBCTypes::ODBC_VarChar;
+ return ODBCTypes::ODBC_WChar;//it's a unicode dirver
+ break;
+
+ case 2000://"ANY" type in KYLIN
+ return ODBCTypes::ODBC_WChar;//it's a unicode dirver
+ break;
+
+ case JDBC_LONGVARCHAR:
+ return ODBCTypes::ODBC_LongVarChar;
+ break;
+
+ case JDBC_DATE:
+ return ODBCTypes::ODBC_Type_Date;
+ break;
+
+ case JDBC_TIME:
+ return ODBCTypes::ODBC_Type_Time;
+ break;
+
+ case JDBC_TIMESTAMP:
+ return ODBCTypes::ODBC_Type_Timestamp;
+ break;
+
+ case JDBC_BINARY:
+ return ODBCTypes::ODBC_Binary;
+ break;
+
+ case JDBC_VARBINARY:
+ return ODBCTypes::ODBC_VarBinary;
+ break;
+
+ case JDBC_LONGVARBINARY:
+ return ODBCTypes::ODBC_LongVarBinary;
+ break;
+
+ /* case NULL:
+ break;
+ case OTHER:
+ break;
+ case JAVA_OBJECT:
+ break;
+ case DISTINCT:
+ break;
+ case STRUCT:
+ break;
+ case ARRAY:
+ break;
+ case BLOB:
+ break;
+ case CLOB:
+ break;
+ case REF:
+ break;
+ case DATALINK:
+ break;
+ case BOOLEAN:
+ break;
+ case ROWID:
+ break;
+ case NCHAR:
+ break;
+ case NVARCHAR:
+ break;
+ case LONGNVARCHAR:
+ break;
+ case NCLOB:
+ break;
+ case SQLXML:
+ break;*/
+ default:
+ throw;
+ break;
+ }
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/JDBCODBC.h
----------------------------------------------------------------------
diff --git a/odbc/Common/JDBCODBC.h b/odbc/Common/JDBCODBC.h
new file mode 100644
index 0000000..71849f5
--- /dev/null
+++ b/odbc/Common/JDBCODBC.h
@@ -0,0 +1,443 @@
+#pragma once
+
+
+
+
+enum JDBCTypes {
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>BIT</code>.
+ */
+ JDBC_BIT = -7,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>TINYINT</code>.
+ */
+ JDBC_TINYINT = -6,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>SMALLINT</code>.
+ */
+ JDBC_SMALLINT = 5,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>INTEGER</code>.
+ */
+ JDBC_INTEGER = 4,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>BIGINT</code>.
+ */
+ JDBC_BIGINT = -5,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>FLOAT</code>.
+ */
+ JDBC_FLOAT = 6,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>REAL</code>.
+ */
+ JDBC_REAL = 7,
+
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>DOUBLE</code>.
+ */
+ JDBC_DOUBLE = 8,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>NUMERIC</code>.
+ */
+ JDBC_NUMERIC = 2,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>DECIMAL</code>.
+ */
+ JDBC_DECIMAL = 3,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>CHAR</code>.
+ */
+ JDBC_CHAR = 1,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>VARCHAR</code>.
+ */
+ JDBC_VARCHAR = 12,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>LONGVARCHAR</code>.
+ */
+ JDBC_LONGVARCHAR = -1,
+
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>DATE</code>.
+ */
+ JDBC_DATE = 91,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>TIME</code>.
+ */
+ JDBC_TIME = 92,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>TIMESTAMP</code>.
+ */
+ JDBC_TIMESTAMP = 93,
+
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>BINARY</code>.
+ */
+ JDBC_BINARY = -2,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>VARBINARY</code>.
+ */
+ JDBC_VARBINARY = -3,
+
+ /**
+ <P>The constant in the Java programming language, sometimes referred
+ to as a type code, that identifies the generic SQL type
+ <code>LONGVARBINARY</code>.
+ */
+ JDBC_LONGVARBINARY = -4,
+
+ /**
+ <P>The constant in the Java programming language
+ that identifies the generic SQL value
+ <code>NULL</code>.
+ */
+ //NULL = 0,
+
+ /**
+ The constant in the Java programming language that indicates
+ that the SQL type is database-specific and
+ gets mapped to a Java object that can be accessed via
+ the methods <code>getObject</code> and <code>setObject</code>.
+ */
+ JDBC_OTHER = 1111,
+
+
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type
+ <code>JAVA_OBJECT</code>.
+ @since 1.2
+ */
+ JDBC_JAVA_OBJECT = 2000,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type
+ <code>DISTINCT</code>.
+ @since 1.2
+ */
+ JDBC_DISTINCT = 2001,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type
+ <code>STRUCT</code>.
+ @since 1.2
+ */
+ JDBC_STRUCT = 2002,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type
+ <code>ARRAY</code>.
+ @since 1.2
+ */
+ JDBC_ARRAY = 2003,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type
+ <code>BLOB</code>.
+ @since 1.2
+ */
+ JDBC_BLOB = 2004,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type
+ <code>CLOB</code>.
+ @since 1.2
+ */
+ JDBC_CLOB = 2005,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type
+ <code>REF</code>.
+ @since 1.2
+ */
+ JDBC_REF = 2006,
+
+ /**
+ The constant in the Java programming language, somtimes referred to
+ as a type code, that identifies the generic SQL type <code>DATALINK</code>.
+
+ @since 1.4
+ */
+ JDBC_DATALINK = 70,
+
+ /**
+ The constant in the Java programming language, somtimes referred to
+ as a type code, that identifies the generic SQL type <code>BOOLEAN</code>.
+
+ @since 1.4
+ */
+ JDBC_BOOLEAN = 16,
+
+ //------------------------- JDBC 4.0 -----------------------------------
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type <code>ROWID</code>
+
+ @since 1.6
+
+ */
+ JDBC_ROWID = -8,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type <code>NCHAR</code>
+
+ @since 1.6
+ */
+ JDBC_NCHAR = -15,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type <code>NVARCHAR</code>.
+
+ @since 1.6
+ */
+ JDBC_NVARCHAR = -9,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type <code>LONGNVARCHAR</code>.
+
+ @since 1.6
+ */
+ JDBC_LONGNVARCHAR = -16,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type <code>NCLOB</code>.
+
+ @since 1.6
+ */
+ JDBC_NCLOB = 2011,
+
+ /**
+ The constant in the Java programming language, sometimes referred to
+ as a type code, that identifies the generic SQL type <code>XML</code>.
+
+ @since 1.6
+ */
+ JDBC_SQLXML = 2009
+};
+
+enum ODBCTypes {
+ // Summary:
+ // Maps to SQL_GUID.
+ ODBC_Guid = -11,
+ //
+ // Summary:
+ // Maps to SQL_WLONGVARCHAR. Native Type: System.String
+ ODBC_WLongVarChar = -10,
+ //
+ // Summary:
+ // Maps to SQL_WVARCHAR. Native Type: System.String
+ ODBC_WVarChar = -9,
+ //
+ // Summary:
+ // Maps to SQL_WCHAR. Native Type: System.String
+ ODBC_WChar = -8,
+ //
+ // Summary:
+ // Maps to SQL_BIT. Native Type: System.Boolean
+ ODBC_Bit = -7,
+ //
+ // Summary:
+ // Maps to SQL_TINYINT. Native Type: System.SByte
+ ODBC_TinyInt = -6,
+ //
+ // Summary:
+ // Maps to SQL_BIGINT. Native Type: System.Int64
+ ODBC_BigInt = -5,
+ //
+ // Summary:
+ // Maps to SQL_LONGVARBINARY. Native Type: array[System.Byte]
+ ODBC_LongVarBinary = -4,
+ //
+ // Summary:
+ // Maps to SQL_VARBINARY. Native Type: array[System.Byte]
+ ODBC_VarBinary = -3,
+ //
+ // Summary:
+ // Maps to SQL_BINARY. Native Type: array[System.Byte]
+ ODBC_Binary = -2,
+ //
+ // Summary:
+ // Maps to SQL_LONGVARCHAR. Native Type: System.String
+ ODBC_LongVarChar = -1,
+ //
+ // Summary:
+ // Maps to SQL_CHAR. Native Type: System.String
+ ODBC_Char = 1,
+ //
+ // Summary:
+ // Maps to SQL_NUMERIC. Native Type: System.Decimal
+ ODBC_Numeric = 2,
+ //
+ // Summary:
+ // Maps to SQL_DECIMAL. Native Type: System.Decimal
+ ODBC_Decimal = 3,
+ //
+ // Summary:
+ // Maps to SQL_INTEGER. Native Type: System.Int32
+ ODBC_Integer = 4,
+ //
+ // Summary:
+ // Maps to SQL_SMALLINT. Native Type: System.Int16
+ ODBC_SmallInt = 5,
+ //
+ // Summary:
+ // Maps to SQL_FLOAT. Native Type: System.Double
+ ODBC_Float = 6,
+ //
+ // Summary:
+ // Maps to SQL_REAL. Native Type: System.Single
+ ODBC_Real = 7,
+ //
+ // Summary:
+ // Maps to SQL_DOUBLE. Native Type: System.Double
+ ODBC_Double = 8,
+ //
+ // Summary:
+ // Maps to SQL_DATETIME. This type should NOT be used with CreateTypeMetadata,
+ // as it is not a valid type identifier.
+ ODBC_DateTime = 9,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL. Not a valid type identifier.
+ ODBC_Interval = 10,
+ //
+ // Summary:
+ // Maps to SQL_VARCHAR. Native Type: System.String
+ ODBC_VarChar = 12,
+ //
+ // Summary:
+ // Does not map to an ODBC SQL type. Native Type: System.DateTimeOffset
+ ODBC_DateTimeOffset = 36,
+ //
+ // Summary:
+ // Maps to SQL_TYPE_DATE. Native Type: System.DateTime
+ ODBC_Type_Date = 91,
+ //
+ // Summary:
+ // Maps to SQL_TYPE_TIME. Native Type: System.DateTime
+ ODBC_Type_Time = 92,
+ //
+ // Summary:
+ // Maps to SQL_TYPE_TIMESTAMP. Native Type: System.DateTime
+ ODBC_Type_Timestamp = 93,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_YEAR. Native Type: Simba.DotNetDSI.DataEngine.DSIMonthSpan
+ ODBC_Interval_Year = 101,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_MONTH. Native Type: Simba.DotNetDSI.DataEngine.DSIMonthSpan
+ ODBC_Interval_Month = 102,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_DAY. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Day = 103,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_HOUR. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Hour = 104,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_MINUTE. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Minute = 105,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_SECOND. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Second = 106,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_YEAR_TO_MONTH. Native Type: Simba.DotNetDSI.DataEngine.DSIMonthSpan
+ ODBC_Interval_Year_To_Month = 107,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_DAY_TO_HOUR. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Day_To_Hour = 108,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_DAY_TO_MINUTE. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Day_To_Minute = 109,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_DAY_TO_SECOND. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Day_To_Second = 110,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_HOUR_TO_MINUTE. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Hour_To_Minute = 111,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_HOUR_TO_SECOND. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Hour_To_Second = 112,
+ //
+ // Summary:
+ // Maps to SQL_INTERVAL_MINUTE_TO_SECOND. Native Type: Simba.DotNetDSI.DataEngine.DSITimeSpan
+ ODBC_Interval_Minute_To_Second = 113,
+};
+
+ODBCTypes JDBC2ODBC ( int jtype );
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/JsonConverter.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/JsonConverter.cpp b/odbc/Common/JsonConverter.cpp
new file mode 100644
index 0000000..adc639a
--- /dev/null
+++ b/odbc/Common/JsonConverter.cpp
@@ -0,0 +1,154 @@
+#include "JsonConverter.h"
+
+#define ASSIGN_IF_NOT_NULL(x,y,z) if(!y.is_null())x=y.z
+#define x_ASSIGN_IF_NOT_NULL(x,y,z) if(!y.is_null())x=wstring2string(y.z)
+
+
+TableMeta* TableMetaFromJSON ( web::json::value & object ) {
+ TableMeta* result = new TableMeta();
+ x_ASSIGN_IF_NOT_NULL ( result->TABLE_CAT, object[U ( "table_CAT" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TABLE_SCHEM , object[U ( "table_SCHEM" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TABLE_NAME , object[U ( "table_NAME" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TABLE_TYPE , object[U ( "table_TYPE" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->REMARKS , object[U ( "remarks" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TYPE_CAT , object[U ( "type_CAT" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TYPE_SCHEM , object[U ( "type_SCHEM" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TYPE_NAME , object[U ( "type_NAME" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->SELF_REFERENCING_COL_NAME , object[U ( "self_REFERENCING_COL_NAME" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->REF_GENERATION , object[U ( "ref_GENERATION" )], as_string() );
+ return result;
+}
+
+ColumnMeta* ColumnMetaFromJSON ( web::json::value & object ) {
+ ColumnMeta* result = new ColumnMeta();
+ x_ASSIGN_IF_NOT_NULL ( result->TABLE_CAT , object[U ( "table_CAT" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TABLE_SCHEM , object[U ( "table_SCHEM" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->TABLE_NAME , object[U ( "table_NAME" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->COLUMN_NAME , object[U ( "column_NAME" )], as_string() );
+ //ASSIGN_IF_NOT_NULL(result->DATA_TYPE ,object[U("data_TYPE")], as_integer());
+ x_ASSIGN_IF_NOT_NULL ( result->TYPE_NAME , object[U ( "type_NAME" )], as_string() );
+ ASSIGN_IF_NOT_NULL ( result->COLUMN_SIZE , object[U ( "column_SIZE" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->BUFFER_LENGTH , object[U ( "buffer_LENGTH" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->DECIMAL_DIGITS , object[U ( "decimal_DIGITS" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->NUM_PREC_RADIX , object[U ( "num_PREC_RADIX" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->NULLABLE , object[U ( "nullable" )], as_integer() );
+ x_ASSIGN_IF_NOT_NULL ( result->REMARKS , object[U ( "remarks" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->COLUMN_DEF , object[U ( "column_DEF" )], as_string() );
+ //ASSIGN_IF_NOT_NULL(result->SQL_DATA_TYPE ,object[U("sql_DATA_TYPE")], as_integer());
+ ASSIGN_IF_NOT_NULL ( result->SQL_DATETIME_SUB , object[U ( "sql_DATETIME_SUB" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->CHAR_OCTET_LENGTH , object[U ( "char_OCTET_LENGTH" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->ORDINAL_POSITION , object[U ( "ordinal_POSITION" )], as_integer() );
+ x_ASSIGN_IF_NOT_NULL ( result->IS_NULLABLE , object[U ( "is_NULLABLE" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->SCOPE_CATLOG , object[U ( "scope_CATLOG" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->SCOPE_SCHEMA , object[U ( "scope_SCHEMA" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->SCOPE_TABLE , object[U ( "scope_TABLE" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->IS_AUTOINCREMENT , object[U ( "iS_AUTOINCREMENT" )], as_string() );
+
+ if ( !object[U ( "source_DATA_TYPE" )].is_null() ) {
+ result->SOURCE_DATA_TYPE = ( short ) object[U ( "source_DATA_TYPE" )].as_integer();
+ }
+
+ // the orig value passed from REST is java.sql.Types, we convert it to SQL Type
+
+ if ( !object[U ( "data_TYPE" )].is_null() ) {
+ result->DATA_TYPE = JDBC2ODBC ( object[U ( "data_TYPE" )].as_integer() );
+ }
+
+ if ( !object[U ( "sql_DATA_TYPE" )].is_null() ) {
+ result->SQL_DATA_TYPE = JDBC2ODBC ( object[U ( "sql_DATA_TYPE" )].as_integer() );
+ }
+
+ return result;
+}
+
+std::unique_ptr<MetadataResponse> MetadataResponseFromJSON ( web::json::value & object ) {
+ std::unique_ptr<MetadataResponse> result ( new MetadataResponse() );
+ web::json::array& tableMetaArray = object.as_array();
+
+ for ( auto iter = tableMetaArray.begin(); iter != tableMetaArray.end(); ++iter ) {
+ result->tableMetas.push_back ( TableMetaFromJSON ( *iter ) );
+ web::json::value& columns = ( *iter ) [U ( "columns" )];
+ web::json::array& columnsMetaArray = columns.as_array();
+
+ for ( auto inner_iter = columnsMetaArray.begin(); inner_iter != columnsMetaArray.end(); ++inner_iter ) {
+ result->columnMetas.push_back ( ColumnMetaFromJSON ( *inner_iter ) );
+ }
+ }
+
+ return result;
+}
+SelectedColumnMeta* SelectedColumnMetaFromJSON ( web::json::value & object ) {
+ SelectedColumnMeta* result = new SelectedColumnMeta();
+ ASSIGN_IF_NOT_NULL ( result->isAutoIncrement , object[U ( "autoIncrement" )], as_bool() );
+ ASSIGN_IF_NOT_NULL ( result->isCaseSensitive , object[U ( "caseSensitive" )], as_bool() );
+ ASSIGN_IF_NOT_NULL ( result->isSearchable , object[U ( "searchable" )], as_bool() );
+ ASSIGN_IF_NOT_NULL ( result->isCurrency , object[U ( "currency" )], as_bool() );
+ ASSIGN_IF_NOT_NULL ( result->isNullable , object[U ( "isNullable" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->isSigned , object[U ( "signed" )], as_bool() );
+ ASSIGN_IF_NOT_NULL ( result->displaySize , object[U ( "displaySize" )], as_integer() );
+ x_ASSIGN_IF_NOT_NULL ( result->label , object[U ( "label" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->name , object[U ( "name" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->schemaName , object[U ( "schemaName" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->catelogName , object[U ( "catelogName" )], as_string() );
+ x_ASSIGN_IF_NOT_NULL ( result->tableName , object[U ( "tableName" )], as_string() );
+ ASSIGN_IF_NOT_NULL ( result->precision , object[U ( "precision" )], as_integer() );
+ ASSIGN_IF_NOT_NULL ( result->scale , object[U ( "scale" )], as_integer() );
+ //ASSIGN_IF_NOT_NULL(result->columnType ,object[U("columnType")], as_integer());
+ x_ASSIGN_IF_NOT_NULL ( result->columnTypeName , object[U ( "columnTypeName" )], as_string() );
+ ASSIGN_IF_NOT_NULL ( result->isReadOnly , object[U ( "readOnly" )], as_bool() );
+ ASSIGN_IF_NOT_NULL ( result->isWritable , object[U ( "writable" )], as_bool() );
+ ASSIGN_IF_NOT_NULL ( result->isDefinitelyWritable , object[U ( "definitelyWritable" )], as_bool() );
+
+ if ( !object[U ( "columnType" )].is_null() ) {
+ result->columnType = JDBC2ODBC ( object[U ( "columnType" )].as_integer() );
+ }
+
+ return result;
+}
+
+void constructUnflattenResults ( SQLResponse* result, web::json::value& o_results ) {
+ if ( o_results.is_null() )
+ { return; }
+
+ for ( auto iter = o_results.as_array().begin(); iter != o_results.as_array().end(); ++iter ) {
+ SQLRowContent* row = new SQLRowContent();
+
+ for ( auto jter = iter->as_array().begin(); jter != iter->as_array().end(); ++jter ) {
+ if ( jter->is_null() ) {
+ wstring emptyCell;
+ row->contents.push_back ( emptyCell );
+ }
+
+ else {
+ row->contents.push_back ( ( jter->as_string() ) );
+ }
+ }
+
+ result->results.push_back ( row );
+ }
+}
+
+std::unique_ptr<SQLResponse> SQLResponseFromJSON ( web::json::value & object ) {
+ std::unique_ptr<SQLResponse> result ( new SQLResponse() );
+ web::json::value& o_columnMetas = object[U ( "columnMetas" )];
+ web::json::value& o_results = object[U ( "results" )];
+ result->affectedRowCount = object[U ( "affectedRowCount" )].as_integer();
+ result->isException = object[U ( "isException" )].as_bool();
+ ASSIGN_IF_NOT_NULL ( result->exceptionMessage, object[U ( "exceptionMessage" )], as_string() );
+
+ if ( !o_columnMetas.is_null() ) {
+ for ( auto iter = o_columnMetas.as_array().begin(); iter != o_columnMetas.as_array().end(); ++iter ) {
+ result->columnMetas.push_back ( SelectedColumnMetaFromJSON ( *iter ) );
+ }
+ }
+
+ constructUnflattenResults ( result.get(), o_results );
+ return result;
+}
+
+std::unique_ptr<ErrorMessage> ErrorMessageFromJSON ( web::json::value & object ) {
+ std::unique_ptr<ErrorMessage> result ( new ErrorMessage() );
+ ASSIGN_IF_NOT_NULL ( result->url, object[U ( "url" )], as_string() );
+ ASSIGN_IF_NOT_NULL ( result->msg, object[U ( "exception" )], as_string() );
+ return result;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/JsonConverter.h
----------------------------------------------------------------------
diff --git a/odbc/Common/JsonConverter.h b/odbc/Common/JsonConverter.h
new file mode 100644
index 0000000..ac6dbcf
--- /dev/null
+++ b/odbc/Common/JsonConverter.h
@@ -0,0 +1,13 @@
+
+#pragma once
+
+#include "cpprest/json.h"
+#include "cpprest/asyncrt_utils.h"
+#include "MsgTypes.h"
+
+TableMeta* TableMetaFromJSON ( web::json::value & object );
+ColumnMeta* ColumnMetaFromJSON ( web::json::value & object );
+SelectedColumnMeta* SelectedColumnMetaFromJSON ( web::json::value & object );
+std::unique_ptr<MetadataResponse> MetadataResponseFromJSON ( web::json::value & object );
+std::unique_ptr<SQLResponse> SQLResponseFromJSON ( web::json::value & object );
+std::unique_ptr<ErrorMessage> ErrorMessageFromJSON ( web::json::value & object );
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/MsgTypes.h
----------------------------------------------------------------------
diff --git a/odbc/Common/MsgTypes.h b/odbc/Common/MsgTypes.h
new file mode 100644
index 0000000..ba5b427
--- /dev/null
+++ b/odbc/Common/MsgTypes.h
@@ -0,0 +1,415 @@
+// ----------------------------------------------------------------------------
+//
+// File: MsgTypes.h
+//
+// Purpose: Message protocols for kylin deriver to connect with Rest Server
+//
+// Author: Hongbin Ma
+//
+
+#pragma once
+
+#include <string>
+#include <vector>
+#include <sstream>
+
+#include "StringUtils.h"
+#include "JDBCODBC.h"
+
+#define ASSIGN_IF_NOT_NULL(x,y,z) if(!y.is_null())x=y.z
+#define x_ASSIGN_IF_NOT_NULL(x,y,z) if(!y.is_null())x=wstring2string(y.z)
+
+using namespace std;
+
+class TableMeta {
+ public:
+ string TABLE_CAT;
+ string TABLE_SCHEM;
+ string TABLE_NAME;
+ string TABLE_TYPE;
+ string REMARKS;
+ string TYPE_CAT;
+ string TYPE_SCHEM;
+ string TYPE_NAME;
+ string SELF_REFERENCING_COL_NAME;
+ string REF_GENERATION;
+
+};
+
+class ColumnMeta {
+ public:
+ string TABLE_CAT;
+ string TABLE_SCHEM;
+ string TABLE_NAME;
+ string COLUMN_NAME;
+ int DATA_TYPE;
+ string TYPE_NAME;
+ int COLUMN_SIZE;
+ int BUFFER_LENGTH;
+ int DECIMAL_DIGITS;
+ int NUM_PREC_RADIX;
+ int NULLABLE;
+ string REMARKS;
+ string COLUMN_DEF;
+ int SQL_DATA_TYPE;
+ int SQL_DATETIME_SUB;
+ int CHAR_OCTET_LENGTH;
+ int ORDINAL_POSITION;
+ string IS_NULLABLE;
+ string SCOPE_CATLOG;
+ string SCOPE_SCHEMA;
+ string SCOPE_TABLE;
+ short SOURCE_DATA_TYPE;
+ string IS_AUTOINCREMENT;
+
+};
+
+class MetadataResponse {
+ public:
+ std::vector<TableMeta*> tableMetas;
+ std::vector<ColumnMeta*> columnMetas;
+
+ ~MetadataResponse() {
+ for ( std::vector<TableMeta*>::size_type i = 0 ; i < tableMetas.size(); ++i ) {
+ TableMeta* p = tableMetas.at ( i );
+ delete p;
+ }
+
+ for ( std::vector<ColumnMeta*>::size_type i = 0 ; i < columnMetas.size(); ++i ) {
+ ColumnMeta* p = columnMetas.at ( i );
+ delete p;
+ }
+ }
+
+};
+
+class SelectedColumnMeta {
+ public:
+ bool isAutoIncrement;
+ bool isCaseSensitive;
+ bool isSearchable;
+ bool isCurrency;
+ int isNullable ;//0:nonull, 1:nullable, 2: nullableunknown
+ bool isSigned ;
+ int displaySize;
+ string label;// AS keyword
+ string name ;
+ string schemaName ;
+ string catelogName;
+ string tableName;
+ int precision;
+ int scale;
+ int columnType ;// the orig value passed from REST is java.sql.Types, we convert it to SQL Type
+ string columnTypeName ;
+ bool isReadOnly;
+ bool isWritable ;
+ bool isDefinitelyWritable ;
+
+};
+
+class SQLRowContent {
+ public:
+ std::vector<wstring> contents;
+
+};
+
+class SQLResponse {
+ public:
+ // the data type for each column
+ std::vector<SelectedColumnMeta*> columnMetas;
+
+ // the results rows, each row contains several columns
+ std::vector<SQLRowContent*> results;
+
+ // if not select query, only return affected row count
+ int affectedRowCount;
+
+ // flag indicating whether an exception occurred
+ bool isException;
+
+ // if isException, the detailed exception message
+ wstring exceptionMessage;
+
+ ~SQLResponse() {
+ for ( std::vector<SelectedColumnMeta*>::size_type i = 0 ; i < columnMetas.size(); ++i ) {
+ SelectedColumnMeta* p = columnMetas.at ( i );
+ delete p;
+ }
+
+ for ( std::vector<SQLRowContent*>::size_type i = 0 ; i < results.size(); ++i ) {
+ SQLRowContent* p = results.at ( i );
+ delete p;
+ }
+ }
+
+ static std::unique_ptr<SQLResponse> MakeResp4SQLTables ( MetadataResponse* meta ) {
+ std::unique_ptr<SQLResponse> ret ( new SQLResponse() );
+ FillColumnMetas4SQLTables ( ret.get() );
+
+ for ( auto i = meta->tableMetas.begin(); i != meta->tableMetas.end(); i++ ) {
+ SQLRowContent* temp = new SQLRowContent();
+ temp->contents.push_back ( string2wstring ( ( *i )->TABLE_CAT ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->TABLE_SCHEM ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->TABLE_NAME ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->TABLE_TYPE ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->REMARKS ) );
+ ret->results.push_back ( temp );
+ }
+
+ return ret;
+ }
+
+ static std::unique_ptr<SQLResponse> MakeResp4SQLColumns ( MetadataResponse* meta, char* tableName, char* columnName ) {
+ std::unique_ptr<SQLResponse> ret ( new SQLResponse() );
+ FillColumnMetas4SQLColumns ( ret.get() );
+
+ for ( auto i = meta->columnMetas.begin(); i != meta->columnMetas.end(); i++ ) {
+ //filter
+ if ( tableName != NULL && _stricmp ( tableName, ( *i )->TABLE_NAME.c_str() ) != 0 )
+ { continue; }
+
+ if ( columnName != NULL && _stricmp ( columnName, ( *i )->COLUMN_NAME.c_str() ) != 0 )
+ { continue; }
+
+ SQLRowContent* temp = new SQLRowContent();
+ temp->contents.push_back ( string2wstring ( ( *i )->TABLE_CAT ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->TABLE_SCHEM ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->TABLE_NAME ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->COLUMN_NAME ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->DATA_TYPE ) ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->TYPE_NAME ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->COLUMN_SIZE ) ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->BUFFER_LENGTH ) ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->DECIMAL_DIGITS ) ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->NUM_PREC_RADIX ) ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->NULLABLE ) ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->REMARKS ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->COLUMN_DEF ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->SQL_DATA_TYPE ) ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->SQL_DATETIME_SUB ) ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->CHAR_OCTET_LENGTH ) ) );
+ temp->contents.push_back ( string2wstring ( std::to_string ( ( *i )->ORDINAL_POSITION ) ) );
+ temp->contents.push_back ( string2wstring ( ( *i )->IS_NULLABLE ) );
+ temp->contents.push_back ( L"0" ); //user_data_type
+ ret->results.push_back ( temp );
+ }
+
+ return ret;
+ }
+
+ static std::string GetString ( int i ) {
+ std::ostringstream ss;
+ ss << i;
+ return ss.str();
+ }
+
+ static void FillColumnMetas4SQLTables ( SQLResponse* sqlResp ) {
+ SelectedColumnMeta* m1 = new SelectedColumnMeta();
+ m1->label = "TABLE_CAT";
+ m1->name = "TABLE_CAT";
+ m1->displaySize = 128;
+ m1->scale = 0;
+ m1->isNullable = 1;
+ m1->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m2 = new SelectedColumnMeta();
+ m2->label = "TABLE_SCHEM";
+ m2->name = "TABLE_SCHEM";
+ m2->displaySize = 128;
+ m2->scale = 0;
+ m2->isNullable = 1;
+ m2->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m3 = new SelectedColumnMeta();
+ m3->label = "TABLE_NAME";
+ m3->name = "TABLE_NAME";
+ m3->displaySize = 128;
+ m3->scale = 0;
+ m3->isNullable = 1;
+ m3->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m4 = new SelectedColumnMeta();
+ m4->label = "TABLE_TYPE";
+ m4->name = "TABLE_TYPE";
+ m4->displaySize = 32;
+ m4->scale = 0;
+ m4->isNullable = 1;
+ m4->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m5 = new SelectedColumnMeta();
+ m5->label = "REMARKS";
+ m5->name = "REMARKS";
+ m5->displaySize = 254;
+ m5->scale = 0;
+ m5->isNullable = 1;
+ m5->columnType = ODBCTypes::ODBC_WVarChar;
+ sqlResp->columnMetas.push_back ( m1 );
+ sqlResp->columnMetas.push_back ( m2 );
+ sqlResp->columnMetas.push_back ( m3 );
+ sqlResp->columnMetas.push_back ( m4 );
+ sqlResp->columnMetas.push_back ( m5 );
+ }
+
+ static void FillColumnMetas4SQLColumns ( SQLResponse* sqlResp ) {
+ SelectedColumnMeta* m1 = new SelectedColumnMeta();
+ m1->label = "TABLE_CAT";
+ m1->name = "TABLE_CAT";
+ m1->displaySize = 128;
+ m1->scale = 0;
+ m1->isNullable = 1;
+ m1->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m2 = new SelectedColumnMeta();
+ m2->label = "TABLE_SCHEM";
+ m2->name = "TABLE_SCHEM";
+ m2->displaySize = 128;
+ m2->scale = 0;
+ m2->isNullable = 1;
+ m2->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m3 = new SelectedColumnMeta();
+ m3->label = "TABLE_NAME";
+ m3->name = "TABLE_NAME";
+ m3->displaySize = 128;
+ m3->scale = 0;
+ m3->isNullable = 1;
+ m3->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m4 = new SelectedColumnMeta();
+ m4->label = "COLUMN_NAME";
+ m4->name = "COLUMN_NAME";
+ m4->displaySize = 128;
+ m4->scale = 0;
+ m4->isNullable = 0;
+ m4->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m5 = new SelectedColumnMeta();
+ m5->label = "DATA_TYPE";
+ m5->name = "DATA_TYPE";
+ m5->displaySize = 5;
+ m5->scale = 0;
+ m5->isNullable = 0;
+ m5->columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m6 = new SelectedColumnMeta();
+ m6->label = "TYPE_NAME";
+ m6->name = "TYPE_NAME";
+ m6->displaySize = 128;
+ m6->scale = 0;
+ m6->isNullable = 0;
+ m6->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m7 = new SelectedColumnMeta();
+ m7->label = "COLUMN_SIZE";
+ m7->name = "COLUMN_SIZE";
+ m7->displaySize = 10;
+ m7->scale = 0;
+ m7->isNullable = 1;
+ m7->columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m8 = new SelectedColumnMeta();
+ m8->label = "BUFFER_LENGTH";
+ m8->name = "BUFFER_LENGTH";
+ m8->displaySize = 10;
+ m8->scale = 0;
+ m8->isNullable = 1;
+ m8->columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m9 = new SelectedColumnMeta();
+ m9->label = "DECIMAL_DIGITS";
+ m9->name = "DECIMAL_DIGITS";
+ m9->displaySize = 5;
+ m9->scale = 0;
+ m9->isNullable = 1;
+ m9->columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m10 = new SelectedColumnMeta();
+ m10->label = "NUM_PREC_RADIX";
+ m10->name = "NUM_PREC_RADIX";
+ m10->displaySize = 5;
+ m10->scale = 0;
+ m10->isNullable = 1;
+ m10->columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m11 = new SelectedColumnMeta();
+ m11->label = "NULLABLE";
+ m11->name = "NULLABLE";
+ m11->displaySize = 5;
+ m11->scale = 0;
+ m11->isNullable = 0;
+ m11->columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m12 = new SelectedColumnMeta();
+ m12->label = "REMARKS";
+ m12->name = "REMARKS";
+ m12->displaySize = 128;
+ m12->scale = 0;
+ m12->isNullable = 1;
+ m12->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m13 = new SelectedColumnMeta();
+ m13->label = "COLUMN_DEF";
+ m13->name = "COLUMN_DEF";
+ m13->displaySize = 4000;
+ m13->scale = 0;
+ m13->isNullable = 1;
+ m13->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m14 = new SelectedColumnMeta();
+ m14->label = "SQL_DATA_TYPE";
+ m14->name = "SQL_DATA_TYPE";
+ m14->displaySize = 5;
+ m14->scale = 0;
+ m14->isNullable = 0;
+ m14->columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m15 = new SelectedColumnMeta();
+ m15->label = "SQL_DATETIME_SUB";
+ m15->name = "SQL_DATETIME_SUB";
+ m15->displaySize = 5;
+ m15->scale = 0;
+ m15->isNullable = 1;
+ m15->columnType = ODBCTypes::ODBC_SmallInt;
+ SelectedColumnMeta* m16 = new SelectedColumnMeta();
+ m16->label = "CHAR_OCTET_LENGTH";
+ m16->name = "CHAR_OCTET_LENGTH";
+ m16->displaySize = 10;
+ m16->scale = 0;
+ m16->isNullable = 1;
+ m16->columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m17 = new SelectedColumnMeta();
+ m17->label = "ORDINAL_POSITION";
+ m17->name = "ORDINAL_POSITION";
+ m17->displaySize = 10;
+ m17->scale = 0;
+ m17->isNullable = 0;
+ m17->columnType = ODBCTypes::ODBC_Integer;
+ SelectedColumnMeta* m18 = new SelectedColumnMeta();
+ m18->label = "IS_NULLABLE";
+ m18->name = "IS_NULLABLE";
+ m18->displaySize = 254;
+ m18->scale = 0;
+ m18->isNullable = 1;
+ m18->columnType = ODBCTypes::ODBC_WVarChar;
+ SelectedColumnMeta* m19 = new SelectedColumnMeta();
+ m19->label = "USER_DATA_TYPE";
+ m19->name = "USER_DATA_TYPE";
+ m19->displaySize = 5;
+ m19->scale = 0;
+ m19->isNullable = 1;
+ m19->columnType = ODBCTypes::ODBC_SmallInt;
+ sqlResp->columnMetas.push_back ( m1 );
+ sqlResp->columnMetas.push_back ( m2 );
+ sqlResp->columnMetas.push_back ( m3 );
+ sqlResp->columnMetas.push_back ( m4 );
+ sqlResp->columnMetas.push_back ( m5 );
+ sqlResp->columnMetas.push_back ( m6 );
+ sqlResp->columnMetas.push_back ( m7 );
+ sqlResp->columnMetas.push_back ( m8 );
+ sqlResp->columnMetas.push_back ( m9 );
+ sqlResp->columnMetas.push_back ( m10 );
+ sqlResp->columnMetas.push_back ( m11 );
+ sqlResp->columnMetas.push_back ( m12 );
+ sqlResp->columnMetas.push_back ( m13 );
+ sqlResp->columnMetas.push_back ( m14 );
+ sqlResp->columnMetas.push_back ( m15 );
+ sqlResp->columnMetas.push_back ( m16 );
+ sqlResp->columnMetas.push_back ( m17 );
+ sqlResp->columnMetas.push_back ( m18 );
+ sqlResp->columnMetas.push_back ( m19 );
+ }
+
+};
+
+
+
+class ErrorMessage {
+ public:
+ wstring url;
+
+ // if isException, the detailed exception message
+ wstring msg;
+
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/QueryCache.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/QueryCache.cpp b/odbc/Common/QueryCache.cpp
new file mode 100644
index 0000000..6c5f869
--- /dev/null
+++ b/odbc/Common/QueryCache.cpp
@@ -0,0 +1,69 @@
+#include "QueryCache.h"
+#include <cpprest/http_client.h>
+#include <cpprest/filestream.h>
+#include <cpprest/json.h>
+#include <cpprest/uri.h>
+#include <regex>
+#include "Dump.h"
+#include "JsonConverter.h"
+
+
+const wchar_t* alwaysFailQueries[7] = {
+ L"(\\s)*CREATE(\\s)*LOCAL(\\s)*TEMPORARY(\\s)*TABLE(\\s)*\"XTableau_B_Connect\"(\\s)*\\((\\s)*\"COL\"(\\s)*INTEGER(\\s)*\\)(\\s)*ON(\\s)*COMMIT(\\s)*PRESERVE(\\s)*ROWS(\\s)*",
+ L"(\\s)*DROP(\\s)*TABLE(\\s)*\"XTableau_B_Connect\"(\\s)*",
+ L"(\\s)*SELECT(\\s)*TOP(\\s)*1(\\s)*\"COL\"(\\s)*FROM(\\s)*\\(SELECT(\\s)*1(\\s)*AS(\\s)*\"COL\"(\\s)*\\)(\\s)*AS(\\s)*\"CHECKTOP\"(\\s)*",
+ L"(\\s)*SELECT(\\s)*\"SUBCOL\"(\\s)*AS(\\s)*\"COL\"(\\s)*FROM(\\s)*\\((\\s)*SELECT(\\s)*1(\\s)*AS(\\s)*\"SUBCOL\"(\\s)*\\)(\\s)*\"SUBQUERY\"(\\s)*GROUP(\\s)*BY(\\s)*1(\\s)*",
+ L"(\\s)*SELECT(\\s)*\"SUBCOL\"(\\s)*AS(\\s)*\"COL\"(\\s)*FROM(\\s)*\\((\\s)*SELECT(\\s)*1(\\s)*AS(\\s)*\"SUBCOL\"(\\s)*\\)(\\s)*\"SUBQUERY\"(\\s)*GROUP(\\s)*BY(\\s)*\"COL\"(\\s)*",
+ L"(\\s)*INSERT(\\s)*INTO(\\s)*\"XTableau_C_Connect\"(\\s)*SELECT(\\s)*\\*(\\s)*FROM(\\s)*\\(SELECT(\\s)*1(\\s)*AS(\\s)*COL(\\s)*\\)(\\s)*AS(\\s)*CHECKTEMP(\\s)*LIMIT(\\s)*1(\\s)*",
+ L"(\\s)*DROP(\\s)*TABLE(\\s)*\"XTableau_C_Connect\"(\\s)*"
+};
+
+const wchar_t* alwaysSuccessQueries[3] = {
+ L"(\\s)*SELECT(\\s)*1(\\s)*",
+ L"(\\s)*SELECT(\\s)*\"COL\"(\\s)*FROM(\\s)*\\(SELECT(\\s)*1(\\s)*AS(\\s)*\"COL\"\\)(\\s)*AS(\\s)*\"SUBQUERY\"(\\s)*",
+ L"(\\s)*SELECT(\\s)*\"COL\"(\\s)*FROM(\\s)*\\(SELECT(\\s)*1(\\s)*AS(\\s)*\"COL\"\\)(\\s)*AS(\\s)*\"CHECKTOP\"(\\s)*LIMIT(\\s)*1(\\s)*"
+};
+
+const wchar_t* alwaysSuccessResults[3] = {
+ L"{\"columnMetas\":[{\"isNullable\":2,\"displaySize\":11,\"label\":\"COL\",\"name\":\"COL\",\"schemaName\":\"\",\"catelogName\":\"\",\"tableName\":\"\",\"precision\":10,\"scale\":0,\"columnType\":4,\"columnTypeName\":\"int4\",\"writable\":true,\"caseSensitive\":false,\"autoIncrement\":false,\"searchable\":true,\"currency\":false,\"signed\":true,\"definitelyWritable\":false,\"readOnly\":false}],\"results\":[[\"1\"]],\"isResultsFlatten\":false,\"flattenResult\":null,\"flattenResultOriginalSize\":0,\"cubes\":null,\"affectedRowCount\":0,\"isException\":false,\"exceptionMessage\":null,\"duration\":0.002,\"partial\":false}",
+ L"{\"columnMetas\":[{\"isNullable\":2,\"displaySize\":11,\"label\":\"COL\",\"name\":\"COL\",\"schemaName\":\"\",\"catelogName\":\"\",\"tableName\":\"\",\"precision\":10,\"scale\":0,\"columnType\":4,\"columnTypeName\":\"int4\",\"writable\":true,\"caseSensitive\":false,\"autoIncrement\":false,\"searchable\":true,\"currency\":false,\"signed\":true,\"definitelyWritable\":false,\"readOnly\":false}],\"results\":[[\"1\"]],\"isResultsFlatten\":false,\"flattenResult\":null,\"flattenResultOriginalSize\":0,\"cubes\":null,\"affectedRowCount\":0,\"isException\":false,\"exceptionMessage\":null,\"duration\":0.002,\"partial\":false}",
+ L"{\"columnMetas\":[{\"isNullable\":2,\"displaySize\":11,\"label\":\"COL\",\"name\":\"COL\",\"schemaName\":\"\",\"catelogName\":\"\",\"tableName\":\"\",\"precision\":10,\"scale\":0,\"columnType\":4,\"columnTypeName\":\"int4\",\"writable\":true,\"caseSensitive\":false,\"autoIncrement\":false,\"searchable\":true,\"currency\":false,\"signed\":true,\"definitelyWritable\":false,\"readOnly\":false}],\"results\":[[\"1\"]],\"isResultsFlatten\":false,\"flattenResult\":null,\"flattenResultOriginalSize\":0,\"cubes\":null,\"affectedRowCount\":0,\"isException\":false,\"exceptionMessage\":null,\"duration\":0.002,\"partial\":false}"
+};
+
+int findQuery ( const wchar_t* sql, const wchar_t** regexs, int size ) {
+ for ( int i = 0; i < size; ++i ) {
+ std::tr1::wregex rgx ( regexs[i], regex_constants::icase );
+ bool match = std::tr1::regex_search ( sql, rgx );
+
+ if ( match ) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+int findInAlwaysSuccessQuery ( const wchar_t* sql ) {
+ return findQuery ( sql, alwaysSuccessQueries, sizeof ( alwaysSuccessQueries ) / sizeof ( wchar_t* ) );
+}
+
+int findInAlwaysFailQuery ( const wchar_t* sql ) {
+ return findQuery ( sql, alwaysFailQueries, sizeof ( alwaysFailQueries ) / sizeof ( wchar_t* ) );
+}
+
+unique_ptr<SQLResponse> loadCache ( const wchar_t* query ) {
+ int index = 0;
+
+ if ( findInAlwaysFailQuery ( query ) >= 0 ) {
+ throw exception ( "Unsupported SQL" );
+ }
+
+ else if ( ( index = findInAlwaysSuccessQuery ( query ) ) >= 0 ) {
+ web::json::value v = web::json::value::parse ( alwaysSuccessResults[index] );
+ std::unique_ptr<SQLResponse> r = SQLResponseFromJSON ( v );
+ //overwrite(r.get());
+ return r;
+ }
+
+ return NULL;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/QueryCache.h
----------------------------------------------------------------------
diff --git a/odbc/Common/QueryCache.h b/odbc/Common/QueryCache.h
new file mode 100644
index 0000000..e3e55e3
--- /dev/null
+++ b/odbc/Common/QueryCache.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "MsgTypes.h"
+
+unique_ptr<SQLResponse> loadCache ( const wchar_t* query );
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/REST.cpp
----------------------------------------------------------------------
diff --git a/odbc/Common/REST.cpp b/odbc/Common/REST.cpp
new file mode 100644
index 0000000..b008f4d
--- /dev/null
+++ b/odbc/Common/REST.cpp
@@ -0,0 +1,363 @@
+#include <cpprest/http_client.h>
+#include <cpprest/filestream.h>
+#include <cpprest/json.h>
+#include <cpprest/uri.h>
+#include <string>
+#include <windows.h>
+#include "Base64.h"
+#include "StringUtils.h"
+#include "REST.h"
+#include "Gzip.h"
+#include "QueryCache.h"
+#include "JsonConverter.h"
+
+#include <ctime>
+#include <fcntl.h>
+#include <io.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+
+using namespace utility;
+using namespace web::http;
+using namespace web::http::client;
+using namespace concurrency::streams;
+using namespace web;
+using namespace web::json;
+
+void printLog ( const char* msg ) {
+ time_t now = time ( 0 );
+ struct tm tstruct;
+ char buffer[100];
+ tstruct = *localtime ( &now );
+ strftime ( buffer, 100, "%Y-%m-%d.%X", &tstruct );
+ printf ( buffer );
+ printf ( "\n" );
+ printf ( msg );
+ printf ( "\n" );
+}
+
+/// <summary>
+/// Find the longest length
+/// </summary>
+/// <param name="results"></param>
+/// <param name="column"></param>
+/// <returns></returns>
+int ScanForLength ( std::vector<SQLRowContent*> results, int column ) {
+ int max = 0;
+
+ for ( auto p = results.begin(); p < results.end(); p++ ) {
+ SQLRowContent* result = *p;
+ int length = result->contents[column].size();
+
+ if ( length > max )
+ { max = length; }
+ }
+
+ return max;
+}
+
+/// <summary>
+/// Scale is Maximum number of digits to the right of the decimal point.
+/// Find the largest scale.
+/// </summary>
+/// <param name="results"></param>
+/// <param name="column"></param>
+/// <returns></returns>
+int ScanForScale ( std::vector<SQLRowContent*> results, int column ) {
+ int max = 0;
+
+ for ( auto p = results.begin(); p < results.end(); p++ ) {
+ SQLRowContent* result = *p;
+ int length = result->contents[column].size();
+ int dotLocation = result->contents[column].find ( L"." );
+
+ if ( dotLocation != string::npos ) {
+ int scale = length - 1 - dotLocation;
+
+ if ( scale > max )
+ { max = scale; }
+ }
+ }
+
+ return max;
+}
+
+
+void overwrite ( SQLResponse* res ) {
+ for ( int i = 0; i < ( int ) res->columnMetas.size(); ++i ) {
+ SelectedColumnMeta* meta = res->columnMetas[i];
+ ODBCTypes t = ( ODBCTypes ) meta->columnType;
+ int scale = 0;
+ int length = 0;
+
+ switch ( t ) {
+ case ODBCTypes::ODBC_Numeric:
+ case ODBCTypes::ODBC_Decimal:
+ case ODBCTypes::ODBC_Double:
+ case ODBCTypes::ODBC_Real:
+ case ODBCTypes::ODBC_Float:
+ scale = ScanForScale ( res->results, i );
+ meta->scale = scale;
+ meta->scale = 4;
+ break;
+
+ case ODBCTypes::ODBC_Char:
+ case ODBCTypes::ODBC_VarChar:
+ case ODBCTypes::ODBC_LongVarChar:
+ case ODBCTypes::ODBC_WChar:
+ case ODBCTypes::ODBC_WVarChar:
+ case ODBCTypes::ODBC_WLongVarChar:
+ case ODBCTypes::ODBC_DateTime:
+ case ODBCTypes::ODBC_Type_Date:
+ case ODBCTypes::ODBC_Type_Time:
+ case ODBCTypes::ODBC_Type_Timestamp:
+ length = ScanForLength ( res->results, i );
+ meta->displaySize = length;
+ meta->precision = length;
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+std::wstring completeServerStr ( char* serverStr, long port ) {
+ //concat the whole server string
+ char completeServerAddr[256];
+ char portSuffix[10];
+ sprintf ( portSuffix, ":%d", port );
+
+ if ( strstr ( serverStr, "https://" ) == serverStr ||
+ strstr ( serverStr, "http://" ) == serverStr ) {
+ sprintf ( completeServerAddr, "%s", serverStr );
+ }
+
+ else {
+ // by default use https
+ sprintf ( completeServerAddr, "https://%s", serverStr );
+ }
+
+ if ( strstr ( serverStr, portSuffix ) == NULL ) {
+ strcat ( completeServerAddr, portSuffix );
+ }
+
+ return string2wstring ( std::string ( completeServerAddr ) );
+}
+
+
+http_request makeRequest ( const char* username, const char* passwd, const wchar_t* uriStr , http::method method ) {
+ http_request request;
+ char s[128];
+ sprintf ( s, "%s:%s", username, passwd );
+ std::string b64 = base64_encode ( ( unsigned char const* ) s, strlen ( s ) );
+ request.set_method ( method );
+ request.set_request_uri ( uri ( uri::encode_uri ( uriStr ) ) );
+ request.headers().add ( header_names::authorization, string2wstring ( "Basic " + b64 ) );
+ request.headers().add ( header_names::content_type, "application/json" );
+ return request;
+}
+
+bool restAuthenticate ( char* serverAddr, long port, char* username, char* passwd ) {
+ wstring serverAddrW = completeServerStr ( serverAddr, port ) ;
+ http_client_config config;
+ config.set_timeout ( utility::seconds ( 300 ) );
+ http_client session ( serverAddrW, config );
+ //can get project list only when correct username/password is given
+ http_request request = makeRequest ( username, passwd, L"/kylin/api/projects", methods::GET );
+ http_response response = session.request ( request ).get();
+
+ if ( response.status_code() == status_codes::OK )
+ { return true; }
+
+ else
+ { return false; }
+}
+
+void restListProjects ( char* serverAddr, long port, char* username, char* passwd , std::vector<string>& holder ) {
+ wstring serverAddrW = completeServerStr ( serverAddr, port );
+ http_client_config config;
+ config.set_timeout ( utility::seconds ( 300 ) );
+ http_client session ( serverAddrW, config );
+ http_request request = makeRequest ( username, passwd, L"/kylin/api/projects", methods::GET );
+ http_response response = session.request ( request ).get();
+
+ if ( response.status_code() == status_codes::OK ) {
+ web::json::value projects = response.extract_json().get();
+
+ for ( auto iter = projects.as_array().begin(); iter != projects.as_array().end(); ++iter ) {
+ holder.push_back ( wstring2string ( ( *iter ) [U ( "name" )].as_string() ) );
+ }
+
+ if ( holder.size() == 0 )
+ { throw exception ( "There is no project available in this server" ); }
+ }
+
+ else if ( response.status_code() == status_codes::InternalError ) {
+ std::unique_ptr<ErrorMessage> em = ErrorMessageFromJSON ( response.extract_json().get() );
+ string errorMsg = wstring2string ( em->msg );
+ throw exception ( errorMsg.c_str() );
+ }
+
+ else {
+ throw exception ( "REST request(listproject) Invalid Response status code : " + response.status_code() );
+ }
+}
+
+std::unique_ptr<MetadataResponse> restGetMeta ( char* serverAddr, long port , char* username, char* passwd,
+ char* project ) {
+ wstring serverAddrW = completeServerStr ( serverAddr, port ) ;
+ http_client_config config;
+ config.set_timeout ( utility::seconds ( 300 ) );
+ http_client session ( serverAddrW, config );
+ std::wstringstream wss;
+ wss << L"/kylin/api/tables_and_columns" << L"?project=" << project;
+ http_request request = makeRequest ( username, passwd, wss.str().c_str(), methods::GET );
+ http_response response = session.request ( request ).get();
+
+ if ( response.status_code() == status_codes::OK ) {
+ return MetadataResponseFromJSON ( response.extract_json().get() );
+ }
+
+ else if ( response.status_code() == status_codes::Unauthorized ) {
+ throw exception ( "Username/Password Unauthorized." );
+ }
+
+ else if ( response.status_code() == status_codes::InternalError ) {
+ std::unique_ptr<ErrorMessage> em = ErrorMessageFromJSON ( response.extract_json().get() );
+ string errorMsg = wstring2string ( em->msg );
+ throw exception ( errorMsg.c_str() );
+ }
+
+ else {
+ throw exception ( "REST request(getmeta) Invalid Response status code : " + response.status_code() );
+ }
+}
+
+wstring cookQuery ( wchar_t* p ) {
+ wchar_t* q = new wchar_t[wcslen ( p ) + 1];
+ wcscpy ( q, p );
+
+ for ( int i = 0 ; i < ( int ) wcslen ( q ); i++ ) {
+ if ( q[i] == '\r' || q[i] == '\n' || q[i] == '\t' ) {
+ q[i] = ' ';
+ }
+ }
+
+ wstring ret ( q );
+ delete[] q;
+ size_t pos = 0;
+
+ for ( size_t pos = 0;; pos += 2 ) {
+ pos = ret.find ( L"\"", pos );
+
+ if ( pos == wstring::npos ) { break; }
+
+ ret.insert ( pos, L"\\" );
+ }
+
+ return ret;
+}
+
+wstring getBodyString ( http_response& response ) {
+ bool isGzipped = response.headers().has ( L"Content-Encoding" );
+
+ if ( isGzipped ) {
+ isGzipped = false;
+ http_headers::iterator iterator = response.headers().find ( L"Content-Encoding" );
+
+ if ( iterator != response.headers().end() ) {
+ wstring contentEncoding = iterator->second;
+
+ if ( contentEncoding.find ( L"gzip" ) != std::string::npos )
+ { isGzipped = true; }
+ }
+ }
+
+ container_buffer<std::string> bodyBuffer;
+ response.body().read_to_end ( bodyBuffer ).get();
+ const std::string& raw = bodyBuffer.collection();
+ std::string uncompressed;
+
+ if ( isGzipped ) {
+ bool decompressStatus = gzipInflate ( raw, uncompressed );
+
+ if ( !decompressStatus )
+ { throw exception ( "gzip decompress failed" ); }
+ }
+
+ else {
+ uncompressed = raw;
+ }
+
+ //convert the string from utf8 to wchar
+ int size_needed = ::MultiByteToWideChar ( CP_UTF8, 0, ( char* ) uncompressed.c_str(), uncompressed.size(), NULL, 0 );
+ std::wstring ret ( size_needed, 0 );
+ ::MultiByteToWideChar ( CP_UTF8, 0, ( char* ) uncompressed.c_str(), uncompressed.size(), &ret[0], size_needed );
+ return ret;
+}
+
+std::unique_ptr<SQLResponse> restQuery ( wchar_t* rawSql, char* serverAddr, long port, char* username,
+ char* passwd,
+ char* project ) {
+ //using local cache to intercept probing queries
+ std::unique_ptr<SQLResponse> cachedQueryRes = loadCache ( rawSql );
+
+ if ( cachedQueryRes != NULL )
+ { return cachedQueryRes; }
+
+ //real requesting
+ wstring serverAddrW = completeServerStr ( serverAddr, port ) ;
+ http_client_config config;
+ config.set_timeout ( utility::seconds ( 36000 ) );
+ http_client session ( serverAddrW, config );
+ http_request request = makeRequest ( username, passwd, L"/kylin/api/query", methods::POST );
+ wstring sql = cookQuery ( rawSql );
+ std::wstringstream wss;
+ wss << L"{ \"acceptPartial\": false, \"project\" : \"" << project << L"\", " << " \"sql\" : \"" << sql << L"\" }" ;
+ request.set_body ( wss.str(), L"application/json" );
+ request.headers().add ( header_names::accept_encoding, "gzip,deflate" );
+ http::status_code status;
+ http_response response;
+
+ try {
+ response = session.request ( request ).get();
+ status = response.status_code();
+ }
+
+ catch ( std::exception& e ) {
+ std::stringstream ss;
+ ss << "An exception is throw Error message: " << e.what();
+ throw exception ( ss.str().c_str() );
+ }
+
+ wstring ret = getBodyString ( response );
+
+ if ( status == status_codes::OK ) {
+ //convert to json
+ web::json::value actualRes = web::json::value::parse ( ret );
+ std::unique_ptr<SQLResponse> r = SQLResponseFromJSON ( actualRes );
+
+ if ( r->isException == true ) {
+ string expMsg = wstring2string ( r->exceptionMessage );
+ throw exception ( expMsg.c_str() );
+ }
+
+ overwrite ( r.get() );
+ return r;
+ }
+
+ else if ( status == status_codes::InternalError ) {
+ std::unique_ptr<ErrorMessage> em = ErrorMessageFromJSON ( web::json::value::parse ( ret ) );
+ string expMsg = wstring2string ( em->msg );
+ throw exception ( expMsg.c_str() );
+ }
+
+ else {
+ throw exception ( "Unknown exception in rest query with return code " + status );
+ }
+
+ return NULL;
+}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/d1dcfd15/odbc/Common/REST.h
----------------------------------------------------------------------
diff --git a/odbc/Common/REST.h b/odbc/Common/REST.h
new file mode 100644
index 0000000..99cd90f
--- /dev/null
+++ b/odbc/Common/REST.h
@@ -0,0 +1,16 @@
+#pragma once
+
+#include "vld.h"
+#include "MsgTypes.h"
+
+//REST
+bool restAuthenticate ( char* serverAddr, long port, char* username, char* passwd );
+
+void restListProjects ( char* serverAddr, long port, char* username, char* passwd, std::vector<string>& holder );
+
+std::unique_ptr<SQLResponse> restQuery ( wchar_t* rawSql, char* serverAddr, long port, char* username,
+ char* passwd,
+ char* project );
+
+std::unique_ptr<MetadataResponse> restGetMeta ( char* serverAddr, long port, char* username, char* passwd,
+ char* project );