1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-523 Add UDAF and UDAnF SDK

This commit is contained in:
David Hall
2017-07-26 11:53:08 -05:00
parent 630b113565
commit bc2a4e7795
75 changed files with 10250 additions and 4523 deletions

3
CMakeLists.txt Normal file → Executable file
View File

@ -194,10 +194,11 @@ SET (ENGINE_WE_CONFIGCPP_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/writeengine/x
SET (ENGINE_SERVER_SQL_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/sql") SET (ENGINE_SERVER_SQL_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/sql")
SET (ENGINE_SERVER_INCLUDE_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/include") SET (ENGINE_SERVER_INCLUDE_INCLUDE "${SERVER_SOURCE_ROOT_DIR}/include")
SET (ENGINE_SERVER_PCRE_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../pcre") SET (ENGINE_SERVER_PCRE_INCLUDE "${SERVER_BUILD_INCLUDE_DIR}/../pcre")
SET (ENGINE_UTILS_UDFSDK_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/utils/udfsdk")
SET (ENGINE_DEFAULT_INCLUDES ${CMAKE_BINARY_DIR} "." "../" "../../" ${SERVER_BUILD_INCLUDE_DIR}) SET (ENGINE_DEFAULT_INCLUDES ${CMAKE_BINARY_DIR} "." "../" "../../" ${SERVER_BUILD_INCLUDE_DIR})
SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_OAMAPPS_ALARMMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE}) SET (ENGINE_COMMON_INCLUDES ${ENGINE_DEFAULT_INCLUDES} ${Boost_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} ${ENGINE_UTILS_MESSAGEQCPP_INCLUDE} ${ENGINE_WE_SHARED_INCLUDE} ${ENGINE_UTILS_IDBDATAFILE_INCLUDE} ${ENGINE_UTILS_LOGGINGCPP_INCLUDE} ${ENGINE_UTILS_CONFIGCPP_INCLUDE} ${ENGINE_UTILS_COMPRESS_INCLUDE} ${ENGINE_VERSIONING_BRM_INCLUDE} ${ENGINE_UTILS_ROWGROUP_INCLUDE} ${ENGINE_UTILS_COMMON_INCLUDE} ${ENGINE_UTILS_DATACONVERT_INCLUDE} ${ENGINE_UTILS_RWLOCK_INCLUDE} ${ENGINE_UTILS_FUNCEXP_INCLUDE} ${ENGINE_OAMAPPS_ALARMMANAGER_INCLUDE} ${ENGINE_UTILS_INCLUDE} ${ENGINE_OAM_OAMCPP_INCLUDE} ${ENGINE_DBCON_DDLPKGPROC_INCLUDE} ${ENGINE_DBCON_DDLPKG_INCLUDE} ${ENGINE_DBCON_EXECPLAN_INCLUDE} ${ENGINE_UTILS_STARTUP_INCLUDE} ${ENGINE_DBCON_JOBLIST_INCLUDE} ${ENGINE_WE_WRAPPER_INCLUDE} ${ENGINE_WE_SERVER_INCLUDE} ${ENGINE_DBCON_DMLPKG_INCLUDE} ${ENGINE_WE_CLIENT_INCLUDE} ${ENGINE_DBCON_DMLPKGPROC_INCLUDE} ${ENGINE_UTILS_CACHEUTILS_INCLUDE} ${ENGINE_UTILS_MYSQLCL_INCLUDE} ${ENGINE_UTILS_QUERYTELE_INCLUDE} ${ENGINE_UTILS_THRIFT_INCLUDE} ${ENGINE_UTILS_JOINER_INCLUDE} ${ENGINE_UTILS_THREADPOOL_INCLUDE} ${ENGINE_UTILS_BATCHLDR_INCLUDE} ${ENGINE_UTILS_DDLCLEANUP_INCLUDE} ${ENGINE_UTILS_QUERYSTATS_INCLUDE} ${ENGINE_WE_CONFIGCPP_INCLUDE} ${ENGINE_SERVER_SQL_INCLUDE} ${ENGINE_SERVER_INCLUDE_INCLUDE} ${ENGINE_SERVER_PCRE_INCLUDE} ${ENGINE_UTILS_UDFSDK_INCLUDE})
ADD_SUBDIRECTORY(utils) ADD_SUBDIRECTORY(utils)
ADD_SUBDIRECTORY(oam/oamcpp) ADD_SUBDIRECTORY(oam/oamcpp)

478
dbcon/ddlpackage/ddlpackage.vpj Normal file → Executable file
View File

@ -1,242 +1,242 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdddlpackage.so" OutputFile="%bdddlpackage.so"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/dbcon/ddlpackage/"> ObjectDir="/home/dhall/genii/dbcon/ddlpackage/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dbcon/ddlpackage/" RunFromDir="/home/dhall/genii/dbcon/ddlpackage/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdddlpackage.so" OutputFile="%bdddlpackage.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dbcon/ddlpackage/" RunFromDir="/home/dhall/genii/dbcon/ddlpackage/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="altertable.cpp"/> <F N="altertable.cpp"/>
<F N="columndef.cpp"/> <F N="columndef.cpp"/>
<F N="createindex.cpp"/> <F N="createindex.cpp"/>
<F N="createtable.cpp"/> <F N="createtable.cpp"/>
<F N="ddl-gram.cpp"/> <F N="ddl-gram.cpp"/>
<F N="ddl-scan.cpp"/> <F N="ddl-scan.cpp"/>
<F N="ddlpkg.cpp"/> <F N="ddlpkg.cpp"/>
<F N="dropindex.cpp"/> <F N="dropindex.cpp"/>
<F N="droppartition.cpp"/> <F N="droppartition.cpp"/>
<F N="droptable.cpp"/> <F N="droptable.cpp"/>
<F N="gramtest.cpp"/> <F N="gramtest.cpp"/>
<F N="markpartition.cpp"/> <F N="markpartition.cpp"/>
<F N="old-tdriver.cpp"/> <F N="old-tdriver.cpp"/>
<F N="restorepartition.cpp"/> <F N="restorepartition.cpp"/>
<F N="serialize.cpp"/> <F N="serialize.cpp"/>
<F N="sqlparser.cpp"/> <F N="sqlparser.cpp"/>
<F N="sqlstatement.cpp"/> <F N="sqlstatement.cpp"/>
<F N="sqlstatementlist.cpp"/> <F N="sqlstatementlist.cpp"/>
<F N="tabledef.cpp"/> <F N="tabledef.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="ddl-gram.h"/> <F N="ddl-gram.h"/>
<F N="ddlpkg.h"/> <F N="ddlpkg.h"/>
<F N="sqlparser.h"/> <F N="sqlparser.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

480
dbcon/ddlpackageproc/ddlpackageproc.vpj Normal file → Executable file
View File

@ -1,243 +1,243 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdddlpackageproc.so" OutputFile="%bdddlpackageproc.so"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/ddlproc/"> ObjectDir="/home/dhall/genii/ddlproc/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdddlpackageproc.so" OutputFile="%bdddlpackageproc.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="altertableprocessor.cpp"/> <F N="altertableprocessor.cpp"/>
<F N="createindexprocessor.cpp"/> <F N="createindexprocessor.cpp"/>
<F N="createtableprocessor.cpp"/> <F N="createtableprocessor.cpp"/>
<F N="ddlindexpopulator.cpp"/> <F N="ddlindexpopulator.cpp"/>
<F N="ddlpackageprocessor.cpp"/> <F N="ddlpackageprocessor.cpp"/>
<F N="ddlpackageprocessorfactory.cpp"/> <F N="ddlpackageprocessorfactory.cpp"/>
<F N="dropindexprocessor.cpp"/> <F N="dropindexprocessor.cpp"/>
<F N="droppartitionprocessor.cpp"/> <F N="droppartitionprocessor.cpp"/>
<F N="droptableprocessor.cpp"/> <F N="droptableprocessor.cpp"/>
<F N="markpartitionprocessor.cpp"/> <F N="markpartitionprocessor.cpp"/>
<F N="mydriver.cpp"/> <F N="mydriver.cpp"/>
<F N="restorepartitionprocessor.cpp"/> <F N="restorepartitionprocessor.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="altertableprocessor.h"/> <F N="altertableprocessor.h"/>
<F N="createindexprocessor.h"/> <F N="createindexprocessor.h"/>
<F N="createtableprocessor.h"/> <F N="createtableprocessor.h"/>
<F N="ddlindexpopulator.h"/> <F N="ddlindexpopulator.h"/>
<F N="ddlpackageprocessor.h"/> <F N="ddlpackageprocessor.h"/>
<F N="ddlpackageprocessorfactory.h"/> <F N="ddlpackageprocessorfactory.h"/>
<F N="dropindexprocessor.h"/> <F N="dropindexprocessor.h"/>
<F N="droppartitionprocessor.h"/> <F N="droppartitionprocessor.h"/>
<F N="droptableprocessor.h"/> <F N="droptableprocessor.h"/>
<F N="markpartitionprocessor.h"/> <F N="markpartitionprocessor.h"/>
<F N="restorepartitionprocessor.h"/> <F N="restorepartitionprocessor.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

504
dbcon/dmlpackage/dmlpackage.vpj Normal file → Executable file
View File

@ -1,255 +1,255 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bddmlpackage.so" OutputFile="%bddmlpackage.so"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/dbcon/dmlpackage/"> ObjectDir="/home/dhall/genii/dbcon/dmlpackage/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dbcon/dmlpackage/" RunFromDir="/home/dhall/genii/dbcon/dmlpackage/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make -fMakefile"/> <Exec CmdLine="make -fMakefile"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bddmlpackage.so" OutputFile="%bddmlpackage.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dbcon/dmlpackage/" RunFromDir="/home/dhall/genii/dbcon/dmlpackage/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make -fMakefile"/> <Exec CmdLine="make -fMakefile"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="calpontdmlfactory.cpp"/> <F N="calpontdmlfactory.cpp"/>
<F N="calpontdmlpackage.cpp"/> <F N="calpontdmlpackage.cpp"/>
<F N="commanddmlpackage.cpp"/> <F N="commanddmlpackage.cpp"/>
<F N="deletedmlpackage.cpp"/> <F N="deletedmlpackage.cpp"/>
<F N="dml-gram.cpp"/> <F N="dml-gram.cpp"/>
<F N="dml-scan.cpp"/> <F N="dml-scan.cpp"/>
<F N="dmlcolumn.cpp"/> <F N="dmlcolumn.cpp"/>
<F N="dmlobject.cpp"/> <F N="dmlobject.cpp"/>
<F N="dmlparser.cpp"/> <F N="dmlparser.cpp"/>
<F N="dmlpkg.cpp"/> <F N="dmlpkg.cpp"/>
<F N="dmltable.cpp"/> <F N="dmltable.cpp"/>
<F N="gramtest.cpp"/> <F N="gramtest.cpp"/>
<F N="insertdmlpackage.cpp"/> <F N="insertdmlpackage.cpp"/>
<F N="mysqldmlstatement.cpp"/> <F N="mysqldmlstatement.cpp"/>
<F N="oracledmlstatement.cpp"/> <F N="oracledmlstatement.cpp"/>
<F N="row.cpp"/> <F N="row.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
<F N="updatedmlpackage.cpp"/> <F N="updatedmlpackage.cpp"/>
<F N="vendordmlstatement.cpp"/> <F N="vendordmlstatement.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="calpontdmlfactory.h"/> <F N="calpontdmlfactory.h"/>
<F N="calpontdmlpackage.h"/> <F N="calpontdmlpackage.h"/>
<F N="commanddmlpackage.h"/> <F N="commanddmlpackage.h"/>
<F N="deletedmlpackage.h"/> <F N="deletedmlpackage.h"/>
<F N="dml-gram.h"/> <F N="dml-gram.h"/>
<F N="dmlcolumn.h"/> <F N="dmlcolumn.h"/>
<F N="dmlobject.h"/> <F N="dmlobject.h"/>
<F N="dmlpackage.h"/> <F N="dmlpackage.h"/>
<F N="dmlparser.h"/> <F N="dmlparser.h"/>
<F N="dmlpkg.h"/> <F N="dmlpkg.h"/>
<F N="dmltable.h"/> <F N="dmltable.h"/>
<F N="insertdmlpackage.h"/> <F N="insertdmlpackage.h"/>
<F N="mysqldmlstatement.h"/> <F N="mysqldmlstatement.h"/>
<F N="oracledmlstatement.h"/> <F N="oracledmlstatement.h"/>
<F N="row.h"/> <F N="row.h"/>
<F N="updatedmlpackage.h"/> <F N="updatedmlpackage.h"/>
<F N="vendordmlstatement.h"/> <F N="vendordmlstatement.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

5
dbcon/dmlpackageproc/deletepackageprocessor.cpp Normal file → Executable file
View File

@ -458,16 +458,15 @@ namespace dmlpackageprocessor
} }
// XXXST: take out the 'true' when all jobsteps have been made st-compatible // XXXST: take out the 'true' when all jobsteps have been made st-compatible
uint32_t amount = rgData.deserialize(msg, true); rgData.deserialize(msg, true);
rowGroup->setData(&rgData); rowGroup->setData(&rgData);
//rowGroup->setData(const_cast<uint8_t*>(msg.buf())); //rowGroup->setData(const_cast<uint8_t*>(msg.buf()));
err = (rowGroup->getStatus() != 0); err = (rowGroup->getStatus() != 0);
if (err) if (err)
{ {
msgBk.advance(amount);
//msgBk.advance(rowGroup->getDataSize()); //msgBk.advance(rowGroup->getDataSize());
string errorMsg; string errorMsg;
msgBk >> errorMsg; msg >> errorMsg;
logging::Message::Args args; logging::Message::Args args;
logging::Message message(2); logging::Message message(2);
args.add("Delete Failed: "); args.add("Delete Failed: ");

466
dbcon/dmlpackageproc/dmlpackageproc.vpj Normal file → Executable file
View File

@ -1,236 +1,236 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bddmlpackageproc.so" OutputFile="%bddmlpackageproc.so"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/dbcon/dmlpackageproc/"> ObjectDir="/home/dhall/genii/dbcon/dmlpackageproc/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dbcon/dmlpackageproc/" RunFromDir="/home/dhall/genii/dbcon/dmlpackageproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bddmlpackageproc.so" OutputFile="%bddmlpackageproc.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dbcon/dmlpackageproc/" RunFromDir="/home/dhall/genii/dbcon/dmlpackageproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="autoincrementdata.cpp"/> <F N="autoincrementdata.cpp"/>
<F N="commandpackageprocessor.cpp"/> <F N="commandpackageprocessor.cpp"/>
<F N="deletepackageprocessor.cpp"/> <F N="deletepackageprocessor.cpp"/>
<F N="dmlpackageprocessor.cpp"/> <F N="dmlpackageprocessor.cpp"/>
<F N="dmlpackageprocessorfactory.cpp"/> <F N="dmlpackageprocessorfactory.cpp"/>
<F N="insertpackageprocessor.cpp"/> <F N="insertpackageprocessor.cpp"/>
<F N="tablelockdata.cpp"/> <F N="tablelockdata.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
<F N="updatepackageprocessor.cpp"/> <F N="updatepackageprocessor.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="autoincrementdata.h"/> <F N="autoincrementdata.h"/>
<F N="commandpackageprocessor.h"/> <F N="commandpackageprocessor.h"/>
<F N="deletepackageprocessor.h"/> <F N="deletepackageprocessor.h"/>
<F N="dmlpackageprocessor.h"/> <F N="dmlpackageprocessor.h"/>
<F N="dmlpackageprocessorfactory.h"/> <F N="dmlpackageprocessorfactory.h"/>
<F N="insertpackageprocessor.h"/> <F N="insertpackageprocessor.h"/>
<F N="tablelockdata.h"/> <F N="tablelockdata.h"/>
<F N="updatepackageprocessor.h"/> <F N="updatepackageprocessor.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

5
dbcon/dmlpackageproc/updatepackageprocessor.cpp Normal file → Executable file
View File

@ -512,16 +512,15 @@ uint64_t UpdatePackageProcessor::fixUpRows(dmlpackage::CalpontDMLPackage& cpacka
//timer.stop("Meta"); //timer.stop("Meta");
continue; continue;
} }
uint32_t amount = rgData.deserialize(msg, true); rgData.deserialize(msg, true);
rowGroup->setData(&rgData); rowGroup->setData(&rgData);
//rowGroup->setData(const_cast<uint8_t*>(msg.buf())); //rowGroup->setData(const_cast<uint8_t*>(msg.buf()));
err = (rowGroup->getStatus() != 0); err = (rowGroup->getStatus() != 0);
if (err) if (err)
{ {
msgBk.advance(amount);
//msgBk.advance(rowGroup->getDataSize()); //msgBk.advance(rowGroup->getDataSize());
string errorMsg; string errorMsg;
msgBk >> errorMsg; msg >> errorMsg;
logging::Message::Args args; logging::Message::Args args;
logging::Message message(2); logging::Message message(2);
args.add("Update Failed: "); args.add("Update Failed: ");

5
dbcon/execplan/CMakeLists.txt Normal file → Executable file
View File

@ -1,5 +1,5 @@
include_directories( ${ENGINE_COMMON_INCLUDES} ) include_directories( ${ENGINE_COMMON_INCLUDES} ${ENGINE_UTILS_UDFSDK_INCLUDE} )
########### next target ############### ########### next target ###############
@ -41,7 +41,8 @@ set(execplan_LIB_SRCS
treenode.cpp treenode.cpp
treenodeimpl.cpp treenodeimpl.cpp
vendorexecutionplan.cpp vendorexecutionplan.cpp
windowfunctioncolumn.cpp) windowfunctioncolumn.cpp
udafcolumn.cpp)
add_library(execplan SHARED ${execplan_LIB_SRCS}) add_library(execplan SHARED ${execplan_LIB_SRCS})

3
dbcon/execplan/aggregatecolumn.h Normal file → Executable file
View File

@ -70,7 +70,8 @@ public:
BIT_AND, BIT_AND,
BIT_OR, BIT_OR,
BIT_XOR, BIT_XOR,
GROUP_CONCAT GROUP_CONCAT,
UDAF
}; };
/** /**

4
dbcon/execplan/calpontsystemcatalog.cpp Normal file → Executable file
View File

@ -1051,7 +1051,7 @@ const CalpontSystemCatalog::ColType CalpontSystemCatalog::colType(const OID& Oid
colMap.insert(CMVT_(scale, srcp)); colMap.insert(CMVT_(scale, srcp));
srcp.reset(col[8]); srcp.reset(col[8]);
colMap.insert(CMVT_(precision, srcp)); colMap.insert(CMVT_(precision, srcp));
// TODO: NULL value handling & convert to boost::any // TODO: NULL value handling & convert to static_any::any
// delete this manually at fcn exit // delete this manually at fcn exit
srcp.reset(col[9]); srcp.reset(col[9]);
colMap.insert(CMVT_(defaultvalue, srcp)); colMap.insert(CMVT_(defaultvalue, srcp));
@ -5045,7 +5045,7 @@ void CalpontSystemCatalog::getSchemaInfo(const string& in_schema)
colMap.insert(CMVT_(scale, srcp)); colMap.insert(CMVT_(scale, srcp));
srcp.reset(col[8]); srcp.reset(col[8]);
colMap.insert(CMVT_(precision, srcp)); colMap.insert(CMVT_(precision, srcp));
// TODO: NULL value handling & convert to boost::any // TODO: NULL value handling & convert to static_any::any
// delete this manually at fcn exit // delete this manually at fcn exit
srcp.reset(col[9]); srcp.reset(col[9]);
colMap.insert(CMVT_(defaultvalue, srcp)); colMap.insert(CMVT_(defaultvalue, srcp));

29
dbcon/execplan/calpontsystemcatalog.h Normal file → Executable file
View File

@ -156,7 +156,8 @@ public:
TEXT, /*!< TEXT type */ TEXT, /*!< TEXT type */
NUM_OF_COL_DATA_TYPE, /* NEW TYPES ABOVE HERE */ NUM_OF_COL_DATA_TYPE, /* NEW TYPES ABOVE HERE */
LONGDOUBLE, /* @bug3241, dev and variance calculation only */ LONGDOUBLE, /* @bug3241, dev and variance calculation only */
STRINT /* @bug3532, string as int for fast comparison */ STRINT, /* @bug3532, string as int for fast comparison */
UNDEFINED /*!< Undefined - used in UDAF API */
}; };
/** the set of column constraint types /** the set of column constraint types
@ -914,6 +915,32 @@ inline bool isCharType(const execplan::CalpontSystemCatalog::ColDataType type)
/** convenience function to determine if column type is an /** convenience function to determine if column type is an
* unsigned type * unsigned type
*/ */
inline bool isNumeric(const execplan::CalpontSystemCatalog::ColDataType type)
{
switch (type)
{
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::SMALLINT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UBIGINT:
case execplan::CalpontSystemCatalog::UFLOAT:
case execplan::CalpontSystemCatalog::UDOUBLE:
case execplan::CalpontSystemCatalog::UDECIMAL:
return true;
default:
return false;
}
}
inline bool isUnsigned(const execplan::CalpontSystemCatalog::ColDataType type) inline bool isUnsigned(const execplan::CalpontSystemCatalog::ColDataType type)
{ {
switch (type) switch (type)

7
dbcon/execplan/execplan.vpj Normal file → Executable file
View File

@ -213,6 +213,7 @@
<F N="filter.cpp"/> <F N="filter.cpp"/>
<F N="functioncolumn.cpp"/> <F N="functioncolumn.cpp"/>
<F N="groupconcatcolumn.cpp"/> <F N="groupconcatcolumn.cpp"/>
<F N="intervalcolumn.cpp"/>
<F N="logicoperator.cpp"/> <F N="logicoperator.cpp"/>
<F N="mysqlexecutionplan.cpp"/> <F N="mysqlexecutionplan.cpp"/>
<F N="objectidmanager.cpp"/> <F N="objectidmanager.cpp"/>
@ -221,6 +222,7 @@
<F N="oracleexecutionplan.cpp"/> <F N="oracleexecutionplan.cpp"/>
<F N="outerjoinonfilter.cpp"/> <F N="outerjoinonfilter.cpp"/>
<F N="predicateoperator.cpp"/> <F N="predicateoperator.cpp"/>
<F N="pseudocolumn.cpp"/>
<F N="range.cpp"/> <F N="range.cpp"/>
<F N="returnedcolumn.cpp"/> <F N="returnedcolumn.cpp"/>
<F N="rowcolumn.cpp"/> <F N="rowcolumn.cpp"/>
@ -232,6 +234,7 @@
<F N="simplescalarfilter.cpp"/> <F N="simplescalarfilter.cpp"/>
<F N="treenode.cpp"/> <F N="treenode.cpp"/>
<F N="treenodeimpl.cpp"/> <F N="treenodeimpl.cpp"/>
<F N="udafcolumn.cpp"/>
<F N="vendorexecutionplan.cpp"/> <F N="vendorexecutionplan.cpp"/>
<F N="windowfunctioncolumn.cpp"/> <F N="windowfunctioncolumn.cpp"/>
</Folder> </Folder>
@ -258,6 +261,7 @@
<F N="filter.h"/> <F N="filter.h"/>
<F N="functioncolumn.h"/> <F N="functioncolumn.h"/>
<F N="groupconcatcolumn.h"/> <F N="groupconcatcolumn.h"/>
<F N="intervalcolumn.h"/>
<F N="logicoperator.h"/> <F N="logicoperator.h"/>
<F N="mysqlexecutionplan.h"/> <F N="mysqlexecutionplan.h"/>
<F N="njlcolumnresult.h"/> <F N="njlcolumnresult.h"/>
@ -268,6 +272,7 @@
<F N="outerjoinonfilter.h"/> <F N="outerjoinonfilter.h"/>
<F N="parsetree.h"/> <F N="parsetree.h"/>
<F N="predicateoperator.h"/> <F N="predicateoperator.h"/>
<F N="pseudocolumn.h"/>
<F N="range.h"/> <F N="range.h"/>
<F N="returnedcolumn.h"/> <F N="returnedcolumn.h"/>
<F N="rowcolumn.h"/> <F N="rowcolumn.h"/>
@ -282,7 +287,9 @@
<F N="simplescalarfilter.h"/> <F N="simplescalarfilter.h"/>
<F N="treenode.h"/> <F N="treenode.h"/>
<F N="treenodeimpl.h"/> <F N="treenodeimpl.h"/>
<F N="udafcolumn.h"/>
<F N="vendorexecutionplan.h"/> <F N="vendorexecutionplan.h"/>
<F N="wf_frame.h"/>
<F N="windowfunctioncolumn.h"/> <F N="windowfunctioncolumn.h"/>
</Folder> </Folder>
<Folder <Folder

6
dbcon/execplan/objectreader.cpp Normal file → Executable file
View File

@ -32,6 +32,7 @@
#include "treenode.h" #include "treenode.h"
#include "returnedcolumn.h" #include "returnedcolumn.h"
#include "aggregatecolumn.h" #include "aggregatecolumn.h"
#include "udafcolumn.h"
#include "arithmeticcolumn.h" #include "arithmeticcolumn.h"
#include "constantcolumn.h" #include "constantcolumn.h"
#include "functioncolumn.h" #include "functioncolumn.h"
@ -121,6 +122,9 @@ TreeNode* ObjectReader::createTreeNode(messageqcpp::ByteStream& b) {
case GROUPCONCATCOLUMN: case GROUPCONCATCOLUMN:
ret = new GroupConcatColumn(); ret = new GroupConcatColumn();
break; break;
case UDAFCOLUMN:
ret = new UDAFColumn();
break;
case ARITHMETICCOLUMN: case ARITHMETICCOLUMN:
ret = new ArithmeticColumn(); ret = new ArithmeticColumn();
break; break;
@ -293,6 +297,8 @@ void ObjectReader::checkType(messageqcpp::ByteStream& b, const CLASSID id)
throw UnserializeException("Not a CalpontSelectExecutionPlan"); throw UnserializeException("Not a CalpontSelectExecutionPlan");
case NULL_CLASS: case NULL_CLASS:
throw UnserializeException("Not NULL"); // ?? throw UnserializeException("Not NULL"); // ??
case MCSV1_CONTEXT:
throw UnserializeException("Not a MCSV1_CONTEXT");
default: default:
throw UnserializeException("Bad id"); throw UnserializeException("Bad id");
} }

4
dbcon/execplan/objectreader.h Normal file → Executable file
View File

@ -114,6 +114,10 @@ public:
CALPONTSELECTEXECUTIONPLAN, CALPONTSELECTEXECUTIONPLAN,
CONSTANTFILTER, CONSTANTFILTER,
OUTERJOINONFILTER, OUTERJOINONFILTER,
/** UDAF SDK */
MCSV1_CONTEXT,
UDAFCOLUMN,
}; };
typedef uint8_t id_t; //expand as necessary typedef uint8_t id_t; //expand as necessary

130
dbcon/execplan/udafcolumn.cpp Executable file
View File

@ -0,0 +1,130 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <sstream>
#include <cstring>
using namespace std;
#include "bytestream.h"
using namespace messageqcpp;
#include "rowgroup.h"
using namespace rowgroup;
#include "joblisttypes.h"
using namespace joblist;
#include "simplefilter.h"
#include "constantfilter.h"
#include "arithmeticcolumn.h"
#include "functioncolumn.h"
#include "objectreader.h"
#include "groupconcatcolumn.h"
#include "udafcolumn.h"
namespace execplan {
/**
* Constructors/Destructors
*/
UDAFColumn::UDAFColumn():
AggregateColumn()
{
}
UDAFColumn::UDAFColumn(const uint32_t sessionID):
AggregateColumn(sessionID)
{
}
UDAFColumn::UDAFColumn(const UDAFColumn& rhs, const uint32_t sessionID):
AggregateColumn(dynamic_cast<const AggregateColumn&>(rhs))
{
}
UDAFColumn::~UDAFColumn()
{
}
/**
* Methods
*/
const string UDAFColumn::toString() const
{
ostringstream output;
output << "UDAFColumn " << endl;
output << AggregateColumn::toString() << endl;
output << context.toString() << endl;
return output.str();
}
ostream& operator<<(ostream& output, const UDAFColumn& rhs)
{
output << rhs.toString();
return output;
}
void UDAFColumn::serialize(messageqcpp::ByteStream& b) const
{
b << (uint8_t) ObjectReader::UDAFCOLUMN;
AggregateColumn::serialize(b);
context.serialize(b);
}
void UDAFColumn::unserialize(messageqcpp::ByteStream& b)
{
ObjectReader::checkType(b, ObjectReader::UDAFCOLUMN);
AggregateColumn::unserialize(b);
context.unserialize(b);
}
bool UDAFColumn::operator==(const UDAFColumn& t) const
{
const AggregateColumn *rc1, *rc2;
rc1 = static_cast<const AggregateColumn*>(this);
rc2 = static_cast<const AggregateColumn*>(&t);
if (*rc1 != *rc2)
return false;
if (context != t.context)
return false;
return true;
}
bool UDAFColumn::operator==(const TreeNode* t) const
{
const UDAFColumn *ac;
ac = dynamic_cast<const UDAFColumn*>(t);
if (ac == NULL)
return false;
return *this == *ac;
}
bool UDAFColumn::operator!=(const UDAFColumn& t) const
{
return !(*this == t);
}
bool UDAFColumn::operator!=(const TreeNode* t) const
{
return !(*this == t);
}
} // namespace execplan

131
dbcon/execplan/udafcolumn.h Executable file
View File

@ -0,0 +1,131 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***********************************************************************
* $Id: groupconcatcolumn.h 9210 2013-01-21 14:10:42Z rdempsey $
*
*
***********************************************************************/
/** @file */
#ifndef UDAFCOLUMN_H
#define UDAFCOLUMN_H
#include <string>
#include "calpontselectexecutionplan.h"
#include "aggregatecolumn.h"
#include "mcsv1_udaf.h"
namespace messageqcpp {
class ByteStream;
}
using namespace mcsv1sdk;
/**
* Namespace
*/
namespace execplan {
/**
* @brief A class to represent an aggregate return column
*
* This class is a specialization of class ReturnedColumn that
* handles a user defined aggregate function (UDAF) call.
*/
class UDAFColumn : public AggregateColumn {
public:
/**
* Constructors
*/
UDAFColumn();
UDAFColumn(const uint32_t sessionID);
UDAFColumn(const UDAFColumn& rhs, const uint32_t sessionID=0);
/**
* Destructors
*/
virtual ~UDAFColumn();
/**
* Overloaded stream operator
*/
virtual const std::string toString() const;
/** return a copy of this pointer
*
* deep copy of this pointer and return the copy
*/
virtual UDAFColumn* clone() const { return new UDAFColumn(*this); }
/**
* Accessors and Mutators
*/
mcsv1Context& getContext() {return context;}
/**
* Serialize interface
*/
virtual void serialize(messageqcpp::ByteStream&) const;
virtual void unserialize(messageqcpp::ByteStream&);
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
*
* Do a deep, strict (as opposed to semantic) equivalence test.
* @return true iff every member of t is a duplicate copy of every member of this;
* false otherwise
*/
virtual bool operator==(const TreeNode* t) const;
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
*
* Do a deep, strict (as opposed to semantic) equivalence test.
* @return true iff every member of t is a duplicate copy of every member of this;
* false otherwise
*/
virtual bool operator==(const UDAFColumn& t) const;
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
*
* Do a deep, strict (as opposed to semantic) equivalence test.
* @return false iff every member of t is a duplicate copy of every member of this;
* true otherwise
*/
virtual bool operator!=(const TreeNode* t) const;
/** @brief Do a deep, strict (as opposed to semantic) equivalence test
*
* Do a deep, strict (as opposed to semantic) equivalence test.
* @return false iff every member of t is a duplicate copy of every member of this;
* true otherwise
*/
virtual bool operator!=(const UDAFColumn& t) const;
private:
mcsv1Context context;
};
/**
* stream operator
*/
std::ostream& operator<<(std::ostream& os, const UDAFColumn& rhs);
}
#endif //UDAFCOLUMN_H

95
dbcon/execplan/wf_frame.h Executable file
View File

@ -0,0 +1,95 @@
/* Copyright (C) 2014 InfiniDB, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***********************************************************************
* $Id: wf_frame.h 9679 2017-06-11 $
*
*
***********************************************************************/
/** @file */
#ifndef WINDOW_FUNCTION_FRAME_H
#define WINDOW_FUNCTION_FRAME_H
#include <string>
#include <iosfwd>
#include <vector>
#include "returnedcolumn.h"
/**
* Namespace
*/
namespace execplan {
// This enum is made consistant with mysql Item_window_func
enum WF_FRAME
{
WF_PRECEDING = 0,
WF_FOLLOWING,
WF_UNBOUNDED_PRECEDING,
WF_UNBOUNDED_FOLLOWING,
WF_CURRENT_ROW,
WF_UNKNOWN
};
struct WF_Boundary
{
WF_Boundary() {}
WF_Boundary(WF_FRAME frame):fFrame(frame) {}
~WF_Boundary() {}
const std::string toString() const;
void serialize(messageqcpp::ByteStream&) const;
void unserialize(messageqcpp::ByteStream&);
SRCP fVal; /// has to evaluate to unsigned value
SRCP fBound; /// order by col +, -, date_add or date_sub for RANGE window
enum WF_FRAME fFrame;
};
struct WF_Frame
{
WF_Frame(): fIsRange(true)
{
fStart.fFrame = WF_UNBOUNDED_PRECEDING;
fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
}
~WF_Frame() {}
const std::string toString() const;
void serialize(messageqcpp::ByteStream&) const;
void unserialize(messageqcpp::ByteStream&);
WF_Boundary fStart;
WF_Boundary fEnd;
bool fIsRange; /// RANGE or ROWS
};
/**
* @brief A class to represent the order by clause of window function
*/
struct WF_OrderBy
{
WF_OrderBy() {}
WF_OrderBy(std::vector<SRCP> orders): fOrders(orders) {}
~WF_OrderBy() {};
const std::string toString() const;
void serialize(messageqcpp::ByteStream&) const;
void unserialize(messageqcpp::ByteStream&);
std::vector<SRCP> fOrders;
WF_Frame fFrame;
};
}
#endif

2
dbcon/execplan/windowfunctioncolumn.cpp Normal file → Executable file
View File

@ -257,6 +257,7 @@ void WindowFunctionColumn::serialize(messageqcpp::ByteStream& b) const
for (uint32_t i = 0; i < fPartitions.size(); i++) for (uint32_t i = 0; i < fPartitions.size(); i++)
fPartitions[i]->serialize(b); fPartitions[i]->serialize(b);
fOrderBy.serialize(b); fOrderBy.serialize(b);
udafContext.serialize(b);
} }
void WindowFunctionColumn::unserialize(messageqcpp::ByteStream& b) void WindowFunctionColumn::unserialize(messageqcpp::ByteStream& b)
@ -283,6 +284,7 @@ void WindowFunctionColumn::unserialize(messageqcpp::ByteStream& b)
fPartitions.push_back(srcp); fPartitions.push_back(srcp);
} }
fOrderBy.unserialize(b); fOrderBy.unserialize(b);
udafContext.unserialize(b);
} }
void WindowFunctionColumn::addToPartition(vector<SRCP>& groupByList) void WindowFunctionColumn::addToPartition(vector<SRCP>& groupByList)

62
dbcon/execplan/windowfunctioncolumn.h Normal file → Executable file
View File

@ -31,6 +31,8 @@
#include "returnedcolumn.h" #include "returnedcolumn.h"
#include "functor.h" #include "functor.h"
#include "mcsv1_udaf.h"
#include "wf_frame.h"
namespace messageqcpp { namespace messageqcpp {
class ByteStream; class ByteStream;
@ -41,61 +43,6 @@ class ByteStream;
*/ */
namespace execplan { namespace execplan {
// This enum is made consistant with mysql Item_window_func
enum WF_FRAME
{
WF_PRECEDING = 0,
WF_FOLLOWING,
WF_UNBOUNDED_PRECEDING,
WF_UNBOUNDED_FOLLOWING,
WF_CURRENT_ROW,
WF_UNKNOWN
};
struct WF_Boundary
{
WF_Boundary() {}
WF_Boundary(WF_FRAME frame):fFrame(frame) {}
~WF_Boundary() {}
const std::string toString() const;
void serialize(messageqcpp::ByteStream&) const;
void unserialize(messageqcpp::ByteStream&);
SRCP fVal; /// has to evaluate to unsigned value
SRCP fBound; /// order by col +, -, date_add or date_sub for RANGE window
enum WF_FRAME fFrame;
};
struct WF_Frame
{
WF_Frame(): fIsRange(true)
{
fStart.fFrame = WF_UNBOUNDED_PRECEDING;
fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
}
~WF_Frame() {}
const std::string toString() const;
void serialize(messageqcpp::ByteStream&) const;
void unserialize(messageqcpp::ByteStream&);
WF_Boundary fStart;
WF_Boundary fEnd;
bool fIsRange; /// RANGE or ROWS
};
/**
* @brief A class to represent the order by clause of window function
*/
struct WF_OrderBy
{
WF_OrderBy() {}
WF_OrderBy(std::vector<SRCP> orders): fOrders(orders) {}
~WF_OrderBy() {};
const std::string toString() const;
void serialize(messageqcpp::ByteStream&) const;
void unserialize(messageqcpp::ByteStream&);
std::vector<SRCP> fOrders;
WF_Frame fFrame;
};
/** /**
* @brief A class to represent a functional column * @brief A class to represent a functional column
* *
@ -182,6 +129,9 @@ public:
virtual bool hasWindowFunc(); virtual bool hasWindowFunc();
void adjustResultType(); void adjustResultType();
// UDAnF support
mcsv1sdk::mcsv1Context& getUDAFContext() {return udafContext;}
private: private:
/** /**
* Fields * Fields
@ -197,6 +147,8 @@ private:
virtual bool operator!=(const TreeNode* t) const { return false; } virtual bool operator!=(const TreeNode* t) const { return false; }
bool operator!=(const WindowFunctionColumn& t) const; bool operator!=(const WindowFunctionColumn& t) const;
// UDAnF support
mcsv1sdk::mcsv1Context udafContext;
/*********************************************************** /***********************************************************
* F&E framework * * F&E framework *
***********************************************************/ ***********************************************************/

434
dbcon/ingres/ingres.vpj Normal file → Executable file
View File

@ -1,220 +1,220 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdingres.so" OutputFile="%bdingres.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdingres.so" OutputFile="%bdingres.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="gwfcp.c"/> <F N="gwfcp.c"/>
<F N="gwfcpdata.c"/> <F N="gwfcpdata.c"/>
<F N="inggwif.cpp"/> <F N="inggwif.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="inggwif.h"/> <F N="inggwif.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

28
dbcon/joblist/joblistfactory.cpp Normal file → Executable file
View File

@ -58,6 +58,7 @@ using namespace boost;
#include "simplecolumn.h" #include "simplecolumn.h"
#include "rowcolumn.h" #include "rowcolumn.h"
#include "treenodeimpl.h" #include "treenodeimpl.h"
#include "udafcolumn.h"
using namespace execplan; using namespace execplan;
#include "configcpp.h" #include "configcpp.h"
@ -697,6 +698,22 @@ void updateAggregateColType(AggregateColumn* ac, const SRCP& srcp, int op, JobIn
ct.scale = 0; ct.scale = 0;
ct.precision = 0; ct.precision = 0;
} }
else if (op == AggregateColumn::UDAF)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(ac);
if (udafc)
{
mcsv1Context& udafContext = udafc->getContext();
ct.colDataType = udafContext.getResultType();
ct.colWidth = udafContext.getColWidth();
ct.scale = udafContext.getScale();
ct.precision = udafContext.getPrecision();
}
else
{
ct = ac->resultType();
}
}
else else
{ {
ct = ac->resultType(); ct = ac->resultType();
@ -883,7 +900,16 @@ const JobStepVector doAggProject(const CalpontSelectExecutionPlan* csep, JobInfo
if (ac->constCol().get() != NULL) if (ac->constCol().get() != NULL)
{ {
// replace the aggregate on constant with a count(*) // replace the aggregate on constant with a count(*)
SRCP clone(new AggregateColumn(*ac, ac->sessionID())); SRCP clone;
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(ac);
if (udafc)
{
clone.reset(new UDAFColumn(*udafc, ac->sessionID()));
}
else
{
clone.reset(new AggregateColumn(*ac, ac->sessionID()));
}
jobInfo.constAggregate.insert(make_pair(i, clone)); jobInfo.constAggregate.insert(make_pair(i, clone));
ac->aggOp(AggregateColumn::COUNT_ASTERISK); ac->aggOp(AggregateColumn::COUNT_ASTERISK);
ac->distinct(false); ac->distinct(false);

416
dbcon/joblist/tupleaggregatestep.cpp Normal file → Executable file
View File

@ -47,6 +47,7 @@ using namespace config;
#include "calpontsystemcatalog.h" #include "calpontsystemcatalog.h"
#include "aggregatecolumn.h" #include "aggregatecolumn.h"
#include "udafcolumn.h"
#include "arithmeticcolumn.h" #include "arithmeticcolumn.h"
#include "functioncolumn.h" #include "functioncolumn.h"
#include "constantcolumn.h" #include "constantcolumn.h"
@ -100,6 +101,7 @@ inline RowAggFunctionType functionIdMap(int planFuncId)
case AggregateColumn::BIT_XOR: return ROWAGG_BIT_XOR; case AggregateColumn::BIT_XOR: return ROWAGG_BIT_XOR;
case AggregateColumn::GROUP_CONCAT: return ROWAGG_GROUP_CONCAT; case AggregateColumn::GROUP_CONCAT: return ROWAGG_GROUP_CONCAT;
case AggregateColumn::CONSTANT: return ROWAGG_CONSTANT; case AggregateColumn::CONSTANT: return ROWAGG_CONSTANT;
case AggregateColumn::UDAF: return ROWAGG_UDAF;
default: return ROWAGG_FUNCT_UNDEFINE; default: return ROWAGG_FUNCT_UNDEFINE;
} }
} }
@ -695,8 +697,18 @@ SJSTEP TupleAggregateStep::prepAggregate(SJSTEP& step, JobInfo& jobInfo)
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(ac->constCol().get()); ConstantColumn* cc = dynamic_cast<ConstantColumn*>(ac->constCol().get());
idbassert(cc != NULL); // @bug5261 idbassert(cc != NULL); // @bug5261
bool isNull = (ConstantColumn::NULLDATA == cc->type()); bool isNull = (ConstantColumn::NULLDATA == cc->type());
constAggDataVec.push_back( UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(ac);
ConstantAggData(cc->constval(), functionIdMap(ac->aggOp()), isNull)); if (udafc)
{
constAggDataVec.push_back(
ConstantAggData(cc->constval(), udafc->getContext().getName(),
functionIdMap(ac->aggOp()), isNull));
}
else
{
constAggDataVec.push_back(
ConstantAggData(cc->constval(), functionIdMap(ac->aggOp()), isNull));
}
} }
} }
} }
@ -1097,7 +1109,24 @@ void TupleAggregateStep::prep1PhaseAggregate(
} }
} }
SP_ROWAGG_FUNC_t funct(new RowAggFunctionCol(aggOp, stats, colProj, i)); SP_ROWAGG_FUNC_t funct;
if (aggOp == ROWAGG_UDAF)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.nonConstCols[i].get());
if (udafc)
{
// Create a RowAggFunctionCol (UDAF subtype) with the context.
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, i));
}
else
{
throw logic_error("prep1PhasesAggregate: A UDAF function is called but there's no UDAFColumn");
}
}
else
{
funct.reset(new RowAggFunctionCol(aggOp, stats, colProj, i));
}
functionVec.push_back(funct); functionVec.push_back(funct);
switch (aggOp) switch (aggOp)
@ -1224,6 +1253,23 @@ void TupleAggregateStep::prep1PhaseAggregate(
} }
break; break;
case ROWAGG_UDAF:
{
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(funct.get());
if (!udafFuncCol)
{
throw logic_error("prep1PhaseAggregate: A UDAF function is called but there's no RowUDAFFunctionCol");
}
// Return column
oidsAgg.push_back(oidsProj[colProj]);
keysAgg.push_back(key);
scaleAgg.push_back(udafFuncCol->fUDAFContext.getScale());
precisionAgg.push_back(udafFuncCol->fUDAFContext.getPrecision());
typeAgg.push_back(udafFuncCol->fUDAFContext.getResultType());
widthAgg.push_back(udafFuncCol->fUDAFContext.getColWidth());
break;
}
default: default:
{ {
ostringstream emsg; ostringstream emsg;
@ -1285,14 +1331,34 @@ void TupleAggregateStep::prep1PhaseAggregate(
} }
} }
// add auxiliary fields for statistics functions // add auxiliary fields for UDAF and statistics functions
for (uint64_t i = 0; i < functionVec.size(); i++) for (uint64_t i = 0; i < functionVec.size(); i++)
{ {
uint64_t j = functionVec[i]->fInputColumnIndex;
if (functionVec[i]->fAggFunction == ROWAGG_UDAF)
{
// UDAF user data
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(functionVec[i].get());
if (!udafFuncCol)
{
throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol");
}
functionVec[i]->fAuxColumnIndex = lastCol++;
oidsAgg.push_back(oidsAgg[j]);
keysAgg.push_back(keysAgg[j]);
scaleAgg.push_back(0);
precisionAgg.push_back(0);
precisionAgg.push_back(0);
typeAgg.push_back(CalpontSystemCatalog::VARBINARY);
widthAgg.push_back(udafFuncCol->fUDAFContext.getUserDataSize()+2);
continue;
}
if (functionVec[i]->fAggFunction != ROWAGG_STATS) if (functionVec[i]->fAggFunction != ROWAGG_STATS)
continue; continue;
functionVec[i]->fAuxColumnIndex = lastCol; functionVec[i]->fAuxColumnIndex = lastCol;
uint64_t j = functionVec[i]->fInputColumnIndex;
// sum(x) // sum(x)
oidsAgg.push_back(oidsAgg[j]); oidsAgg.push_back(oidsAgg[j]);
@ -1527,7 +1593,25 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
continue; continue;
uint64_t colProj = projColPosMap[aggKey]; uint64_t colProj = projColPosMap[aggKey];
SP_ROWAGG_FUNC_t funct(new RowAggFunctionCol(aggOp, stats, colProj, colAgg));
SP_ROWAGG_FUNC_t funct;
if (aggOp == ROWAGG_UDAF)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.nonConstCols[i].get());
if (udafc)
{
// Create a RowAggFunctionCol (UDAF subtype) with the context.
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAgg));
}
else
{
throw logic_error("prep1PhaseDistinctAggregate: A UDAF function is called but there's no UDAFColumn");
}
}
else
{
funct.reset(new RowAggFunctionCol(aggOp, stats, colProj, colAgg));
}
functionVec1.push_back(funct); functionVec1.push_back(funct);
aggFuncMap.insert(make_pair(make_pair(aggKey, aggOp), colAgg)); aggFuncMap.insert(make_pair(make_pair(aggKey, aggOp), colAgg));
@ -1671,6 +1755,32 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
} }
break; break;
case ROWAGG_UDAF:
{
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(funct.get());
if (!udafFuncCol)
{
throw logic_error("prep1PhaseDistinctAggregate A UDAF function is called but there's no RowUDAFFunctionCol");
}
// Return column
oidsAgg.push_back(oidsProj[colProj]);
keysAgg.push_back(aggKey);
scaleAgg.push_back(udafFuncCol->fUDAFContext.getScale());
precisionAgg.push_back(udafFuncCol->fUDAFContext.getPrecision());
typeAgg.push_back(udafFuncCol->fUDAFContext.getResultType());
widthAgg.push_back(udafFuncCol->fUDAFContext.getColWidth());
colAgg++;
// UDAF Dummy holder for UserData struct
oidsAgg.push_back(oidsProj[colProj]);
keysAgg.push_back(aggKey);
scaleAgg.push_back(0);
precisionAgg.push_back(0);
typeAgg.push_back(CalpontSystemCatalog::VARBINARY);
widthAgg.push_back(udafFuncCol->fUDAFContext.getUserDataSize()+2); // Binary column needs +2 for length bytes
funct->fAuxColumnIndex = colAgg++;
break;
}
default: default:
{ {
ostringstream emsg; ostringstream emsg;
@ -2090,14 +2200,33 @@ void TupleAggregateStep::prep1PhaseDistinctAggregate(
} }
} }
// add auxiliary fields for statistics functions // add auxiliary fields for UDAF and statistics functions
for (uint64_t i = 0; i < functionVec2.size(); i++) for (uint64_t i = 0; i < functionVec2.size(); i++)
{ {
uint64_t j = functionVec2[i]->fInputColumnIndex;
if (functionVec2[i]->fAggFunction == ROWAGG_UDAF)
{
// Dummy Column for UDAF user data
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(functionVec2[i].get());
if (!udafFuncCol)
{
throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol");
}
functionVec2[i]->fAuxColumnIndex = lastCol++;
oidsAggDist.push_back(oidsAggDist[j]); // Dummy?
keysAggDist.push_back(keysAggDist[j]); // Dummy?
scaleAggDist.push_back(0);
precisionAggDist.push_back(0);
typeAggDist.push_back(CalpontSystemCatalog::VARBINARY);
widthAggDist.push_back(udafFuncCol->fUDAFContext.getUserDataSize()+2);
continue;
}
if (functionVec2[i]->fAggFunction != ROWAGG_STATS) if (functionVec2[i]->fAggFunction != ROWAGG_STATS)
continue; continue;
functionVec2[i]->fAuxColumnIndex = lastCol; functionVec2[i]->fAuxColumnIndex = lastCol;
uint64_t j = functionVec2[i]->fInputColumnIndex;
// sum(x) // sum(x)
oidsAggDist.push_back(oidsAggDist[j]); oidsAggDist.push_back(oidsAggDist[j]);
@ -2344,22 +2473,22 @@ void TupleAggregateStep::prep2PhasesAggregate(
{ {
// check if there are any aggregate columns // check if there are any aggregate columns
// a vector that has the aggregate function to be done by PM // a vector that has the aggregate function to be done by PM
vector<pair<uint32_t, int> > aggColVec; // vector<pair<uint32_t, int> > aggColVec;
set<uint32_t> avgSet; set<uint32_t> avgSet;
vector<std::pair<uint32_t, int> >& returnedColVec = jobInfo.returnedColVec; vector<std::pair<uint32_t, int> >& returnedColVec = jobInfo.returnedColVec;
for (uint64_t i = 0; i < returnedColVec.size(); i++) // for (uint64_t i = 0; i < returnedColVec.size(); i++)
{ // {
// skip if not an aggregation column // skip if not an aggregation column
if (returnedColVec[i].second == 0) // if (returnedColVec[i].second == 0)
continue; // continue;
aggColVec.push_back(returnedColVec[i]); // aggColVec.push_back(returnedColVec[i]);
// remember if a column has an average function, // remember if a column has an average function,
// with avg function, no need for separate sum or count_column_name // with avg function, no need for separate sum or count_column_name
if (returnedColVec[i].second == AggregateColumn::AVG) // if (returnedColVec[i].second == AggregateColumn::AVG)
avgSet.insert(returnedColVec[i].first); // avgSet.insert(returnedColVec[i].first);
} // }
// populate the aggregate rowgroup on PM and UM // populate the aggregate rowgroup on PM and UM
// PM: projectedRG -> aggregateRGPM // PM: projectedRG -> aggregateRGPM
@ -2480,11 +2609,15 @@ void TupleAggregateStep::prep2PhasesAggregate(
} }
// vectors for aggregate functions // vectors for aggregate functions
for (uint64_t i = 0; i < aggColVec.size(); i++) for (uint64_t i = 0; i < returnedColVec.size(); i++)
{ {
uint32_t aggKey = aggColVec[i].first; // skip if not an aggregation column
RowAggFunctionType aggOp = functionIdMap(aggColVec[i].second); if (returnedColVec[i].second == 0)
RowAggFunctionType stats = statsFuncIdMap(aggColVec[i].second); continue;
uint32_t aggKey = returnedColVec[i].first;
RowAggFunctionType aggOp = functionIdMap(returnedColVec[i].second);
RowAggFunctionType stats = statsFuncIdMap(returnedColVec[i].second);
// skip on PM if this is a constant // skip on PM if this is a constant
if (aggOp == ROWAGG_CONSTANT) if (aggOp == ROWAGG_CONSTANT)
@ -2504,7 +2637,8 @@ void TupleAggregateStep::prep2PhasesAggregate(
} }
if ((aggOp == ROWAGG_SUM || aggOp == ROWAGG_COUNT_COL_NAME) && if ((aggOp == ROWAGG_SUM || aggOp == ROWAGG_COUNT_COL_NAME) &&
(avgSet.find(aggKey) != avgSet.end())) (returnedColVec[i].second == AggregateColumn::AVG))
// (avgSet.find(aggKey) != avgSet.end()))
// skip sum / count(column) if avg is also selected // skip sum / count(column) if avg is also selected
continue; continue;
@ -2513,7 +2647,24 @@ void TupleAggregateStep::prep2PhasesAggregate(
continue; continue;
uint64_t colProj = projColPosMap[aggKey]; uint64_t colProj = projColPosMap[aggKey];
SP_ROWAGG_FUNC_t funct(new RowAggFunctionCol(aggOp, stats, colProj, colAggPm)); SP_ROWAGG_FUNC_t funct;
if (aggOp == ROWAGG_UDAF)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.nonConstCols[i].get());
if (udafc)
{
// Create a RowAggFunctionCol (UDAF subtype) with the context.
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAggPm));
}
else
{
throw logic_error("prep2PhasesAggregate: A UDAF function is called but there's no UDAFColumn");
}
}
else
{
funct.reset(new RowAggFunctionCol(aggOp, stats, colProj, colAggPm));
}
functionVecPm.push_back(funct); functionVecPm.push_back(funct);
aggFuncMap.insert(make_pair(make_pair(aggKey, aggOp), colAggPm)); aggFuncMap.insert(make_pair(make_pair(aggKey, aggOp), colAggPm));
@ -2667,7 +2818,31 @@ void TupleAggregateStep::prep2PhasesAggregate(
colAggPm++; colAggPm++;
} }
break; break;
case ROWAGG_UDAF:
{
// Return column
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(funct.get());
if (!udafFuncCol)
{
throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol");
}
oidsAggPm.push_back(oidsProj[colProj]);
keysAggPm.push_back(aggKey);
scaleAggPm.push_back(udafFuncCol->fUDAFContext.getScale());
precisionAggPm.push_back(udafFuncCol->fUDAFContext.getPrecision());
typeAggPm.push_back(udafFuncCol->fUDAFContext.getResultType());
widthAggPm.push_back(udafFuncCol->fUDAFContext.getColWidth());
colAggPm++;
// Dummy Column for UDAF UserData struct
oidsAggPm.push_back(oidsProj[colProj]);
keysAggPm.push_back(aggKey);
scaleAggPm.push_back(0);
precisionAggPm.push_back(0);
typeAggPm.push_back(CalpontSystemCatalog::VARBINARY);
widthAggPm.push_back(udafFuncCol->fUDAFContext.getUserDataSize()+2); // Binary column needs +2 for length bytes
funct->fAuxColumnIndex = colAggPm++;
break;
}
default: default:
{ {
ostringstream emsg; ostringstream emsg;
@ -2849,7 +3024,16 @@ void TupleAggregateStep::prep2PhasesAggregate(
// update the aggregate function vector // update the aggregate function vector
else else
{ {
SP_ROWAGG_FUNC_t funct(new RowAggFunctionCol(aggOp, stats, colPm, i)); SP_ROWAGG_FUNC_t funct;
if (aggOp == ROWAGG_UDAF)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.nonConstCols[i].get());
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colPm, i));
}
else
{
funct.reset(new RowAggFunctionCol(aggOp, stats, colPm, i));
}
if (aggOp == ROWAGG_COUNT_NO_OP) if (aggOp == ROWAGG_COUNT_NO_OP)
funct->fAuxColumnIndex = colPm; funct->fAuxColumnIndex = colPm;
else if (aggOp == ROWAGG_CONSTANT) else if (aggOp == ROWAGG_CONSTANT)
@ -2909,14 +3093,33 @@ void TupleAggregateStep::prep2PhasesAggregate(
} }
} }
// add auxiliary fields for statistics functions // add auxiliary fields for UDAF and statistics functions
for (uint64_t i = 0; i < functionVecUm.size(); i++) for (uint64_t i = 0; i < functionVecUm.size(); i++)
{ {
uint64_t j = functionVecUm[i]->fInputColumnIndex;
if (functionVecUm[i]->fAggFunction == ROWAGG_UDAF)
{
// Dummy column for UDAF user data
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(functionVecUm[i].get());
if (!udafFuncCol)
{
throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol");
}
functionVecUm[i]->fAuxColumnIndex = lastCol++;
oidsAggUm.push_back(oidsAggUm[j]); // Dummy?
keysAggUm.push_back(keysAggUm[j]); // Dummy?
scaleAggUm.push_back(0);
precisionAggUm.push_back(0);
typeAggUm.push_back(CalpontSystemCatalog::VARBINARY);
widthAggUm.push_back(udafFuncCol->fUDAFContext.getUserDataSize()+2);
continue;
}
if (functionVecUm[i]->fAggFunction != ROWAGG_STATS) if (functionVecUm[i]->fAggFunction != ROWAGG_STATS)
continue; continue;
functionVecUm[i]->fAuxColumnIndex = lastCol; functionVecUm[i]->fAuxColumnIndex = lastCol;
uint64_t j = functionVecUm[i]->fInputColumnIndex;
// sum(x) // sum(x)
oidsAggUm.push_back(oidsAggUm[j]); oidsAggUm.push_back(oidsAggUm[j]);
@ -3170,7 +3373,24 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
continue; continue;
uint64_t colProj = projColPosMap[aggKey]; uint64_t colProj = projColPosMap[aggKey];
SP_ROWAGG_FUNC_t funct(new RowAggFunctionCol(aggOp, stats, colProj, colAggPm)); SP_ROWAGG_FUNC_t funct;
if (aggOp == ROWAGG_UDAF)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.nonConstCols[i].get());
if (udafc)
{
// Create a RowAggFunctionCol (UDAF subtype) with the context.
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colProj, colAggPm));
}
else
{
throw logic_error("prep2PhasesDistinctAggregate: A UDAF function is called but there's no UDAFColumn");
}
}
else
{
funct.reset(new RowAggFunctionCol(aggOp, stats, colProj, colAggPm));
}
functionVecPm.push_back(funct); functionVecPm.push_back(funct);
aggFuncMap.insert(make_pair(make_pair(aggKey, aggOp), colAggPm)); aggFuncMap.insert(make_pair(make_pair(aggKey, aggOp), colAggPm));
@ -3314,6 +3534,32 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
} }
break; break;
case ROWAGG_UDAF:
{
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(funct.get());
if (!udafFuncCol)
{
throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol");
}
// Return column
oidsAggPm.push_back(oidsProj[colProj]);
keysAggPm.push_back(aggKey);
scaleAggPm.push_back(udafFuncCol->fUDAFContext.getScale());
precisionAggPm.push_back(udafFuncCol->fUDAFContext.getPrecision());
typeAggPm.push_back(udafFuncCol->fUDAFContext.getResultType());
widthAggPm.push_back(udafFuncCol->fUDAFContext.getColWidth());
colAggPm++;
// Dummy column for UDAF UserData struct
oidsAggPm.push_back(oidsProj[colProj]);
keysAggPm.push_back(aggKey);
scaleAggPm.push_back(0);
precisionAggPm.push_back(0);
typeAggPm.push_back(CalpontSystemCatalog::VARBINARY);
widthAggPm.push_back(udafFuncCol->fUDAFContext.getUserDataSize()+2); // Binary column needs +2 for length bytes
funct->fAuxColumnIndex = colAggPm++;
break;
}
default: default:
{ {
ostringstream emsg; ostringstream emsg;
@ -3337,14 +3583,29 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
for (uint32_t idx = 0; idx < functionVecPm.size(); idx++) for (uint32_t idx = 0; idx < functionVecPm.size(); idx++)
{ {
SP_ROWAGG_FUNC_t funct;
SP_ROWAGG_FUNC_t funcPm = functionVecPm[idx]; SP_ROWAGG_FUNC_t funcPm = functionVecPm[idx];
SP_ROWAGG_FUNC_t funct(new RowAggFunctionCol( // UDAF support
funcPm->fAggFunction, if (funcPm->fAggFunction == ROWAGG_UDAF)
funcPm->fStatsFunction, {
funcPm->fOutputColumnIndex, RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(funcPm.get());
funcPm->fOutputColumnIndex, funct.reset(new RowUDAFFunctionCol(
funcPm->fAuxColumnIndex)); udafFuncCol->fUDAFContext,
functionNoDistVec.push_back(funct); udafFuncCol->fOutputColumnIndex,
udafFuncCol->fOutputColumnIndex,
udafFuncCol->fAuxColumnIndex));
functionNoDistVec.push_back(funct);
}
else
{
funct.reset(new RowAggFunctionCol(
funcPm->fAggFunction,
funcPm->fStatsFunction,
funcPm->fOutputColumnIndex,
funcPm->fOutputColumnIndex,
funcPm->fAuxColumnIndex));
functionNoDistVec.push_back(funct);
}
} }
posAggUm = posAggPm; posAggUm = posAggPm;
@ -3611,7 +3872,16 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
// update the aggregate function vector // update the aggregate function vector
else else
{ {
SP_ROWAGG_FUNC_t funct(new RowAggFunctionCol(aggOp, stats, colUm, i)); SP_ROWAGG_FUNC_t funct;
if (aggOp == ROWAGG_UDAF)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(jobInfo.nonConstCols[i].get());
funct.reset(new RowUDAFFunctionCol(udafc->getContext(), colUm, i));
}
else
{
funct.reset(new RowAggFunctionCol(aggOp, stats, colUm, i));
}
if (aggOp == ROWAGG_COUNT_NO_OP) if (aggOp == ROWAGG_COUNT_NO_OP)
funct->fAuxColumnIndex = colUm; funct->fAuxColumnIndex = colUm;
else if (aggOp == ROWAGG_CONSTANT) else if (aggOp == ROWAGG_CONSTANT)
@ -3704,14 +3974,32 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
} }
} }
// add auxiliary fields for statistics functions // add auxiliary fields for UDAF and statistics functions
for (uint64_t i = 0; i < functionVecUm.size(); i++) for (uint64_t i = 0; i < functionVecUm.size(); i++)
{ {
uint64_t j = functionVecUm[i]->fInputColumnIndex;
if (functionVecUm[i]->fAggFunction == ROWAGG_UDAF)
{
// Dummy column for UDAF user data
RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(functionVecUm[i].get());
if (!udafFuncCol)
{
throw logic_error("(9)A UDAF function is called but there's no RowUDAFFunctionCol");
}
functionVecUm[i]->fAuxColumnIndex = lastCol++;
oidsAggDist.push_back(oidsAggUm[j]); // Dummy?
keysAggDist.push_back(keysAggUm[j]); // Dummy?
scaleAggDist.push_back(0);
precisionAggDist.push_back(0);
typeAggDist.push_back(CalpontSystemCatalog::VARBINARY);
widthAggDist.push_back(udafFuncCol->fUDAFContext.getUserDataSize()+2);
continue;
}
if (functionVecUm[i]->fAggFunction != ROWAGG_STATS) if (functionVecUm[i]->fAggFunction != ROWAGG_STATS)
continue; continue;
functionVecUm[i]->fAuxColumnIndex = lastCol; functionVecUm[i]->fAuxColumnIndex = lastCol;
uint64_t j = functionVecUm[i]->fInputColumnIndex;
// sum(x) // sum(x)
oidsAggDist.push_back(oidsAggDist[j]); oidsAggDist.push_back(oidsAggDist[j]);
@ -3880,27 +4168,39 @@ void TupleAggregateStep::prep2PhasesDistinctAggregate(
vector<SP_ROWAGG_FUNC_t>::iterator it = functionVecUm.begin(); vector<SP_ROWAGG_FUNC_t>::iterator it = functionVecUm.begin();
while (it != functionVecUm.end()) while (it != functionVecUm.end())
{ {
SP_ROWAGG_FUNC_t funct;
SP_ROWAGG_FUNC_t f = *it++; SP_ROWAGG_FUNC_t f = *it++;
if ((f->fOutputColumnIndex == k) && if (f->fOutputColumnIndex == k)
(f->fAggFunction == ROWAGG_COUNT_ASTERISK ||
f->fAggFunction == ROWAGG_COUNT_COL_NAME ||
f->fAggFunction == ROWAGG_SUM ||
f->fAggFunction == ROWAGG_AVG ||
f->fAggFunction == ROWAGG_MIN ||
f->fAggFunction == ROWAGG_MAX ||
f->fAggFunction == ROWAGG_STATS ||
f->fAggFunction == ROWAGG_BIT_AND ||
f->fAggFunction == ROWAGG_BIT_OR ||
f->fAggFunction == ROWAGG_BIT_XOR ||
f->fAggFunction == ROWAGG_CONSTANT))
{ {
SP_ROWAGG_FUNC_t funct( if (f->fAggFunction == ROWAGG_UDAF)
new RowAggFunctionCol( {
f->fAggFunction, RowUDAFFunctionCol* udafFuncCol = dynamic_cast<RowUDAFFunctionCol*>(f.get());
f->fStatsFunction, funct.reset(new RowUDAFFunctionCol(
f->fInputColumnIndex, udafFuncCol->fUDAFContext,
f->fOutputColumnIndex, udafFuncCol->fInputColumnIndex,
f->fAuxColumnIndex)); udafFuncCol->fOutputColumnIndex,
udafFuncCol->fAuxColumnIndex));
functionSub2.push_back(funct);
}
else if (f->fAggFunction == ROWAGG_COUNT_ASTERISK ||
f->fAggFunction == ROWAGG_COUNT_COL_NAME ||
f->fAggFunction == ROWAGG_SUM ||
f->fAggFunction == ROWAGG_AVG ||
f->fAggFunction == ROWAGG_MIN ||
f->fAggFunction == ROWAGG_MAX ||
f->fAggFunction == ROWAGG_STATS ||
f->fAggFunction == ROWAGG_BIT_AND ||
f->fAggFunction == ROWAGG_BIT_OR ||
f->fAggFunction == ROWAGG_BIT_XOR ||
f->fAggFunction == ROWAGG_CONSTANT)
{
funct.reset(
new RowAggFunctionCol(
f->fAggFunction,
f->fStatsFunction,
f->fInputColumnIndex,
f->fOutputColumnIndex,
f->fAuxColumnIndex));
functionSub2.push_back(funct); functionSub2.push_back(funct);
} }
} }
@ -4292,6 +4592,7 @@ void TupleAggregateStep::threadedAggregateRowGroups(uint32_t threadID)
for (uint32_t j = 0; j < multiDist->subAggregators().size(); j++) for (uint32_t j = 0; j < multiDist->subAggregators().size(); j++)
{ {
fRowGroupIns[threadID].getRow(0, &rowIn); fRowGroupIns[threadID].getRow(0, &rowIn);
rowIn.setUserDataStore(rgDatas[c].getUserDataStore());
for (uint64_t i = 0; i < fRowGroupIns[threadID].getRowCount(); ++i) for (uint64_t i = 0; i < fRowGroupIns[threadID].getRowCount(); ++i)
{ {
for (uint64_t k = 0; for (uint64_t k = 0;
@ -4313,6 +4614,7 @@ void TupleAggregateStep::threadedAggregateRowGroups(uint32_t threadID)
{ {
fRowGroupIns[threadID].setData(&rgDatas[c]); fRowGroupIns[threadID].setData(&rgDatas[c]);
fRowGroupIns[threadID].getRow(0, &rowIn); fRowGroupIns[threadID].getRow(0, &rowIn);
rowIn.setUserDataStore(rgDatas[c].getUserDataStore());
for (uint64_t i = 0; i < fRowGroupIns[threadID].getRowCount(); ++i) for (uint64_t i = 0; i < fRowGroupIns[threadID].getRowCount(); ++i)
{ {
// The key is the groupby columns, which are the leading columns. // The key is the groupby columns, which are the leading columns.

20
dbcon/joblist/windowfunctionstep.cpp Normal file → Executable file
View File

@ -146,6 +146,7 @@ WindowFunctionStep::WindowFunctionStep(const JobInfo& jobInfo) :
fEndOfResult(false), fEndOfResult(false),
fIsSelect(true), fIsSelect(true),
fUseSSMutex(false), fUseSSMutex(false),
fUseUFMutex(false),
fInputDL(NULL), fInputDL(NULL),
fOutputDL(NULL), fOutputDL(NULL),
fInputIterator(-1), fInputIterator(-1),
@ -531,6 +532,7 @@ void WindowFunctionStep::initialize(const RowGroup& rg, JobInfo& jobInfo)
// @bug6065, window functions that will update string table // @bug6065, window functions that will update string table
int64_t wfsUpdateStringTable = 0; int64_t wfsUpdateStringTable = 0;
int64_t wfsUserFunctionCount = 0;
for (RetColsVector::iterator i=jobInfo.windowCols.begin(); i<jobInfo.windowCols.end(); i++) for (RetColsVector::iterator i=jobInfo.windowCols.begin(); i<jobInfo.windowCols.end(); i++)
{ {
// window function type // window function type
@ -541,12 +543,19 @@ void WindowFunctionStep::initialize(const RowGroup& rg, JobInfo& jobInfo)
CalpontSystemCatalog::ColType rt = wc->resultType(); CalpontSystemCatalog::ColType rt = wc->resultType();
if ((types[ridx] == CalpontSystemCatalog::CHAR || if ((types[ridx] == CalpontSystemCatalog::CHAR ||
types[ridx] == CalpontSystemCatalog::VARCHAR || types[ridx] == CalpontSystemCatalog::VARCHAR ||
types[ridx] == CalpontSystemCatalog::TEXT) && types[ridx] == CalpontSystemCatalog::TEXT ||
types[ridx] == CalpontSystemCatalog::VARBINARY ||
types[ridx] == CalpontSystemCatalog::BLOB) &&
rg.getColumnWidth(ridx) >= jobInfo.stringTableThreshold) rg.getColumnWidth(ridx) >= jobInfo.stringTableThreshold)
{ {
wfsUpdateStringTable++; ++wfsUpdateStringTable;
} }
} }
// if (boost::iequals(wc->functionName(),"UDAF_FUNC")
if (wc->functionName() == "UDAF_FUNC")
{
++wfsUserFunctionCount;
}
vector<int64_t> fields; vector<int64_t> fields;
fields.push_back(ridx); // result fields.push_back(ridx); // result
@ -609,7 +618,7 @@ void WindowFunctionStep::initialize(const RowGroup& rg, JobInfo& jobInfo)
// create the functor based on function name // create the functor based on function name
boost::shared_ptr<WindowFunctionType> func = boost::shared_ptr<WindowFunctionType> func =
WindowFunctionType::makeWindowFunction(fn, ct); WindowFunctionType::makeWindowFunction(fn, ct, wc);
// parse parms after peer and fields are set // parse parms after peer and fields are set
// functions may need to set order column index // functions may need to set order column index
@ -751,7 +760,8 @@ void WindowFunctionStep::initialize(const RowGroup& rg, JobInfo& jobInfo)
if (wfsUpdateStringTable > 1) if (wfsUpdateStringTable > 1)
fUseSSMutex = true; fUseSSMutex = true;
if (wfsUserFunctionCount > 1)
fUseUFMutex = true;
fRowGroupOut = fRowGroupDelivered; fRowGroupOut = fRowGroupDelivered;
} }
@ -799,6 +809,8 @@ void WindowFunctionStep::execute()
//@bug6065, make StringStore::storeString() thread safe, default to false. //@bug6065, make StringStore::storeString() thread safe, default to false.
rgData.useStoreStringMutex(fUseSSMutex); rgData.useStoreStringMutex(fUseSSMutex);
// For the User Data of UDAnF
rgData.useUserDataMutex(fUseUFMutex);
// window function does not change row count // window function does not change row count
fRowsReturned += rowCnt; fRowsReturned += rowCnt;

2
dbcon/joblist/windowfunctionstep.h Normal file → Executable file
View File

@ -160,7 +160,7 @@ private:
bool fEndOfResult; bool fEndOfResult;
bool fIsSelect; bool fIsSelect;
bool fUseSSMutex; //@bug6065, mutex for setStringField bool fUseSSMutex; //@bug6065, mutex for setStringField
bool fUseUFMutex; // To ensure thread safety of User Data (UDAnF)
// for input/output datalist // for input/output datalist
RowGroupDL* fInputDL; RowGroupDL* fInputDL;
RowGroupDL* fOutputDL; RowGroupDL* fOutputDL;

View File

@ -80,6 +80,7 @@ using namespace cal_impl_if;
#include "groupconcatcolumn.h" #include "groupconcatcolumn.h"
#include "outerjoinonfilter.h" #include "outerjoinonfilter.h"
#include "intervalcolumn.h" #include "intervalcolumn.h"
#include "udafcolumn.h"
using namespace execplan; using namespace execplan;
#include "funcexp.h" #include "funcexp.h"
@ -447,6 +448,9 @@ void debug_walk(const Item *item, void *arg)
case Item_sum::MAX_FUNC: case Item_sum::MAX_FUNC:
cout << "MAX_FUNC: " << item_name << endl; cout << "MAX_FUNC: " << item_name << endl;
break; break;
case Item_sum::UDF_SUM_FUNC:
cout << "UDAF_FUNC: " << item_name << endl;
break;
default: default:
cout << "SUM_FUNC_ITEM type=" << isp->sum_func() << endl; cout << "SUM_FUNC_ITEM type=" << isp->sum_func() << endl;
break; break;
@ -2135,6 +2139,9 @@ uint32_t setAggOp(AggregateColumn* ac, Item_sum* isp)
return ER_CHECK_NOT_IMPLEMENTED; return ER_CHECK_NOT_IMPLEMENTED;
return rc; return rc;
} }
case Item_sum::UDF_SUM_FUNC:
ac->aggOp(AggregateColumn::UDAF);
return rc;
default: default:
return ER_CHECK_NOT_IMPLEMENTED; return ER_CHECK_NOT_IMPLEMENTED;
} }
@ -3527,7 +3534,9 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
gwi.aggOnSelect = true; gwi.aggOnSelect = true;
// N.B. argument_count() is the # of formal parms to the agg fcn. InifniDB only supports 1 argument // N.B. argument_count() is the # of formal parms to the agg fcn. InifniDB only supports 1 argument
if (isp->argument_count() != 1 && isp->sum_func() != Item_sum::GROUP_CONCAT_FUNC) // TODO: Support more than one parm
if (isp->argument_count() != 1 && isp->sum_func() != Item_sum::GROUP_CONCAT_FUNC
&& isp->sum_func() != Item_sum::UDF_SUM_FUNC)
{ {
gwi.fatalParseError = true; gwi.fatalParseError = true;
gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_MUL_ARG_AGG); gwi.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_MUL_ARG_AGG);
@ -3536,9 +3545,18 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
AggregateColumn* ac = NULL; AggregateColumn* ac = NULL;
if (isp->sum_func() == Item_sum::GROUP_CONCAT_FUNC) if (isp->sum_func() == Item_sum::GROUP_CONCAT_FUNC)
{
ac = new GroupConcatColumn(gwi.sessionid); ac = new GroupConcatColumn(gwi.sessionid);
}
else else
if (isp->sum_func() == Item_sum::UDF_SUM_FUNC)
{
ac = new UDAFColumn(gwi.sessionid);
}
else
{
ac = new AggregateColumn(gwi.sessionid); ac = new AggregateColumn(gwi.sessionid);
}
if (isp->name) if (isp->name)
ac->alias(isp->name); ac->alias(isp->name);
@ -3894,6 +3912,53 @@ ReturnedColumn* buildAggregateColumn(Item* item, gp_walk_info& gwi)
{ {
gwi.count_asterisk_list.push_back(ac); gwi.count_asterisk_list.push_back(ac);
} }
// For UDAF, populate the context and call the UDAF init() function.
if (isp->sum_func() == Item_sum::UDF_SUM_FUNC)
{
UDAFColumn* udafc = dynamic_cast<UDAFColumn*>(ac);
if (udafc)
{
mcsv1Context& context = udafc->getContext();
context.setName(isp->func_name());
// Set up the return type defaults for the call to init()
context.setResultType(udafc->resultType().colDataType);
context.setColWidth(udafc->resultType().colWidth);
context.setScale(udafc->resultType().scale);
context.setPrecision(udafc->resultType().precision);
COL_TYPES colTypes;
execplan::CalpontSelectExecutionPlan::ColumnMap::iterator cmIter;
// Build the column type vector. For now, there is only one
colTypes.push_back(make_pair(udafc->functionParms()->alias(), udafc->functionParms()->resultType().colDataType));
// Call the user supplied init()
if (context.getFunction()->init(&context, colTypes) == mcsv1_UDAF::ERROR)
{
gwi.fatalParseError = true;
gwi.parseErrorText = udafc->getContext().getErrorMessage();
return NULL;
}
if (udafc->getContext().getRunFlag(UDAF_OVER_REQUIRED))
{
gwi.fatalParseError = true;
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WINDOW_FUNC_ONLY,
context.getName());
return NULL;
}
// Set the return type as set in init()
CalpontSystemCatalog::ColType ct;
ct.colDataType = context.getResultType();
ct.colWidth = context.getColWidth();
ct.scale = context.getScale();
ct.precision = context.getPrecision();
udafc->resultType(ct);
}
}
return ac; return ac;
} }

View File

@ -582,6 +582,8 @@ int fetchNextRow(uchar *buf, cal_table_info& ti, cal_connection_info* ci)
(*f)->field_length = 40; (*f)->field_length = 40;
//float float_val = *(float*)(&value); //float float_val = *(float*)(&value);
//f2->store(float_val); //f2->store(float_val);
if (f2->decimals() < (uint32_t)row.getScale(s))
f2->dec = (uint32_t)row.getScale(s);
f2->store(dl); f2->store(dl);
if ((*f)->null_ptr) if ((*f)->null_ptr)
*(*f)->null_ptr &= ~(*f)->null_bit; *(*f)->null_ptr &= ~(*f)->null_bit;
@ -603,6 +605,8 @@ int fetchNextRow(uchar *buf, cal_table_info& ti, cal_connection_info* ci)
(*f)->field_length = 310; (*f)->field_length = 310;
//double double_val = *(double*)(&value); //double double_val = *(double*)(&value);
//f2->store(double_val); //f2->store(double_val);
if (f2->decimals() < (uint32_t)row.getScale(s))
f2->dec = (uint32_t)row.getScale(s);
f2->store(dl); f2->store(dl);
if ((*f)->null_ptr) if ((*f)->null_ptr)
*(*f)->null_ptr &= ~(*f)->null_bit; *(*f)->null_ptr &= ~(*f)->null_bit;

View File

@ -45,6 +45,9 @@ using namespace logging;
#include "funcexp.h" #include "funcexp.h"
using namespace funcexp; using namespace funcexp;
#include "mcsv1_udaf.h"
using namespace mcsv1sdk;
namespace cal_impl_if { namespace cal_impl_if {
ReturnedColumn* nullOnError(gp_walk_info& gwi) ReturnedColumn* nullOnError(gp_walk_info& gwi)
@ -232,7 +235,7 @@ string ConvertFuncName(Item_sum* item)
return "BIT_XOR"; return "BIT_XOR";
break; break;
case Item_sum::UDF_SUM_FUNC: case Item_sum::UDF_SUM_FUNC:
return "UDF_SUM_FUNC"; // Not supported return "UDAF_FUNC";
break; break;
case Item_sum::GROUP_CONCAT_FUNC: case Item_sum::GROUP_CONCAT_FUNC:
return "GROUP_CONCAT"; // Not supported return "GROUP_CONCAT"; // Not supported
@ -286,14 +289,14 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
gwi.hasWindowFunc = true; gwi.hasWindowFunc = true;
Item_window_func* wf = (Item_window_func*)item; Item_window_func* wf = (Item_window_func*)item;
string funcName = ConvertFuncName(wf->window_func()); Item_sum* item_sum = wf->window_func();
string funcName = ConvertFuncName(item_sum);
WindowFunctionColumn* ac = new WindowFunctionColumn(funcName); WindowFunctionColumn* ac = new WindowFunctionColumn(funcName);
ac->distinct(wf->window_func()->has_with_distinct()); ac->distinct(item_sum->has_with_distinct());
Window_spec *win_spec = wf->window_spec; Window_spec *win_spec = wf->window_spec;
SRCP srcp; SRCP srcp;
// arguments // arguments
vector<SRCP> funcParms; vector<SRCP> funcParms;
Item_sum* item_sum = (Item_sum*)wf->arguments()[0];
for (uint32_t i = 0; i < item_sum->argument_count(); i++) for (uint32_t i = 0; i < item_sum->argument_count(); i++)
{ {
srcp.reset(buildReturnedColumn((item_sum->arguments()[i]), gwi, nonSupport)); srcp.reset(buildReturnedColumn((item_sum->arguments()[i]), gwi, nonSupport));
@ -303,17 +306,76 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
if (gwi.clauseType == WHERE && !gwi.rcWorkStack.empty()) if (gwi.clauseType == WHERE && !gwi.rcWorkStack.empty())
gwi.rcWorkStack.pop(); gwi.rcWorkStack.pop();
} }
// Setup UDAnF functions
if (item_sum->sum_func() == Item_sum::UDF_SUM_FUNC)
{
Item_udf_sum* udfsum = (Item_udf_sum*)item_sum;
mcsv1sdk::mcsv1Context& context = ac->getUDAFContext();
context.setName(udfsum->func_name());
// Set up the return type defaults for the call to init()
execplan::CalpontSystemCatalog::ColType& rt = ac->resultType();
context.setResultType(rt.colDataType);
context.setColWidth(rt.colWidth);
context.setScale(rt.scale);
context.setPrecision(rt.precision);
// Turn on the Analytic flag so the function is aware it is being called
// as a Window Function.
context.setContextFlag(CONTEXT_IS_ANALYTIC);
COL_TYPES colTypes;
execplan::CalpontSelectExecutionPlan::ColumnMap::iterator cmIter;
// Build the column type vector.
for (size_t i=0; i < funcParms.size(); ++i)
{
colTypes.push_back(make_pair(funcParms[i]->alias(), funcParms[i]->resultType().colDataType));
}
// Call the user supplied init()
if (context.getFunction()->init(&context, colTypes) == mcsv1_UDAF::ERROR)
{
gwi.fatalParseError = true;
gwi.parseErrorText = context.getErrorMessage();
return NULL;
}
if (!context.getRunFlag(UDAF_OVER_REQUIRED) && !context.getRunFlag(UDAF_OVER_ALLOWED))
{
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_UDANF_NOT_ALLOWED,
context.getName());
return nullOnError(gwi);
}
// Set the return type as set in init()
CalpontSystemCatalog::ColType ct;
ct.colDataType = context.getResultType();
ct.colWidth = context.getColWidth();
ct.scale = context.getScale();
ct.precision = context.getPrecision();
ac->resultType(ct);
}
// Some functions, such as LEAD/LAG don't have all parameters implemented in the // Some functions, such as LEAD/LAG don't have all parameters implemented in the
// front end. Add dummies here to make the backend use defaults. // front end. Add dummies here to make the backend use defaults.
// Some of these will be temporary until they are implemented in the front end. // Some of these will be temporary until they are implemented in the front end.
// Others need to stay because the back end expects them, but the front end // Others need to stay because the back end expects them, but the front end
// no longer sends them. // no longer sends them.
// This case is kept in enum order in hopes the compiler can optimize // This case is kept in enum order in hopes the compiler can optimize
switch (wf->window_func()->sum_func()) switch (item_sum->sum_func())
{ {
case Item_sum::COUNT_FUNC: case Item_sum::UDF_SUM_FUNC:
case Item_sum::COUNT_DISTINCT_FUNC: {
uint64_t bIgnoreNulls = (ac->getUDAFContext().getRunFlag(mcsv1sdk::UDAF_IGNORE_NULLS));
char sIgnoreNulls[18];
sprintf(sIgnoreNulls, "%lu", bIgnoreNulls);
srcp.reset(new ConstantColumn(sIgnoreNulls, (uint64_t)bIgnoreNulls, ConstantColumn::NUM)); // IGNORE/RESPECT NULLS. 1 => RESPECT
funcParms.push_back(srcp);
break; break;
}
case Item_sum::FIRST_VALUE_FUNC: case Item_sum::FIRST_VALUE_FUNC:
srcp.reset(new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // OFFSET (always one) srcp.reset(new ConstantColumn("1", (uint64_t)1, ConstantColumn::NUM)); // OFFSET (always one)
funcParms.push_back(srcp); funcParms.push_back(srcp);
@ -365,251 +427,326 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
ac->partitions(partitions); ac->partitions(partitions);
// Order by // Order by
WF_OrderBy orderBy;
// order columns
if (win_spec->order_list) if (win_spec->order_list)
{ {
WF_OrderBy orderBy; // It is an error to have an order by clause if a UDAnF says it shouldn't
// order columns if (item_sum->sum_func() == Item_sum::UDF_SUM_FUNC)
if (win_spec->order_list)
{ {
vector<SRCP> orders; mcsv1sdk::mcsv1Context& context = ac->getUDAFContext();
ORDER* orderCol = reinterpret_cast<ORDER*>(win_spec->order_list->first); if (!context.getRunFlag(UDAF_ORDER_ALLOWED))
for (; orderCol; orderCol= orderCol->next)
{ {
Item* orderItem = *(orderCol->item); gwi.parseErrorText =
srcp.reset(buildReturnedColumn(orderItem, gwi, nonSupport)); logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_UDANF_ORDER_NOT_ALLOWED,
if (!srcp) context.getName());
return nullOnError(gwi); return nullOnError(gwi);
srcp->asc(orderCol->direction == ORDER::ORDER_ASC ? true : false);
// srcp->nullsFirst(orderCol->nulls); // nulls 2-default, 1-nulls first, 0-nulls last
srcp->nullsFirst(orderCol->direction == ORDER::ORDER_ASC ? 1 : 0); // WINDOWS TODO: implement NULLS FIRST/LAST in 10.2 front end
orders.push_back(srcp);
} }
orderBy.fOrders = orders;
} }
// window frame vector<SRCP> orders;
WF_Frame frm; ORDER* orderCol = reinterpret_cast<ORDER*>(win_spec->order_list->first);
if (win_spec->window_frame) for (; orderCol; orderCol= orderCol->next)
{ {
frm.fIsRange = win_spec->window_frame->units == Window_frame::UNITS_RANGE; Item* orderItem = *(orderCol->item);
// start srcp.reset(buildReturnedColumn(orderItem, gwi, nonSupport));
if (win_spec->window_frame->top_bound) if (!srcp)
return nullOnError(gwi);
srcp->asc(orderCol->direction == ORDER::ORDER_ASC ? true : false);
// srcp->nullsFirst(orderCol->nulls); // nulls 2-default, 1-nulls first, 0-nulls last
srcp->nullsFirst(orderCol->direction == ORDER::ORDER_ASC ? 1 : 0); // WINDOWS TODO: implement NULLS FIRST/LAST in 10.2 front end
orders.push_back(srcp);
}
orderBy.fOrders = orders;
}
else
{
if (item_sum->sum_func() == Item_sum::UDF_SUM_FUNC)
{
mcsv1sdk::mcsv1Context& context = ac->getUDAFContext();
if (context.getRunFlag(UDAF_ORDER_REQUIRED))
{ {
frm.fStart.fFrame = frame(win_spec->window_frame->top_bound->precedence_type, gwi.parseErrorText =
win_spec->window_frame->top_bound->offset); // offset NULL means UNBOUNDED logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_UDANF_NOT_ALLOWED,
context.getName());
return nullOnError(gwi);
}
}
}
if (win_spec->window_frame->top_bound->offset) // window frame
WF_Frame frm;
if (win_spec->window_frame)
{
// It is an error to have a frame clause if a UDAnF says it shouldn't
if (item_sum->sum_func() == Item_sum::UDF_SUM_FUNC)
{
mcsv1sdk::mcsv1Context& context = ac->getUDAFContext();
if (!context.getRunFlag(UDAF_WINDOWFRAME_ALLOWED))
{
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_UDANF_FRAME_NOT_ALLOWED,
context.getName());
return nullOnError(gwi);
}
}
frm.fIsRange = win_spec->window_frame->units == Window_frame::UNITS_RANGE;
// start
if (win_spec->window_frame->top_bound)
{
frm.fStart.fFrame = frame(win_spec->window_frame->top_bound->precedence_type,
win_spec->window_frame->top_bound->offset); // offset NULL means UNBOUNDED
if (win_spec->window_frame->top_bound->offset)
{
frm.fStart.fVal.reset(buildReturnedColumn(win_spec->window_frame->top_bound->offset, gwi, nonSupport));
if (!frm.fStart.fVal)
return nullOnError(gwi);
// 1. check expr is numeric type (rows) or interval (range)
bool boundTypeErr = false;
switch (frm.fStart.fVal->resultType().colDataType)
{ {
frm.fStart.fVal.reset(buildReturnedColumn(win_spec->window_frame->top_bound->offset, gwi, nonSupport)); case CalpontSystemCatalog::CHAR:
if (!frm.fStart.fVal) case CalpontSystemCatalog::VARCHAR:
return nullOnError(gwi); case CalpontSystemCatalog::VARBINARY:
case CalpontSystemCatalog::BLOB:
// 1. check expr is numeric type (rows) or interval (range) case CalpontSystemCatalog::TEXT:
bool boundTypeErr = false; case CalpontSystemCatalog::CLOB:
switch (frm.fStart.fVal->resultType().colDataType) boundTypeErr = true;
{ break;
case CalpontSystemCatalog::CHAR: case CalpontSystemCatalog::DATE:
case CalpontSystemCatalog::VARCHAR: case CalpontSystemCatalog::DATETIME:
case CalpontSystemCatalog::VARBINARY: if (!frm.fIsRange)
case CalpontSystemCatalog::BLOB:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::CLOB:
boundTypeErr = true; boundTypeErr = true;
break; else if (dynamic_cast<IntervalColumn*>(frm.fStart.fVal.get()) == NULL)
case CalpontSystemCatalog::DATE:
case CalpontSystemCatalog::DATETIME:
if (!frm.fIsRange)
boundTypeErr = true;
else if (dynamic_cast<IntervalColumn*>(frm.fStart.fVal.get()) == NULL)
boundTypeErr = true;
break;
default: //okay
break;
}
if (boundTypeErr)
{
gwi.fatalParseError = true;
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_BOUND_TYPE,
colDataTypeToString(frm.fStart.fVal->resultType().colDataType));
return nullOnError(gwi);
}
}
}
// end
if (win_spec->window_frame->bottom_bound)
{
frm.fEnd.fFrame = frame(win_spec->window_frame->bottom_bound->precedence_type,
win_spec->window_frame->bottom_bound->offset);
if (win_spec->window_frame->bottom_bound->offset)
{
frm.fEnd.fVal.reset(buildReturnedColumn(win_spec->window_frame->bottom_bound->offset, gwi, nonSupport));
if (!frm.fEnd.fVal)
return nullOnError(gwi);
// check expr is numeric type (rows) or interval (range)
bool boundTypeErr = false;
switch (frm.fEnd.fVal->resultType().colDataType)
{
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY:
case CalpontSystemCatalog::BLOB:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::CLOB:
boundTypeErr = true; boundTypeErr = true;
break; break;
case CalpontSystemCatalog::DATE: default: //okay
case CalpontSystemCatalog::DATETIME: break;
if (!frm.fIsRange)
boundTypeErr = true;
else if (dynamic_cast<IntervalColumn*>(frm.fEnd.fVal.get()) == NULL)
boundTypeErr = true;
break;
default: //okay
break;
}
if (boundTypeErr)
{
gwi.fatalParseError = true;
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_BOUND_TYPE,
colDataTypeToString(frm.fStart.fVal->resultType().colDataType));
return nullOnError(gwi);
}
} }
} if (boundTypeErr)
else // no end specified. default end to current row
{
frm.fEnd.fFrame = WF_CURRENT_ROW;
}
if (frm.fStart.fVal || frm.fEnd.fVal)
{
// check order by key only 1 (should be error-ed out in parser. double check here)
if (frm.fIsRange && orderBy.fOrders.size() > 1)
{ {
gwi.fatalParseError = true; gwi.fatalParseError = true;
gwi.parseErrorText = gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_ORDER_KEY); logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_BOUND_TYPE,
colDataTypeToString(frm.fStart.fVal->resultType().colDataType));
return nullOnError(gwi); return nullOnError(gwi);
} }
}
}
// check order by key type is numeric or date/datetime // end
bool orderTypeErr = false; if (win_spec->window_frame->bottom_bound)
if (frm.fIsRange && orderBy.fOrders.size() == 1) {
frm.fEnd.fFrame = frame(win_spec->window_frame->bottom_bound->precedence_type,
win_spec->window_frame->bottom_bound->offset);
if (win_spec->window_frame->bottom_bound->offset)
{
frm.fEnd.fVal.reset(buildReturnedColumn(win_spec->window_frame->bottom_bound->offset, gwi, nonSupport));
if (!frm.fEnd.fVal)
return nullOnError(gwi);
// check expr is numeric type (rows) or interval (range)
bool boundTypeErr = false;
switch (frm.fEnd.fVal->resultType().colDataType)
{ {
switch (orderBy.fOrders[0]->resultType().colDataType) case CalpontSystemCatalog::CHAR:
{ case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::CHAR: case CalpontSystemCatalog::VARBINARY:
case CalpontSystemCatalog::VARCHAR: case CalpontSystemCatalog::BLOB:
case CalpontSystemCatalog::VARBINARY: case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::BLOB: case CalpontSystemCatalog::CLOB:
case CalpontSystemCatalog::TEXT: boundTypeErr = true;
case CalpontSystemCatalog::CLOB: break;
orderTypeErr = true; case CalpontSystemCatalog::DATE:
break; case CalpontSystemCatalog::DATETIME:
default: //okay if (!frm.fIsRange)
// interval bound has to have date/datetime order key boundTypeErr = true;
if ((dynamic_cast<IntervalColumn*>(frm.fStart.fVal.get()) != NULL || else if (dynamic_cast<IntervalColumn*>(frm.fEnd.fVal.get()) == NULL)
dynamic_cast<IntervalColumn*>(frm.fEnd.fVal.get()) != NULL)) boundTypeErr = true;
{ break;
if (orderBy.fOrders[0]->resultType().colDataType != CalpontSystemCatalog::DATE && default: //okay
orderBy.fOrders[0]->resultType().colDataType != CalpontSystemCatalog::DATETIME) break;
orderTypeErr = true; }
} if (boundTypeErr)
else {
{ gwi.fatalParseError = true;
if (orderBy.fOrders[0]->resultType().colDataType == CalpontSystemCatalog::DATETIME) gwi.parseErrorText =
orderTypeErr = true; logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_BOUND_TYPE,
} colDataTypeToString(frm.fStart.fVal->resultType().colDataType));
break; return nullOnError(gwi);
}
if (orderTypeErr)
{
gwi.fatalParseError = true;
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_ORDER_TYPE,
colDataTypeToString(orderBy.fOrders[0]->resultType().colDataType));
return nullOnError(gwi);
}
} }
} }
}
else // no end specified. default end to current row
{
frm.fEnd.fFrame = WF_CURRENT_ROW;
}
// construct +,- or interval function for boundary if (frm.fStart.fVal || frm.fEnd.fVal)
if (frm.fIsRange && frm.fStart.fVal) {
// check order by key only 1 (should be error-ed out in parser. double check here)
if (frm.fIsRange && orderBy.fOrders.size() > 1)
{ {
frm.fStart.fBound.reset(buildBoundExp(frm.fStart, orderBy.fOrders[0], gwi)); gwi.fatalParseError = true;
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_ORDER_KEY);
return nullOnError(gwi);
}
// check order by key type is numeric or date/datetime
bool orderTypeErr = false;
if (frm.fIsRange && orderBy.fOrders.size() == 1)
{
switch (orderBy.fOrders[0]->resultType().colDataType)
{
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY:
case CalpontSystemCatalog::BLOB:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::CLOB:
orderTypeErr = true;
break;
default: //okay
// interval bound has to have date/datetime order key
if ((dynamic_cast<IntervalColumn*>(frm.fStart.fVal.get()) != NULL ||
dynamic_cast<IntervalColumn*>(frm.fEnd.fVal.get()) != NULL))
{
if (orderBy.fOrders[0]->resultType().colDataType != CalpontSystemCatalog::DATE &&
orderBy.fOrders[0]->resultType().colDataType != CalpontSystemCatalog::DATETIME)
orderTypeErr = true;
}
else
{
if (orderBy.fOrders[0]->resultType().colDataType == CalpontSystemCatalog::DATETIME)
orderTypeErr = true;
}
break;
}
if (orderTypeErr)
{
gwi.fatalParseError = true;
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_INVALID_ORDER_TYPE,
colDataTypeToString(orderBy.fOrders[0]->resultType().colDataType));
return nullOnError(gwi);
}
}
}
// construct +,- or interval function for boundary
if (frm.fIsRange && frm.fStart.fVal)
{
frm.fStart.fBound.reset(buildBoundExp(frm.fStart, orderBy.fOrders[0], gwi));
if (!frm.fStart.fBound)
return nullOnError(gwi);
}
if (frm.fIsRange && frm.fEnd.fVal)
{
frm.fEnd.fBound.reset(buildBoundExp(frm.fEnd, orderBy.fOrders[0], gwi));
if (!frm.fEnd.fVal)
return nullOnError(gwi);
}
}
else
{
// Certain function types have different default boundaries
// This case is kept in enum order in hopes the compiler can optimize
switch (item_sum->sum_func())
{
case Item_sum::COUNT_FUNC:
case Item_sum::COUNT_DISTINCT_FUNC:
case Item_sum::SUM_FUNC:
case Item_sum::SUM_DISTINCT_FUNC:
case Item_sum::AVG_FUNC:
case Item_sum::AVG_DISTINCT_FUNC:
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fEnd.fFrame = WF_CURRENT_ROW;
break;
case Item_sum::MIN_FUNC:
case Item_sum::MAX_FUNC:
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
// frm.fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
frm.fEnd.fFrame = WF_CURRENT_ROW;
break;
case Item_sum::STD_FUNC:
case Item_sum::VARIANCE_FUNC:
case Item_sum::SUM_BIT_FUNC:
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fEnd.fFrame = WF_CURRENT_ROW;
break;
case Item_sum::UDF_SUM_FUNC:
{
mcsv1sdk::mcsv1Context& context = ac->getUDAFContext();
if (context.getRunFlag(UDAF_WINDOWFRAME_REQUIRED))
{
gwi.parseErrorText =
logging::IDBErrorInfo::instance()->errorMsg(logging::ERR_WF_UDANF_FRAME_REQUIRED,
context.getName());
return nullOnError(gwi);
}
int32_t bound;
context.getStartFrame(frm.fStart.fFrame, bound);
if (frm.fStart.fFrame == execplan::WF_PRECEDING)
{
if (bound == 0)
bound = 1;
srcp.reset(new ConstantColumn((int64_t)bound));
frm.fStart.fVal = srcp;
frm.fStart.fBound.reset(buildBoundExp(frm.fStart, srcp, gwi));
if (!frm.fStart.fBound) if (!frm.fStart.fBound)
return nullOnError(gwi); return nullOnError(gwi);
} }
if (frm.fIsRange && frm.fEnd.fVal)
context.getEndFrame(frm.fEnd.fFrame, bound);
if (frm.fEnd.fFrame == execplan::WF_FOLLOWING)
{ {
frm.fEnd.fBound.reset(buildBoundExp(frm.fEnd, orderBy.fOrders[0], gwi)); if (bound == 0)
if (!frm.fEnd.fVal) bound = 1;
srcp.reset(new ConstantColumn((int64_t)bound));
frm.fEnd.fVal = srcp;
frm.fEnd.fBound.reset(buildBoundExp(frm.fEnd, srcp, gwi));
if (!frm.fEnd.fBound)
return nullOnError(gwi); return nullOnError(gwi);
} }
break;
} }
else case Item_sum::GROUP_CONCAT_FUNC:
{ frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
// Certain function types have different default boundaries frm.fEnd.fFrame = WF_CURRENT_ROW;
// This case is kept in enum order in hopes the compiler can optimize break;
switch (wf->window_func()->sum_func()) case Item_sum::ROW_NUMBER_FUNC:
{ case Item_sum::RANK_FUNC:
case Item_sum::COUNT_FUNC: case Item_sum::DENSE_RANK_FUNC:
case Item_sum::COUNT_DISTINCT_FUNC: case Item_sum::PERCENT_RANK_FUNC:
case Item_sum::SUM_FUNC: case Item_sum::CUME_DIST_FUNC:
case Item_sum::SUM_DISTINCT_FUNC: case Item_sum::NTILE_FUNC:
case Item_sum::AVG_FUNC: frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
case Item_sum::AVG_DISTINCT_FUNC: frm.fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING; break;
frm.fEnd.fFrame = WF_CURRENT_ROW; case Item_sum::FIRST_VALUE_FUNC:
break; case Item_sum::LAST_VALUE_FUNC:
case Item_sum::MIN_FUNC: case Item_sum::NTH_VALUE_FUNC:
case Item_sum::MAX_FUNC: frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING; frm.fEnd.fFrame = WF_CURRENT_ROW;
// frm.fEnd.fFrame = WF_UNBOUNDED_FOLLOWING; break;
frm.fEnd.fFrame = WF_CURRENT_ROW; case Item_sum::LEAD_FUNC:
break; case Item_sum::LAG_FUNC:
case Item_sum::STD_FUNC: frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
case Item_sum::VARIANCE_FUNC: frm.fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
case Item_sum::SUM_BIT_FUNC: break;
case Item_sum::UDF_SUM_FUNC: default:
case Item_sum::GROUP_CONCAT_FUNC: frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING; frm.fEnd.fFrame = WF_CURRENT_ROW;
frm.fEnd.fFrame = WF_CURRENT_ROW; break;
break; };
case Item_sum::ROW_NUMBER_FUNC:
case Item_sum::RANK_FUNC:
case Item_sum::DENSE_RANK_FUNC:
case Item_sum::PERCENT_RANK_FUNC:
case Item_sum::CUME_DIST_FUNC:
case Item_sum::NTILE_FUNC:
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
break;
case Item_sum::FIRST_VALUE_FUNC:
case Item_sum::LAST_VALUE_FUNC:
case Item_sum::NTH_VALUE_FUNC:
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fEnd.fFrame = WF_CURRENT_ROW;
break;
case Item_sum::LEAD_FUNC:
case Item_sum::LAG_FUNC:
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fEnd.fFrame = WF_UNBOUNDED_FOLLOWING;
break;
default:
frm.fStart.fFrame = WF_UNBOUNDED_PRECEDING;
frm.fEnd.fFrame = WF_CURRENT_ROW;
break;
};
}
orderBy.fFrame = frm;
ac->orderBy(orderBy);
} }
orderBy.fFrame = frm;
ac->orderBy(orderBy);
} }
if (gwi.fatalParseError || nonSupport) if (gwi.fatalParseError || nonSupport)
@ -620,7 +757,8 @@ ReturnedColumn* buildWindowFunctionColumn(Item* item, gp_walk_info& gwi, bool& n
return NULL; return NULL;
} }
ac->resultType(colType_MysqlToIDB(wf->arguments()[0])); ac->resultType(colType_MysqlToIDB(item_sum));
// bug5736. Make the result type double for some window functions when // bug5736. Make the result type double for some window functions when
// infinidb_double_for_decimal_math is set. // infinidb_double_for_decimal_math is set.
ac->adjustResultType(); ac->adjustResultType();

View File

@ -310,7 +310,7 @@ fi
kill_by_pid() { kill_by_pid() {
# let's see if we can kill the 2 mysql procs by hand # let's see if we can kill the 2 mysql procs by hand
# get the our mysql from ps # get the our mysql from ps
eval $(ps -ef | grep "$COLUMNSTORE_INSTALL_DIR/mysql//bin/mysqld " | grep -v grep | head -1 | awk '{printf "pid=%d\n", $2}') eval $(ps -ef | grep "$COLUMNSTORE_INSTALL_DIR/mysql//bin/mysqld" | grep -v grep | head -1 | awk '{printf "pid=%d\n", $2}')
if [ -n "$pid" ]; then if [ -n "$pid" ]; then
ppid=$(ps -o ppid= -p $pid) ppid=$(ps -o ppid= -p $pid)

442
ddlproc/ddlproc.vpj Normal file → Executable file
View File

@ -1,224 +1,224 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdDDLProc" OutputFile="%bdDDLProc"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/ddlproc/"> ObjectDir="/home/dhall/genii/ddlproc/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=" make install"/> <Exec CmdLine=" make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdDDLProc" OutputFile="%bdDDLProc"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=" make install"/> <Exec CmdLine=" make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="ddlproc.cpp"/> <F N="ddlproc.cpp"/>
<F N="ddlprocessor.cpp"/> <F N="ddlprocessor.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="ddlproc.h"/> <F N="ddlproc.h"/>
<F N="ddlprocessor.h"/> <F N="ddlprocessor.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

470
dmlproc/dmlproc.vpj Normal file → Executable file
View File

@ -1,238 +1,238 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdDMLProc" OutputFile="%bdDMLProc"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/dmlproc/" ObjectDir="/home/dhall/genii/dmlproc/"
Defines='"/D-Wall"'> Defines='"/D-Wall"'>
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i %f'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i %f'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='g++ %xup -g -o "%o" %objs'/> <Exec CmdLine='g++ %xup -g -o "%o" %objs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="/home/dhall/genii/dmlproc/" RunFromDir="/home/dhall/genii/dmlproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dmlproc/" RunFromDir="/home/dhall/genii/dmlproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
<Includes/> <Includes/>
<Libs PreObjects="0"/> <Libs PreObjects="0"/>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdDMLProc" OutputFile="%bdDMLProc"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
Defines='"/D-Wall"' Defines='"/D-Wall"'
ObjectDir="/home/dhall/genii/dmlproc/"> ObjectDir="/home/dhall/genii/dmlproc/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i %f'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i %f'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='g++ %xup -o "%o" %objs'/> <Exec CmdLine='g++ %xup -o "%o" %objs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="/home/dhall/genii/dmlproc/" RunFromDir="/home/dhall/genii/dmlproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="/home/dhall/genii/dmlproc/" RunFromDir="/home/dhall/genii/dmlproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
<Includes/> <Includes/>
<Libs PreObjects="0"/> <Libs PreObjects="0"/>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="batchinsertprocessor.cpp"/> <F N="batchinsertprocessor.cpp"/>
<F N="dmlproc.cpp"/> <F N="dmlproc.cpp"/>
<F N="dmlprocessor.cpp"/> <F N="dmlprocessor.cpp"/>
<F N="dmlresultbuffer.cpp"/> <F N="dmlresultbuffer.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="batchinsertprocessor.h"/> <F N="batchinsertprocessor.h"/>
<F N="dmlproc.h"/> <F N="dmlproc.h"/>
<F N="dmlprocessor.h"/> <F N="dmlprocessor.h"/>
<F N="dmlresultbuffer.h"/> <F N="dmlresultbuffer.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

444
primitives/linux-port/linux-port.vpj Normal file → Executable file
View File

@ -1,225 +1,225 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdprocessor.a" OutputFile="%bdprocessor.a"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='ar -rs %xup "%o" %f'/> <Exec CmdLine='ar -rs %xup "%o" %f'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="StaticLibrary"/> Value="StaticLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdprocessor.a" OutputFile="%bdprocessor.a"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='ar -rs %xup "%o" %f'/> <Exec CmdLine='ar -rs %xup "%o" %f'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="StaticLibrary"/> Value="StaticLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="column.cpp"/> <F N="column.cpp"/>
<F N="dictionary.cpp"/> <F N="dictionary.cpp"/>
<F N="index.cpp"/> <F N="index.cpp"/>
<F N="primitiveprocessor.cpp"/> <F N="primitiveprocessor.cpp"/>
<F N="print_dictblock.cpp"/> <F N="print_dictblock.cpp"/>
<F N="print_indexlist.cpp"/> <F N="print_indexlist.cpp"/>
<F N="print_indextree_subblock.cpp"/> <F N="print_indextree_subblock.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="primitiveprocessor.h"/> <F N="primitiveprocessor.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

27
primitives/primproc/batchprimitiveprocessor.cpp Normal file → Executable file
View File

@ -371,8 +371,20 @@ void BatchPrimitiveProcessor::initBPP(ByteStream &bs)
{ {
bs >> fAggregateRG; bs >> fAggregateRG;
fAggregator.reset(new RowAggregation); fAggregator.reset(new RowAggregation);
// cout << "Made an aggregator\n";
bs >> *(fAggregator.get()); bs >> *(fAggregator.get());
// If there's UDAF involved, set up for PM processing
for (uint64_t i = 0; i < fAggregator->getAggFunctions().size(); i++)
{
RowUDAFFunctionCol* rowUDAF = dynamic_cast<RowUDAFFunctionCol*>(fAggregator->getAggFunctions()[i].get());
if (rowUDAF)
{
// On the PM, the aux column is not sent, but rather is output col + 1.
rowUDAF->fAuxColumnIndex = rowUDAF->fOutputColumnIndex + 1;
// Set the PM flag in case the UDAF cares.
rowUDAF->fUDAFContext.setContextFlags(rowUDAF->fUDAFContext.getContextFlags()
| mcsv1sdk::CONTEXT_IS_PM);
}
}
} }
} }
@ -1294,7 +1306,7 @@ void BatchPrimitiveProcessor::execute()
} // @bug4507, 8k } // @bug4507, 8k
else { // @bug4507, 8k else { // @bug4507, 8k
fAggregator->loadResult(*serialized); // @bug4507, 8k fAggregator->loadResult(*serialized); // @bug4507, 8k
fAggregator->reset(); // @bug4507, 8k fAggregator->aggReset(); // @bug4507, 8k
} // @bug4507, 8k } // @bug4507, 8k
} }
else { else {
@ -1361,7 +1373,7 @@ void BatchPrimitiveProcessor::execute()
} // @bug4507, 8k } // @bug4507, 8k
else { // @bug4507, 8k else { // @bug4507, 8k
fAggregator->loadResult(*serialized); // @bug4507, 8k fAggregator->loadResult(*serialized); // @bug4507, 8k
fAggregator->reset(); // @bug4507, 8k fAggregator->aggReset(); // @bug4507, 8k
} // @bug4507, 8k } // @bug4507, 8k
} }
@ -1706,7 +1718,7 @@ int BatchPrimitiveProcessor::operator()()
} }
if (fAggregator && currentBlockOffset == 0) // @bug4507, 8k if (fAggregator && currentBlockOffset == 0) // @bug4507, 8k
fAggregator->reset(); // @bug4507, 8k fAggregator->aggReset(); // @bug4507, 8k
for (; currentBlockOffset < count; currentBlockOffset++) { for (; currentBlockOffset < count; currentBlockOffset++) {
if (!(sessionID & 0x80000000)) { // can't do this with syscat queries if (!(sessionID & 0x80000000)) { // can't do this with syscat queries
@ -1765,8 +1777,11 @@ int BatchPrimitiveProcessor::operator()()
vssCache.clear(); vssCache.clear();
#ifndef __FreeBSD__ #ifndef __FreeBSD__
if (sendThread->aborted()) // If we've been aborted the lock *may* have been released already
objLock.try_lock(); // By doing try_lock, we ensure the unlock will work whether it was
// locked or not.
if (sendThread->aborted())
objLock.try_lock();
objLock.unlock(); objLock.unlock();
#endif #endif
freeLargeBuffers(); freeLargeBuffers();

0
primitives/primproc/batchprimitiveprocessor.h Normal file → Executable file
View File

0
primitives/primproc/primitiveserver.cpp Normal file → Executable file
View File

510
primitives/primproc/primproc.vpj Normal file → Executable file
View File

@ -1,258 +1,258 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdPrimProc" OutputFile="%bdPrimProc"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/primitives/primproc/"> ObjectDir="/home/dhall/genii/primitives/primproc/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="/home/dhall/genii/primitives/primproc/" RunFromDir="/home/dhall/genii/primitives/primproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdPrimProc" OutputFile="%bdPrimProc"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/primitives/primproc/"> ObjectDir="/home/dhall/genii/primitives/primproc/">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make install"/> <Exec CmdLine="make install"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="/home/dhall/genii/primitives/primproc/" RunFromDir="/home/dhall/genii/primitives/primproc/"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="batchprimitiveprocessor.cpp"/> <F N="batchprimitiveprocessor.cpp"/>
<F N="bppseeder.cpp"/> <F N="bppseeder.cpp"/>
<F N="bppsendthread.cpp"/> <F N="bppsendthread.cpp"/>
<F N="columncommand.cpp"/> <F N="columncommand.cpp"/>
<F N="command.cpp"/> <F N="command.cpp"/>
<F N="dictstep.cpp"/> <F N="dictstep.cpp"/>
<F N="filtercommand.cpp"/> <F N="filtercommand.cpp"/>
<F N="logger.cpp"/> <F N="logger.cpp"/>
<F N="monitorprocmem.cpp"/> <F N="monitorprocmem.cpp"/>
<F N="passthrucommand.cpp"/> <F N="passthrucommand.cpp"/>
<F N="primitiveserver.cpp"/> <F N="primitiveserver.cpp"/>
<F N="primproc.cpp"/> <F N="primproc.cpp"/>
<F N="rowaggregation.cpp"/> <F N="rowaggregation.cpp"/>
<F N="rowgroup.cpp"/> <F N="rowgroup.cpp"/>
<F N="rtscommand.cpp"/> <F N="rtscommand.cpp"/>
<F N="tdriver-umsocksel.cpp"/> <F N="tdriver-umsocksel.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
<F N="udf.cpp"/> <F N="udf.cpp"/>
<F N="umsocketselector.cpp"/> <F N="umsocketselector.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="batchprimitiveprocessor.h"/> <F N="batchprimitiveprocessor.h"/>
<F N="bpp.h"/> <F N="bpp.h"/>
<F N="bppseeder.h"/> <F N="bppseeder.h"/>
<F N="bppsendthread.h"/> <F N="bppsendthread.h"/>
<F N="columncommand.h"/> <F N="columncommand.h"/>
<F N="command.h"/> <F N="command.h"/>
<F N="dictstep.h"/> <F N="dictstep.h"/>
<F N="filtercommand.h"/> <F N="filtercommand.h"/>
<F N="monitorprocmem.h"/> <F N="monitorprocmem.h"/>
<F N="passthrucommand.h"/> <F N="passthrucommand.h"/>
<F N="pp_logger.h"/> <F N="pp_logger.h"/>
<F N="primitiveserver.h"/> <F N="primitiveserver.h"/>
<F N="primproc.h"/> <F N="primproc.h"/>
<F N="rowaggregation.h"/> <F N="rowaggregation.h"/>
<F N="rowgroup.h"/> <F N="rowgroup.h"/>
<F N="rtscommand.h"/> <F N="rtscommand.h"/>
<F N="umsocketselector.h"/> <F N="umsocketselector.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

462
tools/dbloadxml/colxml.vpj Normal file → Executable file
View File

@ -1,234 +1,234 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdcolxml" OutputFile="%bdcolxml"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/tools/dbloadxml/" ObjectDir="/home/dhall/genii/tools/dbloadxml/"
Defines=""> Defines="">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i %f'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i %f'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %objs'/> <Exec CmdLine='g++ %xup -g -o "%o" %objs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec <Exec
CmdLine='vsdebugio -prog "%o" %~other' CmdLine='vsdebugio -prog "%o" %~other'
OtherOptions="tpch1 -t lineitem"/> OtherOptions="tpch1 -t lineitem"/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec <Exec
CmdLine='"%o" %~other' CmdLine='"%o" %~other'
OtherOptions="tpch1 -t lineitem"/> OtherOptions="tpch1 -t lineitem"/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
<Includes/> <Includes/>
<Libs PreObjects="0"/> <Libs PreObjects="0"/>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdcolxml" OutputFile="%bdcolxml"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
Defines=""> Defines="">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i %f'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i %f'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %objs'/> <Exec CmdLine='g++ %xup -o "%o" %objs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec <Exec
CmdLine='vsdebugio -prog "%o" %~other' CmdLine='vsdebugio -prog "%o" %~other'
OtherOptions="tpch1 -t lineitem"/> OtherOptions="tpch1 -t lineitem"/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec <Exec
CmdLine='"%o" %~other' CmdLine='"%o" %~other'
OtherOptions="tpch1 -t lineitem"/> OtherOptions="tpch1 -t lineitem"/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
<Includes/> <Includes/>
<Libs PreObjects="0"/> <Libs PreObjects="0"/>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="colxml.cpp"/> <F N="colxml.cpp"/>
<F N="inputmgr.cpp"/> <F N="inputmgr.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="inputmgr.h"/> <F N="inputmgr.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

460
tools/editem/editem.vpj Normal file → Executable file
View File

@ -1,233 +1,233 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdeditem" OutputFile="%bdeditem"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
ObjectDir="/home/dhall/genii/tools/editem/" ObjectDir="/home/dhall/genii/tools/editem/"
Defines=""> Defines="">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i %f'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i %f'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %objs'/> <Exec CmdLine='g++ %xup -g -o "%o" %objs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec <Exec
CmdLine='vsdebugio -prog "%o" %~other' CmdLine='vsdebugio -prog "%o" %~other'
OtherOptions="-u -o 8520"/> OtherOptions="-u -o 8520"/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec <Exec
CmdLine='"%o" %~other' CmdLine='"%o" %~other'
OtherOptions="-u -o 8520"/> OtherOptions="-u -o 8520"/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
<Includes/> <Includes/>
<Libs PreObjects="0"/> <Libs PreObjects="0"/>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdeditem" OutputFile="%bdeditem"
CompilerConfigName="Latest Version" CompilerConfigName="Latest Version"
Defines=""> Defines="">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i %f'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i %f'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %objs'/> <Exec CmdLine='g++ %xup -o "%o" %objs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec <Exec
CmdLine='vsdebugio -prog "%o" %~other' CmdLine='vsdebugio -prog "%o" %~other'
OtherOptions="-u -o 8520"/> OtherOptions="-u -o 8520"/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec <Exec
CmdLine='"%o" %~other' CmdLine='"%o" %~other'
OtherOptions="-u -o 8520"/> OtherOptions="-u -o 8520"/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
<Includes/> <Includes/>
<Libs PreObjects="0"/> <Libs PreObjects="0"/>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="editem.cpp"/> <F N="editem.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

430
tools/hdfsCheck/hdfsCheck.vpj Normal file → Executable file
View File

@ -1,218 +1,218 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdhdfsCheck" OutputFile="%bdhdfsCheck"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdhdfsCheck" OutputFile="%bdhdfsCheck"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='vsdebugio -prog "%o"'/> <Exec CmdLine='vsdebugio -prog "%o"'/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='"%o"'/> <Exec CmdLine='"%o"'/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="Executable"/> Value="Executable"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="hdfsCheck.cpp"/> <F N="hdfsCheck.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"/>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

223
utils/common/any.hpp Executable file
View File

@ -0,0 +1,223 @@
#pragma once
/*
* (C) Copyright Christopher Diggins 2005-2011
* (C) Copyright Pablo Aguilar 2005
* (C) Copyright Kevlin Henney 2001
*
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt
*/
#include <stdexcept>
namespace static_any
{
namespace anyimpl
{
struct bad_any_cast
{
};
struct empty_any
{
};
struct base_any_policy
{
virtual void static_delete(void** x) = 0;
virtual void copy_from_value(void const* src, void** dest) = 0;
virtual void clone(void* const* src, void** dest) = 0;
virtual void move(void* const* src, void** dest) = 0;
virtual void* get_value(void** src) = 0;
virtual size_t get_size() = 0;
};
template<typename T>
struct typed_base_any_policy : base_any_policy
{
virtual size_t get_size() { return sizeof(T); }
};
template<typename T>
struct small_any_policy : typed_base_any_policy<T>
{
virtual void static_delete(void** x) { }
virtual void copy_from_value(void const* src, void** dest)
{ new(dest) T(*reinterpret_cast<T const*>(src)); }
virtual void clone(void* const* src, void** dest) { *dest = *src; }
virtual void move(void* const* src, void** dest) { *dest = *src; }
virtual void* get_value(void** src) { return reinterpret_cast<void*>(src); }
};
template<typename T>
struct big_any_policy : typed_base_any_policy<T>
{
virtual void static_delete(void** x) { if (*x)
delete(*reinterpret_cast<T**>(x)); *x = NULL; }
virtual void copy_from_value(void const* src, void** dest) {
*dest = new T(*reinterpret_cast<T const*>(src)); }
virtual void clone(void* const* src, void** dest) {
*dest = new T(**reinterpret_cast<T* const*>(src)); }
virtual void move(void* const* src, void** dest) {
(*reinterpret_cast<T**>(dest))->~T();
**reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src); }
virtual void* get_value(void** src) { return *src; }
};
template<typename T>
struct choose_policy
{
typedef big_any_policy<T> type;
};
template<typename T>
struct choose_policy<T*>
{
typedef small_any_policy<T*> type;
};
struct any;
/// Choosing the policy for an any type is illegal, but should never happen.
/// This is designed to throw a compiler error.
template<>
struct choose_policy<any>
{
typedef void type;
};
/// Specializations for small types.
#define SMALL_POLICY(TYPE) template<> struct \
choose_policy<TYPE> { typedef small_any_policy<TYPE> type; };
SMALL_POLICY(char);
SMALL_POLICY(signed char);
SMALL_POLICY(unsigned char);
SMALL_POLICY(signed short);
SMALL_POLICY(unsigned short);
SMALL_POLICY(signed int);
SMALL_POLICY(unsigned int);
SMALL_POLICY(signed long);
SMALL_POLICY(unsigned long);
SMALL_POLICY(signed long long);
SMALL_POLICY(unsigned long long);
SMALL_POLICY(float);
SMALL_POLICY(double);
SMALL_POLICY(bool);
SMALL_POLICY(std::string);
#undef SMALL_POLICY
/// This function will return a different policy for each type.
template<typename T>
base_any_policy* get_policy()
{
static typename choose_policy<T>::type policy;
return &policy;
};
}
class any
{
private:
// fields
anyimpl::base_any_policy* policy;
void* object;
public:
/// Initializing constructor.
template <typename T>
any(const T& x)
: policy(anyimpl::get_policy<anyimpl::empty_any>()), object(NULL)
{
assign(x);
}
/// Empty constructor.
any()
: policy(anyimpl::get_policy<anyimpl::empty_any>()), object(NULL)
{ }
/// Special initializing constructor for string literals.
any(const char* x)
: policy(anyimpl::get_policy<anyimpl::empty_any>()), object(NULL)
{
assign(x);
}
/// Copy constructor.
any(const any& x)
: policy(anyimpl::get_policy<anyimpl::empty_any>()), object(NULL)
{
assign(x);
}
/// Destructor.
~any() {
policy->static_delete(&object);
}
/// Assignment function from another any.
any& assign(const any& x) {
reset();
policy = x.policy;
policy->clone(&x.object, &object);
return *this;
}
/// Assignment function.
template <typename T>
any& assign(const T& x) {
reset();
policy = anyimpl::get_policy<T>();
policy->copy_from_value(&x, &object);
return *this;
}
/// Assignment operator.
template<typename T>
any& operator=(const T& x) {
return assign(x);
}
/// Assignment operator, specialed for literal strings.
/// They have types like const char [6] which don't work as expected.
any& operator=(const char* x) {
return assign(x);
}
/// Utility functions
any& swap(any& x) {
std::swap(policy, x.policy);
std::swap(object, x.object);
return *this;
}
/// Cast operator. You can only cast to the original type.
template<typename T>
T& cast() {
if (policy != anyimpl::get_policy<T>())
throw anyimpl::bad_any_cast();
T* r = reinterpret_cast<T*>(policy->get_value(&object));
return *r;
}
/// Returns true if the any contains no value.
bool empty() const {
return policy == anyimpl::get_policy<anyimpl::empty_any>();
}
/// Frees any allocated memory, and sets the value to NULL.
void reset() {
policy->static_delete(&object);
policy = anyimpl::get_policy<anyimpl::empty_any>();
}
/// Returns true if the two types are the same.
bool compatible(const any& x) const {
return policy == x.policy;
}
};
}

459
utils/common/common.vpj Normal file → Executable file
View File

@ -1,232 +1,233 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdcommon.so" OutputFile="%bdcommon.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdcommon.so" OutputFile="%bdcommon.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="fixedallocator.cpp"/> <F N="fixedallocator.cpp"/>
<F N="MonitorProcMem.cpp"/> <F N="MonitorProcMem.cpp"/>
<F N="poolallocator.cpp"/> <F N="poolallocator.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="fixedallocator.h"/> <F N="any.hpp"/>
<F N="hasher.h"/> <F N="fixedallocator.h"/>
<F N="MonitorProcMem.h"/> <F N="hasher.h"/>
<F N="poolallocator.h"/> <F N="MonitorProcMem.h"/>
<F N="simpleallocator.h"/> <F N="poolallocator.h"/>
<F N="stlpoolallocator.h"/> <F N="simpleallocator.h"/>
<F N="syncstream.h"/> <F N="stlpoolallocator.h"/>
</Folder> <F N="syncstream.h"/>
<Folder </Folder>
Name="Resource Files" <Folder
Filters="*.ico;*.cur;*.dlg"/> Name="Resource Files"
<Folder Filters="*.ico;*.cur;*.dlg"/>
Name="Bitmaps" <Folder
Filters="*.bmp"/> Name="Bitmaps"
<Folder Filters="*.bmp"/>
Name="Other Files" <Folder
Filters=""> Name="Other Files"
<F Filters="">
N="Makefile" <F
Type="Makefile"/> N="Makefile"
</Folder> Type="Makefile"/>
</Files> </Folder>
</Files>
</Project> </Project>

View File

@ -34,7 +34,7 @@ namespace funcexp
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Return input argument type. // Return input argument type.
// See IDB_add in udfsdk.h for explanation of this function. // See mcs_add in udfsdk.h for explanation of this function.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
execplan::CalpontSystemCatalog::ColType Func_inet_aton::operationType( execplan::CalpontSystemCatalog::ColType Func_inet_aton::operationType(
FunctionParm& fp, FunctionParm& fp,

View File

@ -54,7 +54,7 @@ namespace funcexp
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Return input argument type. // Return input argument type.
// See IDB_add in udfsdk.h for explanation of this function. // See mcs_add in udfsdk.h for explanation of this function.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
execplan::CalpontSystemCatalog::ColType Func_inet_ntoa::operationType( execplan::CalpontSystemCatalog::ColType Func_inet_ntoa::operationType(
FunctionParm& fp, FunctionParm& fp,

12
utils/funcexp/func_lpad.cpp Normal file → Executable file
View File

@ -63,7 +63,7 @@ std::string Func_lpad::getStrVal(rowgroup::Row& row,
const string& tstr = fp[0]->data()->getStrVal(row, isNull); const string& tstr = fp[0]->data()->getStrVal(row, isNull);
// The result length in number of characters // The result length in number of characters
int len = 0; size_t len = 0;
switch (fp[1]->data()->resultType().colDataType) switch (fp[1]->data()->resultType().colDataType)
{ {
case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::BIGINT:
@ -129,16 +129,16 @@ std::string Func_lpad::getStrVal(rowgroup::Row& row,
// determine the size of buffer to allocate, we can be sure the wide // determine the size of buffer to allocate, we can be sure the wide
// char string won't be longer than // char string won't be longer than
strwclen = tstr.length(); // a guess to start with. This will be >= to the real count. strwclen = tstr.length(); // a guess to start with. This will be >= to the real count.
int alen = len; size_t alen = len;
if(strwclen > len) if(strwclen > len)
alen = strwclen; alen = strwclen;
int bufsize = (alen+1) * sizeof(wchar_t); size_t bufsize = (alen+1) * sizeof(wchar_t);
// Convert to wide characters. Do all further work in wide characters // Convert to wide characters. Do all further work in wide characters
wchar_t* wcbuf = (wchar_t*)alloca(bufsize); wchar_t* wcbuf = (wchar_t*)alloca(bufsize);
strwclen = utf8::idb_mbstowcs(wcbuf, tstr.c_str(), strwclen+1); strwclen = utf8::idb_mbstowcs(wcbuf, tstr.c_str(), strwclen+1);
unsigned int strSize = strwclen; // The number of significant characters size_t strSize = strwclen; // The number of significant characters
const wchar_t* pWChar = wcbuf; const wchar_t* pWChar = wcbuf;
for (i = 0; *pWChar != '\0' && i < strwclen; ++pWChar, ++i) for (i = 0; *pWChar != '\0' && i < strwclen; ++pWChar, ++i)
{ {
@ -165,13 +165,13 @@ std::string Func_lpad::getStrVal(rowgroup::Row& row,
// Convert the pad string to wide // Convert the pad string to wide
padwclen = pad.length(); // A guess to start. padwclen = pad.length(); // A guess to start.
int padbufsize = (padwclen+1) * sizeof(wchar_t); size_t padbufsize = (padwclen+1) * sizeof(wchar_t);
wchar_t* wcpad = (wchar_t*)alloca(padbufsize); wchar_t* wcpad = (wchar_t*)alloca(padbufsize);
// padwclen+1 is for giving count for the terminating null // padwclen+1 is for giving count for the terminating null
size_t padlen = utf8::idb_mbstowcs(wcpad, pad.c_str(), padwclen+1); size_t padlen = utf8::idb_mbstowcs(wcpad, pad.c_str(), padwclen+1);
// How many chars do we need? // How many chars do we need?
unsigned int padspace = len - strSize; size_t padspace = len - strSize;
// Shift the contents of wcbuf to the right. // Shift the contents of wcbuf to the right.
wchar_t* startofstr = wcbuf + padspace; wchar_t* startofstr = wcbuf + padspace;

2
utils/funcexp/func_rpad.cpp Normal file → Executable file
View File

@ -63,7 +63,7 @@ std::string Func_rpad::getStrVal(rowgroup::Row& row,
const string& tstr = fp[0]->data()->getStrVal(row, isNull); const string& tstr = fp[0]->data()->getStrVal(row, isNull);
// The result length in number of characters // The result length in number of characters
int len = 0; size_t len = 0;
switch (fp[1]->data()->resultType().colDataType) switch (fp[1]->data()->resultType().colDataType)
{ {
case execplan::CalpontSystemCatalog::BIGINT: case execplan::CalpontSystemCatalog::BIGINT:

658
utils/funcexp/funcexp.vpj Normal file → Executable file
View File

@ -1,332 +1,332 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdfuncexp.so" OutputFile="%bdfuncexp.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdfuncexp.so" OutputFile="%bdfuncexp.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw" RunFromDir="%rw"
ClearProcessBuffer="1"> ClearProcessBuffer="1">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="func_abs.cpp"/> <F N="func_abs.cpp"/>
<F N="func_add_time.cpp"/> <F N="func_add_time.cpp"/>
<F N="func_ascii.cpp"/> <F N="func_ascii.cpp"/>
<F N="func_between.cpp"/> <F N="func_between.cpp"/>
<F N="func_bitand.cpp"/> <F N="func_bitand.cpp"/>
<F N="func_bitwise.cpp"/> <F N="func_bitwise.cpp"/>
<F N="func_case.cpp"/> <F N="func_case.cpp"/>
<F N="func_cast.cpp"/> <F N="func_cast.cpp"/>
<F N="func_ceil.cpp"/> <F N="func_ceil.cpp"/>
<F N="func_char.cpp"/> <F N="func_char.cpp"/>
<F N="func_char_length.cpp"/> <F N="func_char_length.cpp"/>
<F N="func_coalesce.cpp"/> <F N="func_coalesce.cpp"/>
<F N="func_concat.cpp"/> <F N="func_concat.cpp"/>
<F N="func_concat_ws.cpp"/> <F N="func_concat_ws.cpp"/>
<F N="func_conv.cpp"/> <F N="func_conv.cpp"/>
<F N="func_crc32.cpp"/> <F N="func_crc32.cpp"/>
<F N="func_date.cpp"/> <F N="func_date.cpp"/>
<F N="func_date_add.cpp"/> <F N="func_date_add.cpp"/>
<F N="func_date_format.cpp"/> <F N="func_date_format.cpp"/>
<F N="func_day.cpp"/> <F N="func_day.cpp"/>
<F N="func_dayname.cpp"/> <F N="func_dayname.cpp"/>
<F N="func_dayofweek.cpp"/> <F N="func_dayofweek.cpp"/>
<F N="func_dayofyear.cpp"/> <F N="func_dayofyear.cpp"/>
<F N="func_div.cpp"/> <F N="func_div.cpp"/>
<F N="func_elt.cpp"/> <F N="func_elt.cpp"/>
<F N="func_exp.cpp"/> <F N="func_exp.cpp"/>
<F N="func_extract.cpp"/> <F N="func_extract.cpp"/>
<F N="func_find_in_set.cpp"/> <F N="func_find_in_set.cpp"/>
<F N="func_floor.cpp"/> <F N="func_floor.cpp"/>
<F N="func_from_days.cpp"/> <F N="func_from_days.cpp"/>
<F N="func_from_unixtime.cpp"/> <F N="func_from_unixtime.cpp"/>
<F N="func_get_format.cpp"/> <F N="func_get_format.cpp"/>
<F N="func_greatest.cpp"/> <F N="func_greatest.cpp"/>
<F N="func_hex.cpp"/> <F N="func_hex.cpp"/>
<F N="func_hour.cpp"/> <F N="func_hour.cpp"/>
<F N="func_if.cpp"/> <F N="func_if.cpp"/>
<F N="func_ifnull.cpp"/> <F N="func_ifnull.cpp"/>
<F N="func_in.cpp"/> <F N="func_in.cpp"/>
<F N="func_inet_aton.cpp"/> <F N="func_inet_aton.cpp"/>
<F N="func_inet_ntoa.cpp"/> <F N="func_inet_ntoa.cpp"/>
<F N="func_insert.cpp"/> <F N="func_insert.cpp"/>
<F N="func_instr.cpp"/> <F N="func_instr.cpp"/>
<F N="func_isnull.cpp"/> <F N="func_isnull.cpp"/>
<F N="func_last_day.cpp"/> <F N="func_last_day.cpp"/>
<F N="func_lcase.cpp"/> <F N="func_lcase.cpp"/>
<F N="func_least.cpp"/> <F N="func_least.cpp"/>
<F N="func_left.cpp"/> <F N="func_left.cpp"/>
<F N="func_length.cpp"/> <F N="func_length.cpp"/>
<F N="func_lpad.cpp"/> <F N="func_lpad.cpp"/>
<F N="func_ltrim.cpp"/> <F N="func_ltrim.cpp"/>
<F N="func_makedate.cpp"/> <F N="func_makedate.cpp"/>
<F N="func_maketime.cpp"/> <F N="func_maketime.cpp"/>
<F N="func_math.cpp"/> <F N="func_math.cpp"/>
<F N="func_md5.cpp"/> <F N="func_md5.cpp"/>
<F N="func_microsecond.cpp"/> <F N="func_microsecond.cpp"/>
<F N="func_minute.cpp"/> <F N="func_minute.cpp"/>
<F N="func_mod.cpp"/> <F N="func_mod.cpp"/>
<F N="func_month.cpp"/> <F N="func_month.cpp"/>
<F N="func_monthname.cpp"/> <F N="func_monthname.cpp"/>
<F N="func_nullif.cpp"/> <F N="func_nullif.cpp"/>
<F N="func_period_add.cpp"/> <F N="func_period_add.cpp"/>
<F N="func_period_diff.cpp"/> <F N="func_period_diff.cpp"/>
<F N="func_pow.cpp"/> <F N="func_pow.cpp"/>
<F N="func_quarter.cpp"/> <F N="func_quarter.cpp"/>
<F N="func_rand.cpp"/> <F N="func_rand.cpp"/>
<F N="func_regexp.cpp"/> <F N="func_regexp.cpp"/>
<F N="func_repeat.cpp"/> <F N="func_repeat.cpp"/>
<F N="func_replace.cpp"/> <F N="func_replace.cpp"/>
<F N="func_reverse.cpp"/> <F N="func_reverse.cpp"/>
<F N="func_right.cpp"/> <F N="func_right.cpp"/>
<F N="func_round.cpp"/> <F N="func_round.cpp"/>
<F N="func_rpad.cpp"/> <F N="func_rpad.cpp"/>
<F N="func_rtrim.cpp"/> <F N="func_rtrim.cpp"/>
<F N="func_sec_to_time.cpp"/> <F N="func_sec_to_time.cpp"/>
<F N="func_second.cpp"/> <F N="func_second.cpp"/>
<F N="func_sha.cpp"/> <F N="func_sha.cpp"/>
<F N="func_sign.cpp"/> <F N="func_sign.cpp"/>
<F N="func_str_to_date.cpp"/> <F N="func_str_to_date.cpp"/>
<F N="func_strcmp.cpp"/> <F N="func_strcmp.cpp"/>
<F N="func_substr.cpp"/> <F N="func_substr.cpp"/>
<F N="func_substring_index.cpp"/> <F N="func_substring_index.cpp"/>
<F N="func_sysdate.cpp"/> <F N="func_sysdate.cpp"/>
<F N="func_time.cpp"/> <F N="func_time.cpp"/>
<F N="func_time_format.cpp"/> <F N="func_time_format.cpp"/>
<F N="func_time_to_sec.cpp"/> <F N="func_time_to_sec.cpp"/>
<F N="func_timediff.cpp"/> <F N="func_timediff.cpp"/>
<F N="func_timestampdiff.cpp"/> <F N="func_timestampdiff.cpp"/>
<F N="func_to_days.cpp"/> <F N="func_to_days.cpp"/>
<F N="func_trim.cpp"/> <F N="func_trim.cpp"/>
<F N="func_truncate.cpp"/> <F N="func_truncate.cpp"/>
<F N="func_ucase.cpp"/> <F N="func_ucase.cpp"/>
<F N="func_unhex.cpp"/> <F N="func_unhex.cpp"/>
<F N="func_unix_timestamp.cpp"/> <F N="func_unix_timestamp.cpp"/>
<F N="func_week.cpp"/> <F N="func_week.cpp"/>
<F N="func_weekday.cpp"/> <F N="func_weekday.cpp"/>
<F N="func_year.cpp"/> <F N="func_year.cpp"/>
<F N="func_yearweek.cpp"/> <F N="func_yearweek.cpp"/>
<F N="funcexp.cpp"/> <F N="funcexp.cpp"/>
<F N="funcexpwrapper.cpp"/> <F N="funcexpwrapper.cpp"/>
<F N="functor.cpp"/> <F N="functor.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="funcexp.h"/> <F N="funcexp.h"/>
<F N="funcexpwrapper.h"/> <F N="funcexpwrapper.h"/>
<F N="funchelpers.h"/> <F N="funchelpers.h"/>
<F N="functor.h"/> <F N="functor.h"/>
<F N="functor_all.h"/> <F N="functor_all.h"/>
<F N="functor_bool.h"/> <F N="functor_bool.h"/>
<F N="functor_dtm.h"/> <F N="functor_dtm.h"/>
<F N="functor_export.h"/> <F N="functor_export.h"/>
<F N="functor_int.h"/> <F N="functor_int.h"/>
<F N="functor_real.h"/> <F N="functor_real.h"/>
<F N="functor_str.h"/> <F N="functor_str.h"/>
<F N="sha.h"/> <F N="sha.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

View File

@ -182,7 +182,7 @@ public:
Func_isnull():fIsNotNull(false) {} Func_isnull():fIsNotNull(false) {}
Func_isnull(bool isnotnull) : fIsNotNull(isnotnull) {} Func_isnull(bool isnotnull) : fIsNotNull(isnotnull) {}
/* /*
* Destructor. IDB_add does not need to do anything here to clean up. * Destructor. isnull does not need to do anything here to clean up.
*/ */
virtual ~Func_isnull() {} virtual ~Func_isnull() {}

9
utils/loggingcpp/ErrorMessage.txt Normal file → Executable file
View File

@ -148,6 +148,7 @@
5001 ERR_FUNC_NON_IMPLEMENT %1%:%2% is not implemented. 5001 ERR_FUNC_NON_IMPLEMENT %1%:%2% is not implemented.
5002 ERR_PSEUDOCOL_IDB_ONLY Pseudo column function '%1%' is only supported in Columnstore. 5002 ERR_PSEUDOCOL_IDB_ONLY Pseudo column function '%1%' is only supported in Columnstore.
5003 ERR_PSEUDOCOL_WRONG_ARG Argument of pseudo column function '%1%' is invalid. 5003 ERR_PSEUDOCOL_WRONG_ARG Argument of pseudo column function '%1%' is invalid.
5004 ERR_WINDOW_FUNC_ONLY User defined function %1% may only be used with the OVER clause.
# DBRM Errors # DBRM Errors
6001 ERR_NETWORK DBRM encountered a network error, check the controllernode. 6001 ERR_NETWORK DBRM encountered a network error, check the controllernode.
@ -195,4 +196,10 @@
9027 ERR_WF_ARG_OUT_OF_RANGE Argument '%1%' is out of range. 9027 ERR_WF_ARG_OUT_OF_RANGE Argument '%1%' is out of range.
9028 ERR_WF_NOT_ALLOWED Window functions are not allowed in %1%. 9028 ERR_WF_NOT_ALLOWED Window functions are not allowed in %1%.
9029 ERR_WF_IDB_ONLY Window function are only supported for Columnstore tables. 9029 ERR_WF_IDB_ONLY Window function are only supported for Columnstore tables.
9030 ERR_WF_DATA_SET_TOO_BIG Window function data set exceeds memory limit. 9030 ERR_WF_DATA_SET_TOO_BIG Window function data set exceeds memory limit.
9031 ERR_WF_UDANF_ERROR User Defined Window function: %1%.
9032 ERR_WF_UDANF_NOT_ALLOWED User Defined Function %1% used with an OVER clause.
9033 ERR_WF_UDANF_ORDER_REQUIRED User Defined Function %1% without an ORDER BY clause in the OVER clause.
9034 ERR_WF_UDANF_ORDER_NOT_ALLOWED User Defined Function %1% with an ORDER BY clause in the OVER clause.
9035 ERR_WF_UDANF_FRAME_REQUIRED User Defined Function %1% without a FRAME clause in the OVER clause.
9036 ERR_WF_UDANF_FRAME_NOT_ALLOWED User Defined Function %1% with a FRAME clause in the OVER clause.

470
utils/loggingcpp/loggingcpp.vpj Normal file → Executable file
View File

@ -1,238 +1,238 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdloggingcpp.so" OutputFile="%bdloggingcpp.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdloggingcpp.so" OutputFile="%bdloggingcpp.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="errorcodes.cpp"/> <F N="errorcodes.cpp"/>
<F N="idberrorinfo.cpp"/> <F N="idberrorinfo.cpp"/>
<F N="logger.cpp"/> <F N="logger.cpp"/>
<F N="message.cpp"/> <F N="message.cpp"/>
<F N="messagelog.cpp"/> <F N="messagelog.cpp"/>
<F N="sqllogger.cpp"/> <F N="sqllogger.cpp"/>
<F N="stopwatch.cpp"/> <F N="stopwatch.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="errorcodes.h"/> <F N="errorcodes.h"/>
<F N="errorids.h"/> <F N="errorids.h"/>
<F N="exceptclasses.h"/> <F N="exceptclasses.h"/>
<F N="idberrorinfo.h"/> <F N="idberrorinfo.h"/>
<F N="logger.h"/> <F N="logger.h"/>
<F N="loggingid.h"/> <F N="loggingid.h"/>
<F N="messageids.h"/> <F N="messageids.h"/>
<F N="messagelog.h"/> <F N="messagelog.h"/>
<F N="messageobj.h"/> <F N="messageobj.h"/>
<F N="sqllogger.h"/> <F N="sqllogger.h"/>
<F N="stopwatch.h"/> <F N="stopwatch.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F N="ErrorMessage.txt"/> <F N="ErrorMessage.txt"/>
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
<F N="MessageFile.txt"/> <F N="MessageFile.txt"/>
<F N="SubsystemIDs.txt"/> <F N="SubsystemIDs.txt"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

48
utils/messageqcpp/bytestream.cpp Normal file → Executable file
View File

@ -588,5 +588,53 @@ void ByteStream::peek(uuid& u) const
memcpy(&u.data[0], fCurOutPtr, uuids::uuid::static_size()); memcpy(&u.data[0], fCurOutPtr, uuids::uuid::static_size());
} }
ByteStream& ByteStream::operator<<(const float f)
{
int sz = sizeof(float);
if (fBuf == 0 || (fCurInPtr - fBuf + sz > fMaxLen + ISSOverhead))
growBuf(fMaxLen + BlockSize);
*((float *) fCurInPtr) = f;
fCurInPtr += sz;
return *this;
}
ByteStream& ByteStream::operator<<(const double d)
{
int sz = sizeof(double);
if (fBuf == 0 || (fCurInPtr - fBuf + sz > fMaxLen + ISSOverhead))
growBuf(fMaxLen + BlockSize);
*((double *) fCurInPtr) = d;
fCurInPtr += sz;
return *this;
}
ByteStream& ByteStream::operator>>(float& f)
{
peek(f);
fCurOutPtr += sizeof(float);
return *this;
}
ByteStream& ByteStream::operator>>(double& d)
{
peek(d);
fCurOutPtr += sizeof(double);
return *this;
}
void ByteStream::peek(float& f) const
{
if (length() < sizeof(float))
throw underflow_error("ByteStream>int64_t: not enough data in stream to fill datatype");
f = *((float *) fCurOutPtr);
}
void ByteStream::peek(double& d) const
{
if (length() < sizeof(double))
throw underflow_error("ByteStream>int64_t: not enough data in stream to fill datatype");
d = *((double *) fCurOutPtr);
}
}//namespace messageqcpp }//namespace messageqcpp

30
utils/messageqcpp/bytestream.h Normal file → Executable file
View File

@ -144,6 +144,16 @@ public:
* push an uint64_t onto the end of the stream. The byte order is whatever the native byte order is. * push an uint64_t onto the end of the stream. The byte order is whatever the native byte order is.
*/ */
EXPORT ByteStream& operator<<(const uint64_t o); EXPORT ByteStream& operator<<(const uint64_t o);
/**
* push an float onto the end of the stream. The byte order is
* whatever the native byte order is.
*/
EXPORT ByteStream& operator<<(const float f);
/**
* push an double onto the end of the stream. The byte order is
* whatever the native byte order is.
*/
EXPORT ByteStream& operator<<(const double d);
/** /**
* push a std::string onto the end of the stream. * push a std::string onto the end of the stream.
*/ */
@ -193,6 +203,16 @@ public:
* extract an uint64_t from the front of the stream. The byte order is whatever the native byte order is. * extract an uint64_t from the front of the stream. The byte order is whatever the native byte order is.
*/ */
EXPORT ByteStream& operator>>(uint64_t& o); EXPORT ByteStream& operator>>(uint64_t& o);
/**
* extract a float from the front of the stream. The byte
* order is whatever the native byte order is.
*/
EXPORT ByteStream& operator>>(float& f);
/**
* extract a double from the front of the stream. The byte
* order is whatever the native byte order is.
*/
EXPORT ByteStream& operator>>(double& d);
/** /**
* extract a std::string from the front of the stream. * extract a std::string from the front of the stream.
*/ */
@ -248,6 +268,16 @@ public:
* Peek at an uint64_t from the front of the stream. The byte order is whatever the native byte order is. * Peek at an uint64_t from the front of the stream. The byte order is whatever the native byte order is.
*/ */
EXPORT void peek(uint64_t& o) const; EXPORT void peek(uint64_t& o) const;
/**
* Peek at a float from the front of the stream. The byte order
* is whatever the native byte order is.
*/
EXPORT void peek(float& f) const;
/**
* Peek at a double from the front of the stream. The byte
* order is whatever the native byte order is.
*/
EXPORT void peek(double& f) const;
/** /**
* Peek at a std::string from the front of the stream. * Peek at a std::string from the front of the stream.
*/ */

462
utils/messageqcpp/messageqcpp.vpj Normal file → Executable file
View File

@ -1,234 +1,234 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdmessageqcpp.so" OutputFile="%bdmessageqcpp.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdmessageqcpp.so" OutputFile="%bdmessageqcpp.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="bytestream.cpp"/> <F N="bytestream.cpp"/>
<F N="compressed_iss.cpp"/> <F N="compressed_iss.cpp"/>
<F N="inetstreamsocket.cpp"/> <F N="inetstreamsocket.cpp"/>
<F N="iosocket.cpp"/> <F N="iosocket.cpp"/>
<F N="messagequeue.cpp"/> <F N="messagequeue.cpp"/>
<F N="socketparms.cpp"/> <F N="socketparms.cpp"/>
<F N="tdriver.cpp"/> <F N="tdriver.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="bytestream.h"/> <F N="bytestream.h"/>
<F N="clientsocket.h"/> <F N="clientsocket.h"/>
<F N="compressed_iss.h"/> <F N="compressed_iss.h"/>
<F N="inetstreamsocket.h"/> <F N="inetstreamsocket.h"/>
<F N="iosocket.h"/> <F N="iosocket.h"/>
<F N="messagequeue.h"/> <F N="messagequeue.h"/>
<F N="serializeable.h"/> <F N="serializeable.h"/>
<F N="serversocket.h"/> <F N="serversocket.h"/>
<F N="socket.h"/> <F N="socket.h"/>
<F N="socketclosed.h"/> <F N="socketclosed.h"/>
<F N="socketparms.h"/> <F N="socketparms.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

744
utils/rowgroup/rowaggregation.cpp Normal file → Executable file
View File

@ -28,7 +28,7 @@
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <limits> #include <limits>
#include <typeinfo>
#include "joblisttypes.h" #include "joblisttypes.h"
#include "resourcemanager.h" #include "resourcemanager.h"
#include "groupconcat.h" #include "groupconcat.h"
@ -459,7 +459,6 @@ inline void RowAggregation::updateFloatSum(float val1, float val2, int64_t col)
fRow.setFloatField(val1 + val2, col); fRow.setFloatField(val1 + val2, col);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Verify if the column value is NULL // Verify if the column value is NULL
// row(in) - Row to be included in aggregation. // row(in) - Row to be included in aggregation.
@ -721,6 +720,41 @@ void RowAggregation::setJoinRowGroups(vector<RowGroup> *pSmallSideRG, RowGroup *
(*fSmallSideRGs)[i].initRow(&rowSmalls[i]); (*fSmallSideRGs)[i].initRow(&rowSmalls[i]);
} }
//------------------------------------------------------------------------------
// For UDAF, we need to sometimes start a new context.
//
// This will be called any number of times by each of the batchprimitiveprocessor
// threads on the PM and by multple threads on the UM. It must remain
// thread safe.
//------------------------------------------------------------------------------
void RowAggregation::resetUDAF(uint64_t funcColID)
{
// Get the UDAF class pointer and store in the row definition object.
RowUDAFFunctionCol* rowUDAF = dynamic_cast<RowUDAFFunctionCol*>(fFunctionCols[funcColID].get());
// resetUDAF needs to be re-entrant. Since we're modifying the context object
// by creating a new userData, we need a local copy. The copy constructor
// doesn't copy userData.
mcsv1sdk::mcsv1Context rgContext(rowUDAF->fUDAFContext);
// Call the user reset for the group userData. Since, at this point,
// context's userData will be NULL, reset will generate a new one.
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
rc = rgContext.getFunction()->reset(&rgContext);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
rowUDAF->bInterrupted = true;
throw logging::QueryDataExcept(rgContext.getErrorMessage(), logging::aggregateFuncErr);
}
fRow.setUserDataStore(fRowGroupOut->getRGData()->getUserDataStore());
fRow.setUserData(rgContext,
rgContext.getUserDataSP(),
rgContext.getUserDataSize(),
rowUDAF->fAuxColumnIndex);
rgContext.setUserData(NULL); // Prevents calling deleteUserData on the context.
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Initilalize the data members to meaningful values, setup the hashmap. // Initilalize the data members to meaningful values, setup the hashmap.
@ -780,7 +814,7 @@ void RowAggregation::initialize()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Reset the working data to aggregate next logical block // Reset the working data to aggregate next logical block
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RowAggregation::reset() void RowAggregation::aggReset()
{ {
fTotalRowCount = 0; fTotalRowCount = 0;
fMaxTotalRowCount = AGG_ROWGROUP_SIZE; fMaxTotalRowCount = AGG_ROWGROUP_SIZE;
@ -798,15 +832,23 @@ void RowAggregation::reset()
delete fAggMapPtr; delete fAggMapPtr;
fAggMapPtr = new RowAggMap_t(10, *fHasher, *fEq, *fAlloc); fAggMapPtr = new RowAggMap_t(10, *fHasher, *fEq, *fAlloc);
} }
fResultDataVec.clear(); fResultDataVec.clear();
fResultDataVec.push_back(fRowGroupOut->getRGData()); fResultDataVec.push_back(fRowGroupOut->getRGData());
// For UDAF, reset the data
for (uint64_t i = 0; i < fFunctionCols.size(); i++)
{
if (fFunctionCols[i]->fAggFunction == ROWAGG_UDAF)
{
resetUDAF(i);
}
}
} }
void RowAggregationUM::reset() void RowAggregationUM::aggReset()
{ {
RowAggregation::reset(); RowAggregation::aggReset();
if (fKeyOnHeap) if (fKeyOnHeap)
{ {
@ -843,6 +885,15 @@ void RowAggregationUM::aggregateRowWithRemap(Row& row)
attachGroupConcatAg(); attachGroupConcatAg();
inserted.first->second = RowPosition(fResultDataVec.size()-1, fRowGroupOut->getRowCount()-1); inserted.first->second = RowPosition(fResultDataVec.size()-1, fRowGroupOut->getRowCount()-1);
// If there's UDAF involved, reset the user data.
for (uint64_t i = 0; i < fFunctionCols.size(); i++)
{
if (fFunctionCols[i]->fAggFunction == ROWAGG_UDAF)
{
resetUDAF(i);
}
}
// replace the key value with an equivalent copy, yes this is OK // replace the key value with an equivalent copy, yes this is OK
const_cast<RowPosition &>((inserted.first->first)) = pos; const_cast<RowPosition &>((inserted.first->first)) = pos;
} }
@ -893,6 +944,16 @@ void RowAggregation::aggregateRow(Row& row)
// replace the key value with an equivalent copy, yes this is OK // replace the key value with an equivalent copy, yes this is OK
const_cast<RowPosition &>(*(inserted.first)) = const_cast<RowPosition &>(*(inserted.first)) =
RowPosition(fResultDataVec.size() - 1, fRowGroupOut->getRowCount() - 1); RowPosition(fResultDataVec.size() - 1, fRowGroupOut->getRowCount() - 1);
// If there's UDAF involved, reset the user data.
for (uint64_t i = 0; i < fFunctionCols.size(); i++)
{
if (fFunctionCols[i]->fAggFunction == ROWAGG_UDAF)
{
resetUDAF(i);
}
}
} }
else { else {
//fRow.setData(*(inserted.first)); //fRow.setData(*(inserted.first));
@ -1065,6 +1126,8 @@ void RowAggregation::makeAggFieldsNull(Row& row)
case execplan::CalpontSystemCatalog::CHAR: case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR: case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::TEXT: case execplan::CalpontSystemCatalog::TEXT:
case execplan::CalpontSystemCatalog::VARBINARY:
case execplan::CalpontSystemCatalog::BLOB:
{ {
int colWidth = fRowGroupOut->getColumnWidth(colOut); int colWidth = fRowGroupOut->getColumnWidth(colOut);
if (colWidth <= 8) if (colWidth <= 8)
@ -1386,7 +1449,7 @@ void RowAggregation::serialize(messageqcpp::ByteStream& bs) const
bs << functionCount; bs << functionCount;
for (uint64_t i = 0; i < functionCount; i++) for (uint64_t i = 0; i < functionCount; i++)
bs << *(fFunctionCols[i].get()); fFunctionCols[i]->serialize(bs);
} }
@ -1415,9 +1478,18 @@ void RowAggregation::deserialize(messageqcpp::ByteStream& bs)
for (uint64_t i = 0; i < functionCount; i++) for (uint64_t i = 0; i < functionCount; i++)
{ {
SP_ROWAGG_FUNC_t funct( uint8_t funcType;
new RowAggFunctionCol(ROWAGG_FUNCT_UNDEFINE, ROWAGG_FUNCT_UNDEFINE, 0, 0)); bs.peek(funcType);
bs >> *(funct.get()); SP_ROWAGG_FUNC_t funct;
if (funcType == ROWAGG_UDAF)
{
funct.reset(new RowUDAFFunctionCol(0, 0));
}
else
{
funct.reset(new RowAggFunctionCol(ROWAGG_FUNCT_UNDEFINE, ROWAGG_FUNCT_UNDEFINE, 0, 0));
}
funct->deserialize(bs);
fFunctionCols.push_back(funct); fFunctionCols.push_back(funct);
} }
} }
@ -1477,6 +1549,20 @@ void RowAggregation::updateEntry(const Row& rowIn)
case ROWAGG_GROUP_CONCAT: case ROWAGG_GROUP_CONCAT:
break; break;
case ROWAGG_UDAF:
{
RowUDAFFunctionCol* rowUDAF = dynamic_cast<RowUDAFFunctionCol*>(fFunctionCols[i].get());
if (rowUDAF)
{
doUDAF(rowIn, colIn, colOut, colOut + 1, rowUDAF);
}
else
{
throw logic_error("(3)A UDAF function is called but there's no RowUDAFFunctionCol");
}
break;
}
default: default:
{ {
std::ostringstream errmsg; std::ostringstream errmsg;
@ -1729,6 +1815,113 @@ void RowAggregation::doStatistics(const Row& rowIn, int64_t colIn, int64_t colOu
fRow.setLongDoubleField(fRow.getLongDoubleField(colAux+1) + valIn*valIn, colAux+1); fRow.setLongDoubleField(fRow.getLongDoubleField(colAux+1) + valIn*valIn, colAux+1);
} }
void RowAggregation::doUDAF(const Row& rowIn, int64_t colIn, int64_t colOut, int64_t colAux,
RowUDAFFunctionCol* rowUDAF)
{
std::vector<mcsv1sdk::ColumnDatum> valsIn;
execplan::CalpontSystemCatalog::ColDataType colDataType = fRowGroupIn.getColTypes()[colIn];
std::vector<uint32_t> dataFlags;
// Get the context for this rowGroup. Make a copy so we're thread safe.
mcsv1sdk::mcsv1Context rgContext(rowUDAF->fUDAFContext);
// Turn on NULL flags
std::vector<uint32_t> flags;
uint32_t flag = 0;
if (isNull(&fRowGroupIn, rowIn, colIn) == true)
{
if (rgContext.getRunFlag(mcsv1sdk::UDAF_IGNORE_NULLS))
{
return;
}
flag |= mcsv1sdk::PARAM_IS_NULL;
}
flags.push_back(flag);
rgContext.setDataFlags(&flags);
mcsv1sdk::ColumnDatum datum;
switch (colDataType)
{
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::SMALLINT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
datum.dataType = execplan::CalpontSystemCatalog::BIGINT;
datum.columnData = rowIn.getIntField(colIn);
datum.scale = fRowGroupIn.getScale()[colIn];
datum.precision = fRowGroupIn.getPrecision()[colIn];
break;
}
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UBIGINT:
{
datum.dataType = execplan::CalpontSystemCatalog::UBIGINT;
datum.columnData = rowIn.getUintField(colIn);
break;
}
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
{
datum.dataType = execplan::CalpontSystemCatalog::DOUBLE;
datum.columnData = rowIn.getDoubleField(colIn);
break;
}
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
{
datum.dataType = execplan::CalpontSystemCatalog::FLOAT;
datum.columnData = rowIn.getFloatField(colIn);
break;
}
case execplan::CalpontSystemCatalog::DATE:
case execplan::CalpontSystemCatalog::DATETIME:
{
datum.dataType = execplan::CalpontSystemCatalog::UBIGINT;
datum.columnData = rowIn.getUintField(colIn);
break;
}
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::TEXT:
case execplan::CalpontSystemCatalog::VARBINARY:
case execplan::CalpontSystemCatalog::CLOB:
case execplan::CalpontSystemCatalog::BLOB:
{
datum.dataType = colDataType;
datum.columnData = rowIn.getStringField(colIn);
break;
}
default:
{
std::ostringstream errmsg;
errmsg << "RowAggregation " << rgContext.getName() <<
": No logic for data type: " << colDataType;
throw logging::QueryDataExcept(errmsg.str(), logging::aggregateFuncErr);
break;
}
}
valsIn.push_back(datum);
// The intermediate values are stored in userData referenced by colAux.
rgContext.setUserData(fRow.getUserData(colAux));
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
rc = rgContext.getFunction()->nextValue(&rgContext, valsIn);
rgContext.setUserData(NULL);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
rowUDAF->bInterrupted = true;
throw logging::QueryDataExcept(rgContext.getErrorMessage(), logging::aggregateFuncErr);
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Allocate a new data array for the output RowGroup // Allocate a new data array for the output RowGroup
@ -1781,7 +1974,6 @@ void RowAggregation::loadEmptySet(messageqcpp::ByteStream& bs)
fEmptyRowGroup.serializeRGData(bs); fEmptyRowGroup.serializeRGData(bs);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Row Aggregation constructor used on UM // Row Aggregation constructor used on UM
// For one-phase case, from projected RG to final aggregated RG // For one-phase case, from projected RG to final aggregated RG
@ -1790,10 +1982,11 @@ RowAggregationUM::RowAggregationUM(const vector<SP_ROWAGG_GRPBY_t>& rowAggGroupB
const vector<SP_ROWAGG_FUNC_t>& rowAggFunctionCols, const vector<SP_ROWAGG_FUNC_t>& rowAggFunctionCols,
joblist::ResourceManager *r, boost::shared_ptr<int64_t> sessionLimit) : joblist::ResourceManager *r, boost::shared_ptr<int64_t> sessionLimit) :
RowAggregation(rowAggGroupByCols, rowAggFunctionCols), fHasAvg(false), fKeyOnHeap(false), RowAggregation(rowAggGroupByCols, rowAggFunctionCols), fHasAvg(false), fKeyOnHeap(false),
fHasStatsFunc(false), fTotalMemUsage(0), fRm(r), fSessionMemLimit(sessionLimit), fHasStatsFunc(false), fHasUDAF(false),fTotalMemUsage(0), fRm(r),
fLastMemUsage(0), fNextRGIndex(0) fSessionMemLimit(sessionLimit), fLastMemUsage(0), fNextRGIndex(0)
{ {
// Check if there are any avg functions. // Check if there are any avg, stats or UDAF functions.
// These flags are used in finalize.
for (uint64_t i = 0; i < fFunctionCols.size(); i++) for (uint64_t i = 0; i < fFunctionCols.size(); i++)
{ {
if (fFunctionCols[i]->fAggFunction == ROWAGG_AVG || if (fFunctionCols[i]->fAggFunction == ROWAGG_AVG ||
@ -1801,6 +1994,8 @@ RowAggregationUM::RowAggregationUM(const vector<SP_ROWAGG_GRPBY_t>& rowAggGroupB
fHasAvg = true; fHasAvg = true;
else if (fFunctionCols[i]->fAggFunction == ROWAGG_STATS) else if (fFunctionCols[i]->fAggFunction == ROWAGG_STATS)
fHasStatsFunc = true; fHasStatsFunc = true;
else if (fFunctionCols[i]->fAggFunction == ROWAGG_UDAF)
fHasUDAF = true;
} }
// Check if all groupby column selected // Check if all groupby column selected
@ -1904,6 +2099,11 @@ void RowAggregationUM::finalize()
calculateStatisticsFunctions(); calculateStatisticsFunctions();
} }
if (fHasUDAF)
{
calculateUDAFColumns();
}
if (fGroupConcat.size() > 0) if (fGroupConcat.size() > 0)
setGroupConcatString(); setGroupConcatString();
@ -1950,6 +2150,7 @@ void RowAggregationUM::updateEntry(const Row& rowIn)
{ {
int64_t colIn = fFunctionCols[i]->fInputColumnIndex; int64_t colIn = fFunctionCols[i]->fInputColumnIndex;
int64_t colOut = fFunctionCols[i]->fOutputColumnIndex; int64_t colOut = fFunctionCols[i]->fOutputColumnIndex;
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
switch (fFunctionCols[i]->fAggFunction) switch (fFunctionCols[i]->fAggFunction)
{ {
@ -1971,14 +2172,12 @@ void RowAggregationUM::updateEntry(const Row& rowIn)
// The sum and count on UM may not be put next to each other: // The sum and count on UM may not be put next to each other:
// use colOut to store the sum; // use colOut to store the sum;
// use colAux to store the count. // use colAux to store the count.
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
doAvg(rowIn, colIn, colOut, colAux); doAvg(rowIn, colIn, colOut, colAux);
break; break;
} }
case ROWAGG_STATS: case ROWAGG_STATS:
{ {
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
doStatistics(rowIn, colIn, colOut, colAux); doStatistics(rowIn, colIn, colOut, colAux);
break; break;
} }
@ -2004,6 +2203,20 @@ void RowAggregationUM::updateEntry(const Row& rowIn)
case ROWAGG_CONSTANT: case ROWAGG_CONSTANT:
break; break;
case ROWAGG_UDAF:
{
RowUDAFFunctionCol* rowUDAF = dynamic_cast<RowUDAFFunctionCol*>(fFunctionCols[i].get());
if (rowUDAF)
{
doUDAF(rowIn, colIn, colOut, colAux, rowUDAF);
}
else
{
throw logic_error("(5)A UDAF function is called but there's no RowUDAFFunctionCol");
}
break;
}
default: default:
{ {
// need a exception to show the value // need a exception to show the value
@ -2143,6 +2356,251 @@ void RowAggregationUM::calculateAvgColumns()
} }
} }
// Sets the value from valOut into column colOut, performing any conversions.
void RowAggregationUM::SetUDAFValue(static_any::any& valOut, int64_t colOut)
{
static const static_any::any& charTypeId = (char)1;
static const static_any::any& scharTypeId = (signed char)1;
static const static_any::any& shortTypeId = (short)1;
static const static_any::any& intTypeId = (int)1;
static const static_any::any& longTypeId = (long)1;
static const static_any::any& llTypeId = (long long)1;
static const static_any::any& ucharTypeId = (unsigned char)1;
static const static_any::any& ushortTypeId = (unsigned short)1;
static const static_any::any& uintTypeId = (unsigned int)1;
static const static_any::any& ulongTypeId = (unsigned long)1;
static const static_any::any& ullTypeId = (unsigned long long)1;
static const static_any::any& floatTypeId = (float)1;
static const static_any::any& doubleTypeId = (double)1;
static const std::string typeStr("");
static const static_any::any& strTypeId = typeStr;
execplan::CalpontSystemCatalog::ColDataType colDataType = fRowGroupOut->getColTypes()[colOut];
if (valOut.empty())
{
// Fields are initialized to NULL, which is what we want for empty;
return;
}
// This may seem a bit convoluted. Users shouldn't return a type
// that they didn't set in mcsv1_UDAF::init(), but this
// handles whatever return type is given and casts
// it to whatever they said to return.
int64_t intOut = 0;
uint64_t uintOut = 0;
float floatOut = 0.0;
double doubleOut = 0.0;
ostringstream oss;
std::string strOut;
if (valOut.compatible(charTypeId))
{
uintOut = intOut = valOut.cast<char>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(scharTypeId))
{
uintOut = intOut = valOut.cast<signed char>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(shortTypeId))
{
uintOut = intOut = valOut.cast<short>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(intTypeId))
{
uintOut = intOut = valOut.cast<int>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(longTypeId))
{
uintOut = intOut = valOut.cast<long>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(llTypeId))
{
uintOut = intOut = valOut.cast<long long>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(ucharTypeId))
{
intOut = uintOut = valOut.cast<unsigned char>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(ushortTypeId))
{
intOut = uintOut = valOut.cast<unsigned short>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(uintTypeId))
{
intOut = uintOut = valOut.cast<unsigned int>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(ulongTypeId))
{
intOut = uintOut = valOut.cast<unsigned long>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(ullTypeId))
{
intOut = uintOut = valOut.cast<unsigned long long>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(floatTypeId))
{
floatOut = valOut.cast<float>();
doubleOut = floatOut;
intOut = uintOut = floatOut;
oss << floatOut;
}
else if (valOut.compatible(doubleTypeId))
{
doubleOut = valOut.cast<double>();
floatOut = (float)doubleOut;
uintOut = (uint64_t)doubleOut;
intOut = (int64_t)doubleOut;
oss << doubleOut;
}
if (valOut.compatible(strTypeId))
{
std::string strOut = valOut.cast<std::string>();
// Convert the string to numeric type, just in case.
intOut = atol(strOut.c_str());
uintOut = strtoul(strOut.c_str(), NULL, 10);
doubleOut = strtod(strOut.c_str(), NULL);
floatOut = (float)doubleOut;
}
else
{
strOut = oss.str();
}
switch (colDataType)
{
case execplan::CalpontSystemCatalog::BIT:
case execplan::CalpontSystemCatalog::TINYINT:
fRow.setIntField<1>(intOut, colOut);
break;
case execplan::CalpontSystemCatalog::SMALLINT:
case execplan::CalpontSystemCatalog::MEDINT:
fRow.setIntField<2>(intOut, colOut);
break;
case execplan::CalpontSystemCatalog::INT:
fRow.setIntField<4>(intOut, colOut);
break;
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
fRow.setIntField<8>(intOut, colOut);
break;
case execplan::CalpontSystemCatalog::UTINYINT:
fRow.setUintField<1>(uintOut, colOut);
break;
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::UMEDINT:
fRow.setUintField<2>(uintOut, colOut);
break;
case execplan::CalpontSystemCatalog::UINT:
fRow.setUintField<4>(uintOut, colOut);
break;
case execplan::CalpontSystemCatalog::UBIGINT:
fRow.setUintField<8>(uintOut, colOut);
break;
case execplan::CalpontSystemCatalog::DATE:
case execplan::CalpontSystemCatalog::DATETIME:
fRow.setUintField<8>(uintOut, colOut);
break;
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
fRow.setFloatField(floatOut, colOut);
break;
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
fRow.setDoubleField(doubleOut, colOut);
break;
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::TEXT:
fRow.setStringField(strOut, colOut);
break;
case execplan::CalpontSystemCatalog::VARBINARY:
case execplan::CalpontSystemCatalog::CLOB:
case execplan::CalpontSystemCatalog::BLOB:
fRow.setVarBinaryField(strOut, colOut);
break;
default:
{
std::ostringstream errmsg;
errmsg << "RowAggregation: No logic for data type: " << colDataType;
throw logging::QueryDataExcept(errmsg.str(), logging::aggregateFuncErr);
break;
}
}
}
//------------------------------------------------------------------------------
//
// For each rowgroup, calculate the final value.
//------------------------------------------------------------------------------
void RowAggregationUM::calculateUDAFColumns()
{
RowUDAFFunctionCol* rowUDAF = NULL;
static_any::any valOut;
for (uint64_t i = 0; i < fFunctionCols.size(); i++)
{
if (fFunctionCols[i]->fAggFunction != ROWAGG_UDAF)
continue;
rowUDAF = dynamic_cast<RowUDAFFunctionCol*>(fFunctionCols[i].get());
mcsv1sdk::mcsv1Context rgContext(rowUDAF->fUDAFContext);
int64_t colOut = rowUDAF->fOutputColumnIndex;
int64_t colAux = rowUDAF->fAuxColumnIndex;
// At this point, each row is an aggregated GROUP BY.
for (uint64_t j = 0; j < fRowGroupOut->getRowCount(); j++)
{
// Get the user data from the row and evaluate.
fRowGroupOut->getRow(j, &fRow);
// Turn the NULL flag off. We can't know NULL at this point
rgContext.setDataFlags(NULL);
// The intermediate values are stored in colAux.
rgContext.setUserData(fRow.getUserData(colAux));
// Call the UDAF evaluate function
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
rc = rgContext.getFunction()->evaluate(&rgContext, valOut);
rgContext.setUserData(NULL);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
rowUDAF->bInterrupted = true;
throw logging::QueryDataExcept(rgContext.getErrorMessage(), logging::aggregateFuncErr);
}
// Set the returned value into the output row
SetUDAFValue(valOut, colOut);
}
rgContext.setUserData(NULL);
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// After all PM rowgroups received, calculate the statistics. // After all PM rowgroups received, calculate the statistics.
@ -2222,7 +2680,6 @@ void RowAggregationUM::calculateStatisticsFunctions()
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Fix the duplicate function columns -- same function same column id repeated // Fix the duplicate function columns -- same function same column id repeated
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -2248,7 +2705,6 @@ void RowAggregationUM::fixDuplicates(RowAggFunctionType funct)
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Evaluate the functions and expressions // Evaluate the functions and expressions
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -2262,7 +2718,6 @@ void RowAggregationUM::evaluateExpression()
} }
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Calculate the aggregate(constant) columns // Calculate the aggregate(constant) columns
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -2395,6 +2850,58 @@ void RowAggregationUM::doNullConstantAggregate(const ConstantAggData& aggData, u
} }
break; break;
case ROWAGG_UDAF:
{
int64_t rowCnt = 0;
// For a NULL constant, call nextValue with NULL and then evaluate.
bool bInterrupted = false;
mcsv1sdk::mcsv1Context context;
context.setRowCnt(rowCnt);
context.setInterrupted(bInterrupted);
context.createUserData();
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
std::vector<mcsv1sdk::ColumnDatum> valsIn;
// Call a reset, then nextValue, then execute. This will evaluate
// the UDAF for the constant.
rc = context.getFunction()->reset(&context);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
context.setInterrupted(true);
throw logging::QueryDataExcept(context.getErrorMessage(), logging::aggregateFuncErr);
}
// Turn the NULL and CONSTANT flags on.
std::vector<uint32_t> flags;
uint32_t flag = mcsv1sdk::PARAM_IS_NULL | mcsv1sdk::PARAM_IS_CONSTANT;
flags.push_back(flag);
context.setDataFlags(&flags);
// Create a dummy datum
mcsv1sdk::ColumnDatum datum;
datum.dataType = execplan::CalpontSystemCatalog::BIGINT;
datum.columnData = 0;
valsIn.push_back(datum);
rc = context.getFunction()->nextValue(&context, valsIn);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
context.setInterrupted(true);
throw logging::QueryDataExcept(context.getErrorMessage(), logging::aggregateFuncErr);
}
static_any::any valOut;
rc = context.getFunction()->evaluate(&context, valOut);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
context.setInterrupted(true);
throw logging::QueryDataExcept(context.getErrorMessage(), logging::aggregateFuncErr);
}
// Set the returned value into the output row
SetUDAFValue(valOut, colOut);
context.setDataFlags(NULL);
}
break;
default: default:
{ {
fRow.setStringField("", colOut); fRow.setStringField("", colOut);
@ -2674,6 +3181,133 @@ void RowAggregationUM::doNotNullConstantAggregate(const ConstantAggData& aggData
} }
break; break;
case ROWAGG_UDAF:
{
int64_t rowCnt = 0;
bool bInterrupted = false;
mcsv1sdk::mcsv1Context context;
context.setRowCnt(rowCnt);
context.setInterrupted(bInterrupted);
// Try the complex data initiation. If not implemented, use the simple,
context.createUserData();
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
std::vector<mcsv1sdk::ColumnDatum> valsIn;
// Call a reset, then nextValue, then execute. This will evaluate
// the UDAF for the constant.
rc = context.getFunction()->reset(&context);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
context.setInterrupted(true);
throw logging::QueryDataExcept(context.getErrorMessage(), logging::aggregateFuncErr);
}
// Turn the CONSTANT flags on.
std::vector<uint32_t> flags;
uint32_t flag = mcsv1sdk::PARAM_IS_CONSTANT;
flags.push_back(flag);
context.setDataFlags(&flags);
// Create a datum item for sending to UDAF
mcsv1sdk::ColumnDatum datum;
datum.dataType = (CalpontSystemCatalog::ColDataType)colDataType;
switch (colDataType)
{
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::SMALLINT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::BIGINT:
{
datum.columnData = strtol(aggData.fConstValue.c_str(), 0, 10);
}
break;
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UBIGINT:
{
datum.columnData = strtoul(aggData.fConstValue.c_str(), 0, 10);
}
break;
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
{
double dbl = strtod(aggData.fConstValue.c_str(), 0);
double scale = pow(10.0, (double) fRowGroupOut->getScale()[i]);
datum.columnData = (int64_t)(scale*dbl);
datum.scale = scale;
datum.precision = fRowGroupOut->getPrecision()[i];
}
break;
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
{
datum.columnData = strtod(aggData.fConstValue.c_str(), 0);
}
break;
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
{
#ifdef _MSC_VER
datum.columnData = strtod(aggData.fConstValue.c_str(), 0);
#else
datum.columnData = strtof(aggData.fConstValue.c_str(), 0);
#endif
}
break;
case execplan::CalpontSystemCatalog::DATE:
{
datum.columnData = DataConvert::stringToDate(aggData.fConstValue);
}
break;
case execplan::CalpontSystemCatalog::DATETIME:
{
datum.columnData = DataConvert::stringToDatetime(aggData.fConstValue);
}
break;
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::TEXT:
case execplan::CalpontSystemCatalog::VARBINARY:
case execplan::CalpontSystemCatalog::BLOB:
default:
{
datum.columnData = aggData.fConstValue;
}
break;
}
valsIn.push_back(datum);
rc = context.getFunction()->nextValue(&context, valsIn);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
context.setInterrupted(true);
throw logging::QueryDataExcept(context.getErrorMessage(), logging::aggregateFuncErr);
}
static_any::any valOut;
rc = context.getFunction()->evaluate(&context, valOut);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
context.setInterrupted(true);
throw logging::QueryDataExcept(context.getErrorMessage(), logging::aggregateFuncErr);
}
// Set the returned value into the output row
SetUDAFValue(valOut, colOut);
context.setDataFlags(NULL);
}
break;
default: default:
{ {
fRow.setStringField(aggData.fConstValue, colOut); fRow.setStringField(aggData.fConstValue, colOut);
@ -2823,6 +3457,7 @@ void RowAggregationUMP2::updateEntry(const Row& rowIn)
{ {
int64_t colIn = fFunctionCols[i]->fInputColumnIndex; int64_t colIn = fFunctionCols[i]->fInputColumnIndex;
int64_t colOut = fFunctionCols[i]->fOutputColumnIndex; int64_t colOut = fFunctionCols[i]->fOutputColumnIndex;
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
switch (fFunctionCols[i]->fAggFunction) switch (fFunctionCols[i]->fAggFunction)
{ {
@ -2845,14 +3480,12 @@ void RowAggregationUMP2::updateEntry(const Row& rowIn)
// The sum and count on UM may not be put next to each other: // The sum and count on UM may not be put next to each other:
// use colOut to store the sum; // use colOut to store the sum;
// use colAux to store the count. // use colAux to store the count.
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
doAvg(rowIn, colIn, colOut, colAux); doAvg(rowIn, colIn, colOut, colAux);
break; break;
} }
case ROWAGG_STATS: case ROWAGG_STATS:
{ {
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
doStatistics(rowIn, colIn, colOut, colAux); doStatistics(rowIn, colIn, colOut, colAux);
break; break;
} }
@ -2878,6 +3511,20 @@ void RowAggregationUMP2::updateEntry(const Row& rowIn)
case ROWAGG_CONSTANT: case ROWAGG_CONSTANT:
break; break;
case ROWAGG_UDAF:
{
RowUDAFFunctionCol* rowUDAF = dynamic_cast<RowUDAFFunctionCol*>(fFunctionCols[i].get());
if (rowUDAF)
{
doUDAF(rowIn, colIn, colOut, colAux, rowUDAF);
}
else
{
throw logic_error("(6)A UDAF function is called but there's no RowUDAFFunctionCol");
}
break;
}
default: default:
{ {
std::ostringstream errmsg; std::ostringstream errmsg;
@ -3050,6 +3697,43 @@ void RowAggregationUMP2::doBitOp(const Row& rowIn, int64_t colIn, int64_t colOut
fRow.setUintField(valIn ^ valOut, colOut); fRow.setUintField(valIn ^ valOut, colOut);
} }
//------------------------------------------------------------------------------
// Subaggregate the UDAF. This calls subaggregate for each partially
// aggregated row returned by the PM
// rowIn(in) - Row to be included in aggregation.
// colIn(in) - column in the input row group
// colOut(in) - column in the output row group
// colAux(in) - Where the UDAF userdata resides
// rowUDAF(in) - pointer to the RowUDAFFunctionCol for this UDAF instance
//------------------------------------------------------------------------------
void RowAggregationUMP2::doUDAF(const Row& rowIn, int64_t colIn, int64_t colOut, int64_t colAux,
RowUDAFFunctionCol* rowUDAF)
{
static_any::any valOut;
mcsv1sdk::mcsv1Context rgContext(rowUDAF->fUDAFContext);
// Turn on NULL flags
std::vector<uint32_t> flags;
uint32_t flag = 0;
if (isNull(&fRowGroupIn, rowIn, colIn) == true)
flag |= mcsv1sdk::PARAM_IS_NULL;
flags.push_back(flag);
rgContext.setDataFlags(&flags);
// The intermediate values are stored in colAux.
rgContext.setUserData(fRow.getUserData(colAux));
// Call the UDAF subEvaluate method
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
rc = rgContext.getFunction()->subEvaluate(&rgContext, rowIn.getUserData(colIn+1).get());
rgContext.setUserData(NULL);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
rowUDAF->bInterrupted = true;
throw logging::QueryDataExcept(rgContext.getErrorMessage(), logging::aggregateFuncErr);
}
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -3163,6 +3847,7 @@ void RowAggregationDistinct::updateEntry(const Row& rowIn)
{ {
int64_t colIn = fFunctionCols[i]->fInputColumnIndex; int64_t colIn = fFunctionCols[i]->fInputColumnIndex;
int64_t colOut = fFunctionCols[i]->fOutputColumnIndex; int64_t colOut = fFunctionCols[i]->fOutputColumnIndex;
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
switch (fFunctionCols[i]->fAggFunction) switch (fFunctionCols[i]->fAggFunction)
{ {
@ -3192,7 +3877,6 @@ void RowAggregationDistinct::updateEntry(const Row& rowIn)
// The sum and count on UM may not be put next to each other: // The sum and count on UM may not be put next to each other:
// use colOut to store the sum; // use colOut to store the sum;
// use colAux to store the count. // use colAux to store the count.
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
doAvg(rowIn, colIn, colOut, colAux); doAvg(rowIn, colIn, colOut, colAux);
break; break;
} }
@ -3202,14 +3886,12 @@ void RowAggregationDistinct::updateEntry(const Row& rowIn)
// The sum and count on UM may not be put next to each other: // The sum and count on UM may not be put next to each other:
// use colOut to store the sum; // use colOut to store the sum;
// use colAux to store the count. // use colAux to store the count.
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
RowAggregation::doAvg(rowIn, colIn, colOut, colAux); RowAggregation::doAvg(rowIn, colIn, colOut, colAux);
break; break;
} }
case ROWAGG_STATS: case ROWAGG_STATS:
{ {
int64_t colAux = fFunctionCols[i]->fAuxColumnIndex;
doStatistics(rowIn, colIn, colOut, colAux); doStatistics(rowIn, colIn, colOut, colAux);
break; break;
} }
@ -3235,6 +3917,20 @@ void RowAggregationDistinct::updateEntry(const Row& rowIn)
case ROWAGG_CONSTANT: case ROWAGG_CONSTANT:
break; break;
case ROWAGG_UDAF:
{
RowUDAFFunctionCol* rowUDAF = dynamic_cast<RowUDAFFunctionCol*>(fFunctionCols[i].get());
if (rowUDAF)
{
doUDAF(rowIn, colIn, colOut, colAux, rowUDAF);
}
else
{
throw logic_error("(7)A UDAF function is called but there's no RowUDAFFunctionCol");
}
break;
}
default: default:
{ {
std::ostringstream errmsg; std::ostringstream errmsg;

104
utils/rowgroup/rowaggregation.h Normal file → Executable file
View File

@ -49,6 +49,7 @@
#include "hasher.h" #include "hasher.h"
#include "stlpoolallocator.h" #include "stlpoolallocator.h"
#include "returnedcolumn.h" #include "returnedcolumn.h"
#include "mcsv1_udaf.h"
// To do: move code that depends on joblist to a proper subsystem. // To do: move code that depends on joblist to a proper subsystem.
namespace joblist namespace joblist
@ -64,6 +65,7 @@ struct RowPosition
{ {
uint64_t group:48; uint64_t group:48;
uint64_t row:16; uint64_t row:16;
static const uint64_t MSB = 0x800000000000ULL; //48th bit is set static const uint64_t MSB = 0x800000000000ULL; //48th bit is set
inline RowPosition(uint64_t g, uint64_t r) : group(g), row(r) { } inline RowPosition(uint64_t g, uint64_t r) : group(g), row(r) { }
inline RowPosition() { } inline RowPosition() { }
@ -105,6 +107,9 @@ enum RowAggFunctionType
// Constant // Constant
ROWAGG_CONSTANT, ROWAGG_CONSTANT,
// User Defined Aggregate Function
ROWAGG_UDAF,
// internal function type to avoid duplicate the work // internal function type to avoid duplicate the work
// handling ROWAGG_COUNT_NO_OP, ROWAGG_DUP_FUNCT and ROWAGG_DUP_AVG is a little different // handling ROWAGG_COUNT_NO_OP, ROWAGG_DUP_FUNCT and ROWAGG_DUP_AVG is a little different
// ROWAGG_COUNT_NO_OP : count done by AVG, no need to copy // ROWAGG_COUNT_NO_OP : count done by AVG, no need to copy
@ -169,7 +174,10 @@ struct RowAggFunctionCol
int32_t inputColIndex, int32_t outputColIndex, int32_t auxColIndex = -1) : int32_t inputColIndex, int32_t outputColIndex, int32_t auxColIndex = -1) :
fAggFunction(aggFunction), fStatsFunction(stats), fInputColumnIndex(inputColIndex), fAggFunction(aggFunction), fStatsFunction(stats), fInputColumnIndex(inputColIndex),
fOutputColumnIndex(outputColIndex), fAuxColumnIndex(auxColIndex) {} fOutputColumnIndex(outputColIndex), fAuxColumnIndex(auxColIndex) {}
~RowAggFunctionCol() {} virtual ~RowAggFunctionCol() {}
virtual void serialize(messageqcpp::ByteStream& bs) const;
virtual void deserialize(messageqcpp::ByteStream& bs);
RowAggFunctionType fAggFunction; // aggregate function RowAggFunctionType fAggFunction; // aggregate function
// statistics function stores ROWAGG_STATS in fAggFunction and real function in fStatsFunction // statistics function stores ROWAGG_STATS in fAggFunction and real function in fStatsFunction
@ -178,24 +186,86 @@ struct RowAggFunctionCol
uint32_t fInputColumnIndex; uint32_t fInputColumnIndex;
uint32_t fOutputColumnIndex; uint32_t fOutputColumnIndex;
// fAuxColumnIndex is used in 3 cases: // fAuxColumnIndex is used in 4 cases:
// 1. for AVG - point to the count column, the fInputColumnIndex is for sum // 1. for AVG - point to the count column, the fInputColumnIndex is for sum
// 2. for statistics function - point to sum(x), +1 is sum(x**2) // 2. for statistics function - point to sum(x), +1 is sum(x**2)
// 3. for duplicate - point to the real aggretate column to be copied from // 3. for UDAF - contain the context user data as binary
// 4. for duplicate - point to the real aggretate column to be copied from
// Set only on UM, the fAuxColumnIndex is defaulted to fOutputColumnIndex+1 on PM. // Set only on UM, the fAuxColumnIndex is defaulted to fOutputColumnIndex+1 on PM.
uint32_t fAuxColumnIndex; uint32_t fAuxColumnIndex;
}; };
inline messageqcpp::ByteStream& operator<<(messageqcpp::ByteStream& b, RowAggFunctionCol& o)
{ return (b << (uint8_t)o.fAggFunction << o.fInputColumnIndex << o.fOutputColumnIndex); }
inline messageqcpp::ByteStream& operator>>(messageqcpp::ByteStream& b, RowAggFunctionCol& o)
{ return (b >> (uint8_t&)o.fAggFunction >> o.fInputColumnIndex >> o.fOutputColumnIndex); }
struct RowUDAFFunctionCol : public RowAggFunctionCol
{
RowUDAFFunctionCol(mcsv1sdk::mcsv1Context& context, int32_t inputColIndex,
int32_t outputColIndex, int32_t auxColIndex = -1) :
RowAggFunctionCol(ROWAGG_UDAF, ROWAGG_FUNCT_UNDEFINE,
inputColIndex, outputColIndex, auxColIndex),
fUDAFContext(context), bInterrupted(false)
{
fUDAFContext.setInterrupted(&bInterrupted);
}
RowUDAFFunctionCol(int32_t inputColIndex,
int32_t outputColIndex, int32_t auxColIndex = -1) :
RowAggFunctionCol(ROWAGG_UDAF, ROWAGG_FUNCT_UNDEFINE,
inputColIndex, outputColIndex, auxColIndex),
bInterrupted(false)
{}
RowUDAFFunctionCol(const RowUDAFFunctionCol& rhs) : RowAggFunctionCol(ROWAGG_UDAF, ROWAGG_FUNCT_UNDEFINE,
rhs.fInputColumnIndex, rhs.fOutputColumnIndex, rhs.fAuxColumnIndex), fUDAFContext(rhs.fUDAFContext)
{}
virtual ~RowUDAFFunctionCol() {}
virtual void serialize(messageqcpp::ByteStream& bs) const;
virtual void deserialize(messageqcpp::ByteStream& bs);
mcsv1sdk::mcsv1Context fUDAFContext; // The UDAF context
bool bInterrupted; // Shared by all the threads
};
inline void RowAggFunctionCol::serialize(messageqcpp::ByteStream& bs) const
{
bs << (uint8_t)fAggFunction;
bs << fInputColumnIndex;
bs << fOutputColumnIndex;
}
inline void RowAggFunctionCol::deserialize(messageqcpp::ByteStream& bs)
{
bs >> (uint8_t&)fAggFunction;
bs >> fInputColumnIndex;
bs >> fOutputColumnIndex;
}
inline void RowUDAFFunctionCol::serialize(messageqcpp::ByteStream& bs) const
{
RowAggFunctionCol::serialize(bs);
fUDAFContext.serialize(bs);
}
inline void RowUDAFFunctionCol::deserialize(messageqcpp::ByteStream& bs)
{
// This deserialize is called when the function gets to PrimProc.
// reset is called because we're starting a new sub-evaluate cycle.
RowAggFunctionCol::deserialize(bs);
fUDAFContext.unserialize(bs);
fUDAFContext.setInterrupted(&bInterrupted);
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
rc = fUDAFContext.getFunction()->reset(&fUDAFContext);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
bInterrupted = true;
throw logging::QueryDataExcept(fUDAFContext.getErrorMessage(), logging::aggregateFuncErr);
}
}
struct ConstantAggData struct ConstantAggData
{ {
std::string fConstValue; std::string fConstValue;
std::string fUDAFName; // If a UDAF is called with constant.
RowAggFunctionType fOp; RowAggFunctionType fOp;
bool fIsNull; bool fIsNull;
@ -205,6 +275,10 @@ struct ConstantAggData
ConstantAggData(const std::string& v, RowAggFunctionType f, bool n) : ConstantAggData(const std::string& v, RowAggFunctionType f, bool n) :
fConstValue(v), fOp(f), fIsNull(n) fConstValue(v), fOp(f), fIsNull(n)
{} {}
ConstantAggData(const std::string& v, const std::string u, RowAggFunctionType f, bool n) :
fConstValue(v), fUDAFName(u), fOp(f), fIsNull(n)
{}
}; };
typedef boost::shared_ptr<RowAggGroupByCol> SP_ROWAGG_GRPBY_t; typedef boost::shared_ptr<RowAggGroupByCol> SP_ROWAGG_GRPBY_t;
@ -377,7 +451,7 @@ class RowAggregation : public messageqcpp::Serializeable
/** @brief reset RowAggregation outputRowGroup and hashMap /** @brief reset RowAggregation outputRowGroup and hashMap
*/ */
virtual void reset(); virtual void aggReset();
/** @brief Define content of data to be aggregated and its aggregated output. /** @brief Define content of data to be aggregated and its aggregated output.
* *
@ -470,12 +544,15 @@ class RowAggregation : public messageqcpp::Serializeable
virtual void doAvg(const Row&, int64_t, int64_t, int64_t); virtual void doAvg(const Row&, int64_t, int64_t, int64_t);
virtual void doStatistics(const Row&, int64_t, int64_t, int64_t); virtual void doStatistics(const Row&, int64_t, int64_t, int64_t);
virtual void doBitOp(const Row&, int64_t, int64_t, int); virtual void doBitOp(const Row&, int64_t, int64_t, int);
virtual void doUDAF(const Row&, int64_t, int64_t, int64_t, RowUDAFFunctionCol* rowUDAF);
virtual bool countSpecial(const RowGroup* pRG) virtual bool countSpecial(const RowGroup* pRG)
{ fRow.setIntField<8>(fRow.getIntField<8>(0) + pRG->getRowCount(), 0); return true; } { fRow.setIntField<8>(fRow.getIntField<8>(0) + pRG->getRowCount(), 0); return true; }
virtual bool newRowGroup(); virtual bool newRowGroup();
virtual void clearAggMap() { if (fAggMapPtr) fAggMapPtr->clear(); } virtual void clearAggMap() { if (fAggMapPtr) fAggMapPtr->clear(); }
void resetUDAF(uint64_t funcColID);
inline bool isNull(const RowGroup* pRowGroup, const Row& row, int64_t col); inline bool isNull(const RowGroup* pRowGroup, const Row& row, int64_t col);
inline void makeAggFieldsNull(Row& row); inline void makeAggFieldsNull(Row& row);
inline void copyNullRow(Row& row) { copyRow(fNullRow, &row); } inline void copyNullRow(Row& row) { copyRow(fNullRow, &row); }
@ -537,7 +614,6 @@ class RowAggregation : public messageqcpp::Serializeable
friend class AggComparator; friend class AggComparator;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** @brief derived Class that aggregates multi-rowgroups on UM /** @brief derived Class that aggregates multi-rowgroups on UM
* One-phase case: aggregate from projected RG to final aggregated RG. * One-phase case: aggregate from projected RG to final aggregated RG.
@ -602,7 +678,7 @@ class RowAggregationUM : public RowAggregation
void aggregateRow(Row &); void aggregateRow(Row &);
//void initialize(); //void initialize();
virtual void reset(); virtual void aggReset();
void setInputOutput(const RowGroup& pRowGroupIn, RowGroup* pRowGroupOut); void setInputOutput(const RowGroup& pRowGroupIn, RowGroup* pRowGroupOut);
@ -628,6 +704,12 @@ class RowAggregationUM : public RowAggregation
// calculate the statistics function all rows received. UM only function. // calculate the statistics function all rows received. UM only function.
void calculateStatisticsFunctions(); void calculateStatisticsFunctions();
// Sets the value from valOut into column colOut, performing any conversions.
void SetUDAFValue(static_any::any& valOut, int64_t colOut);
// calculate the UDAF function all rows received. UM only function.
void calculateUDAFColumns();
// fix duplicates. UM only function. // fix duplicates. UM only function.
void fixDuplicates(RowAggFunctionType funct); void fixDuplicates(RowAggFunctionType funct);
@ -646,6 +728,7 @@ class RowAggregationUM : public RowAggregation
bool fHasAvg; bool fHasAvg;
bool fKeyOnHeap; bool fKeyOnHeap;
bool fHasStatsFunc; bool fHasStatsFunc;
bool fHasUDAF;
boost::shared_ptr<RowAggregation> fDistinctAggregator; boost::shared_ptr<RowAggregation> fDistinctAggregator;
@ -715,6 +798,7 @@ class RowAggregationUMP2 : public RowAggregationUM
void doStatistics(const Row&, int64_t, int64_t, int64_t); void doStatistics(const Row&, int64_t, int64_t, int64_t);
void doGroupConcat(const Row&, int64_t, int64_t); void doGroupConcat(const Row&, int64_t, int64_t);
void doBitOp(const Row&, int64_t, int64_t, int); void doBitOp(const Row&, int64_t, int64_t, int);
void doUDAF(const Row&, int64_t, int64_t, int64_t, RowUDAFFunctionCol* rowUDAF);
bool countSpecial(const RowGroup* pRG) { return false; } bool countSpecial(const RowGroup* pRG) { return false; }
}; };

175
utils/rowgroup/rowgroup.cpp Normal file → Executable file
View File

@ -38,7 +38,6 @@
using namespace std; using namespace std;
#include <boost/shared_array.hpp> #include <boost/shared_array.hpp>
#include <boost/shared_ptr.hpp>
using namespace boost; using namespace boost;
#include "bytestream.h" #include "bytestream.h"
@ -113,7 +112,6 @@ uint32_t StringStore::storeString(const uint8_t *data, uint32_t len)
void StringStore::serialize(ByteStream &bs) const void StringStore::serialize(ByteStream &bs) const
{ {
uint32_t i; uint32_t i;
std::string empty_str;
bs << (uint32_t) mem.size(); bs << (uint32_t) mem.size();
bs << (uint8_t) empty; bs << (uint8_t) empty;
@ -126,30 +124,25 @@ void StringStore::serialize(ByteStream &bs) const
} }
} }
uint32_t StringStore::deserialize(ByteStream &bs) void StringStore::deserialize(ByteStream &bs)
{ {
uint32_t i; uint32_t i;
uint32_t count; uint32_t count;
uint32_t size;
std::string buf; std::string buf;
uint8_t tmp8; uint8_t tmp8;
uint32_t ret = 0;
//mem.clear(); //mem.clear();
bs >> count; bs >> count;
mem.reserve(count); mem.reserve(count);
bs >> tmp8; bs >> tmp8;
empty = (bool) tmp8; empty = (bool) tmp8;
ret += 5;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
//cout << "deserializing " << size << " bytes\n"; //cout << "deserializing " << size << " bytes\n";
bs >> buf; bs >> buf;
shared_ptr<std::string> newString(new std::string(buf.c_str())); shared_ptr<std::string> newString(new std::string(buf.c_str()));
mem.push_back(newString); mem.push_back(newString);
//bs.advance(size);
ret += (size + 4);
} }
return ret; return;
} }
void StringStore::clear() void StringStore::clear()
@ -159,6 +152,106 @@ void StringStore::clear()
empty = true; empty = true;
} }
UserDataStore::UserDataStore() : fUseUserDataMutex(false)
{
}
UserDataStore::~UserDataStore()
{
}
uint32_t UserDataStore::storeUserData(mcsv1sdk::mcsv1Context& context,
boost::shared_ptr<mcsv1sdk::UserData> data,
uint32_t len)
{
uint32_t ret = 0;
if (len == 0 || data == NULL)
{
return numeric_limits<uint32_t>::max();
}
boost::mutex::scoped_lock lk(fMutex, defer_lock);
if (fUseUserDataMutex)
lk.lock();
StoreData storeData;
storeData.length = len;
storeData.functionName = context.getName();
storeData.userData = data;
vStoreData.push_back(storeData);
ret = vStoreData.size();
return ret;
}
boost::shared_ptr<mcsv1sdk::UserData> UserDataStore::getUserData(uint32_t off) const
{
if (off == std::numeric_limits<uint32_t>::max())
return boost::shared_ptr<mcsv1sdk::UserData>();
if ((vStoreData.size() < off) || off == 0)
return boost::shared_ptr<mcsv1sdk::UserData>();
return vStoreData[off-1].userData;
}
void UserDataStore::serialize(ByteStream &bs) const
{
size_t i;
bs << (uint32_t) vStoreData.size();
for (i = 0; i < vStoreData.size(); ++i)
{
const StoreData& storeData = vStoreData[i];
bs << storeData.length;
bs << storeData.functionName;
storeData.userData->serialize(bs);
}
}
void UserDataStore::deserialize(ByteStream &bs)
{
size_t i;
uint32_t cnt;
bs >> cnt;
// vStoreData.clear();
vStoreData.resize(cnt);
for (i = 0; i < cnt; i++)
{
bs >> vStoreData[i].length;
bs >> vStoreData[i].functionName;
// We don't have easy access to the context here, so we do our own lookup
if (vStoreData[i].functionName.length() == 0)
{
throw std::logic_error("UserDataStore::deserialize: has empty name");
}
mcsv1sdk::UDAF_MAP::iterator funcIter = mcsv1sdk::UDAFMap::getMap().find(vStoreData[i].functionName);
if (funcIter == mcsv1sdk::UDAFMap::getMap().end())
{
std::ostringstream errmsg;
errmsg << "UserDataStore::deserialize: " << vStoreData[i].functionName << " is undefined";
throw std::logic_error(errmsg.str());
}
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
mcsv1sdk::UserData* userData = NULL;
rc = funcIter->second->createUserData(userData, vStoreData[i].length);
if (rc != mcsv1sdk::mcsv1_UDAF::SUCCESS)
{
std::ostringstream errmsg;
errmsg << "UserDataStore::deserialize: " << vStoreData[i].functionName << " createUserData failed(" << rc << ")";
throw std::logic_error(errmsg.str());
}
userData->unserialize(bs);
vStoreData[i].userData = boost::shared_ptr<mcsv1sdk::UserData>(userData);
}
return;
}
//uint32_t rgDataCount = 0; //uint32_t rgDataCount = 0;
RGData::RGData() RGData::RGData()
@ -222,7 +315,7 @@ void RGData::reinit(const RowGroup &rg)
reinit(rg, 8192); reinit(rg, 8192);
} }
RGData::RGData(const RGData &r) : rowData(r.rowData), strings(r.strings) RGData::RGData(const RGData &r) : rowData(r.rowData), strings(r.strings), userDataStore(r.userDataStore)
{ {
//cout << "rgdata++ = " << __sync_add_and_fetch(&rgDataCount, 1) << endl; //cout << "rgdata++ = " << __sync_add_and_fetch(&rgDataCount, 1) << endl;
} }
@ -244,49 +337,47 @@ void RGData::serialize(ByteStream &bs, uint32_t amount) const
} }
else else
bs << (uint8_t) 0; bs << (uint8_t) 0;
if (userDataStore)
{
bs << (uint8_t) 1;
userDataStore->serialize(bs);
}
else
bs << (uint8_t) 0;
} }
uint32_t RGData::deserialize(ByteStream &bs, bool hasLenField) void RGData::deserialize(ByteStream &bs, bool hasLenField)
{ {
uint32_t amount, sig; uint32_t amount, sig;
uint8_t *buf; uint8_t *buf;
uint8_t tmp8; uint8_t tmp8;
uint32_t ret = 0;
bs.peek(sig); bs.peek(sig);
if (sig == RGDATA_SIG) { if (sig == RGDATA_SIG) {
bs >> sig; bs >> sig;
bs >> amount; bs >> amount;
ret += 8;
rowData.reset(new uint8_t[amount]); rowData.reset(new uint8_t[amount]);
buf = bs.buf(); buf = bs.buf();
memcpy(rowData.get(), buf, amount); memcpy(rowData.get(), buf, amount);
bs.advance(amount); bs.advance(amount);
bs >> tmp8; bs >> tmp8;
ret += amount + 1;
if (tmp8) { if (tmp8) {
strings.reset(new StringStore()); strings.reset(new StringStore());
ret += strings->deserialize(bs); strings->deserialize(bs);
} }
else else
strings.reset(); strings.reset();
} // UDAF user data
// crude backward compat. Remove after conversions are finished. bs >> tmp8;
else { if (tmp8) {
if (hasLenField) { userDataStore.reset(new UserDataStore());
bs >> amount; userDataStore->deserialize(bs);
ret += 4;
} }
else else
amount = bs.length(); userDataStore.reset();
rowData.reset(new uint8_t[amount]);
strings.reset();
buf = bs.buf();
memcpy(rowData.get(), buf, amount);
bs.advance(amount);
ret += amount;
} }
return ret;
return;
} }
void RGData::clear() void RGData::clear()
@ -295,14 +386,25 @@ void RGData::clear()
strings.reset(); strings.reset();
} }
Row::Row() : data(NULL), strings(NULL) { } // UserDataStore is only used for UDAF.
// Just in time construction because most of the time we don't need one.
UserDataStore* RGData::getUserDataStore()
{
if (!userDataStore)
{
userDataStore.reset(new UserDataStore);
}
return userDataStore.get();
}
Row::Row() : data(NULL), strings(NULL), userDataStore(NULL) { }
Row::Row(const Row &r) : columnCount(r.columnCount), baseRid(r.baseRid), Row::Row(const Row &r) : columnCount(r.columnCount), baseRid(r.baseRid),
oldOffsets(r.oldOffsets), stOffsets(r.stOffsets), oldOffsets(r.oldOffsets), stOffsets(r.stOffsets),
offsets(r.offsets), colWidths(r.colWidths), types(r.types), data(r.data), offsets(r.offsets), colWidths(r.colWidths), types(r.types), data(r.data),
scale(r.scale), precision(r.precision), strings(r.strings), scale(r.scale), precision(r.precision), strings(r.strings),
useStringTable(r.useStringTable), hasLongStringField(r.hasLongStringField), useStringTable(r.useStringTable), hasLongStringField(r.hasLongStringField),
sTableThreshold(r.sTableThreshold), forceInline(r.forceInline) sTableThreshold(r.sTableThreshold), forceInline(r.forceInline), userDataStore(NULL)
{ } { }
Row::~Row() { } Row::~Row() { }
@ -623,9 +725,10 @@ bool Row::isNullValue(uint32_t colIndex) const
break; break;
default: { default: {
ostringstream os; ostringstream os;
os << "Row::isNullValue(): got bad column type (" << types[colIndex] << os << "Row::isNullValue(): got bad column type (";
"). Width=" << getColumnWidth(colIndex) << endl; os << types[colIndex];
os << toString() << endl; os << "). Width=";
os << getColumnWidth(colIndex) << endl;
throw logic_error(os.str()); throw logic_error(os.str());
} }
} }
@ -884,7 +987,9 @@ RowGroup & RowGroup::operator=(const RowGroup &r)
return *this; return *this;
} }
RowGroup::~RowGroup() { } RowGroup::~RowGroup()
{
}
void RowGroup::resetRowGroup(uint64_t rid) void RowGroup::resetRowGroup(uint64_t rid)
{ {

110
utils/rowgroup/rowgroup.h Normal file → Executable file
View File

@ -38,6 +38,7 @@
#include <stdexcept> #include <stdexcept>
//#define NDEBUG //#define NDEBUG
#include <cassert> #include <cassert>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp> #include <boost/shared_array.hpp>
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#include <cmath> #include <cmath>
@ -56,6 +57,7 @@
#include "bytestream.h" #include "bytestream.h"
#include "calpontsystemcatalog.h" #include "calpontsystemcatalog.h"
#include "exceptclasses.h" #include "exceptclasses.h"
#include "mcsv1_udaf.h"
#include "branchpred.h" #include "branchpred.h"
@ -106,25 +108,74 @@ public:
void clear(); void clear();
void serialize(messageqcpp::ByteStream &) const; void serialize(messageqcpp::ByteStream &) const;
uint32_t deserialize(messageqcpp::ByteStream &); void deserialize(messageqcpp::ByteStream &);
//@bug6065, make StringStore::storeString() thread safe //@bug6065, make StringStore::storeString() thread safe
void useStoreStringMutex(bool b) { fUseStoreStringMutex = b; } void useStoreStringMutex(bool b) { fUseStoreStringMutex = b; }
bool useStoreStringMutex() const { return fUseStoreStringMutex; } bool useStoreStringMutex() const { return fUseStoreStringMutex; }
private: private:
std::string empty_str;
StringStore(const StringStore &); StringStore(const StringStore &);
StringStore & operator=(const StringStore &); StringStore & operator=(const StringStore &);
static const uint32_t CHUNK_SIZE = 64*1024; // allocators like powers of 2 static const uint32_t CHUNK_SIZE = 64*1024; // allocators like powers of 2
// This is an overlay b/c the underlying data needs to be any size, // This is an overlay b/c the underlying data needs to be any size,
// and alloc'd in one chunk. data can't be a sepatate dynamic chunk. // and alloc'd in one chunk. data can't be a separate dynamic chunk.
std::vector<boost::shared_ptr<std::string> > mem; std::vector<boost::shared_ptr<std::string> > mem;
bool empty; bool empty;
bool fUseStoreStringMutex; //@bug6065, make StringStore::storeString() thread safe bool fUseStoreStringMutex; //@bug6065, make StringStore::storeString() thread safe
boost::mutex fMutex; boost::mutex fMutex;
};
// Where we store user data for UDA(n)F
class UserDataStore
{
// length represents the fixed portion length of userData.
// There may be variable length data in containers or other
// user created structures.
struct StoreData
{
int32_t length;
std::string functionName;
boost::shared_ptr<mcsv1sdk::UserData> userData;
StoreData() : length(0) { }
StoreData(const StoreData& rhs)
{
length = rhs.length;
functionName = rhs.functionName;
userData = rhs.userData;
}
};
public:
UserDataStore();
virtual ~UserDataStore();
void serialize(messageqcpp::ByteStream &) const;
void deserialize(messageqcpp::ByteStream &);
//Set to make UserDataStore thread safe
void useUserDataMutex(bool b) { fUseUserDataMutex = b; }
bool useUserDataMutex() const { return fUseUserDataMutex; }
// Returns the offset
uint32_t storeUserData(mcsv1sdk::mcsv1Context& context,
boost::shared_ptr<mcsv1sdk::UserData> data,
uint32_t length);
boost::shared_ptr<mcsv1sdk::UserData> getUserData(uint32_t offset) const;
private:
UserDataStore(const UserDataStore &);
UserDataStore & operator=(const UserDataStore &);
std::vector<StoreData> vStoreData;
bool fUseUserDataMutex;
boost::mutex fMutex;
}; };
#ifdef _MSC_VER #ifdef _MSC_VER
@ -152,7 +203,7 @@ public:
// the 'hasLengthField' is there b/c PM aggregation (and possibly others) currently sends // the 'hasLengthField' is there b/c PM aggregation (and possibly others) currently sends
// inline data with a length field. Once that's converted to string table format, that // inline data with a length field. Once that's converted to string table format, that
// option can go away. // option can go away.
uint32_t deserialize(messageqcpp::ByteStream &, bool hasLengthField=false); // returns the # of bytes read void deserialize(messageqcpp::ByteStream &, bool hasLengthField=false); // returns the # of bytes read
inline uint64_t getStringTableMemUsage(); inline uint64_t getStringTableMemUsage();
void clear(); void clear();
@ -169,9 +220,14 @@ public:
void useStoreStringMutex(bool b) { if (strings) strings->useStoreStringMutex(b); } void useStoreStringMutex(bool b) { if (strings) strings->useStoreStringMutex(b); }
bool useStoreStringMutex() const { return (strings ? (strings->useStoreStringMutex()) : false); } bool useStoreStringMutex() const { return (strings ? (strings->useStoreStringMutex()) : false); }
UserDataStore* getUserDataStore();
// make UserDataStore::storeData() thread safe
void useUserDataMutex(bool b) { if (userDataStore) userDataStore->useUserDataMutex(b); }
bool useUserDataMutex() const { return (userDataStore ? (userDataStore->useUserDataMutex()) : false); }
boost::shared_array<uint8_t> rowData; boost::shared_array<uint8_t> rowData;
boost::shared_ptr<StringStore> strings; boost::shared_ptr<StringStore> strings;
boost::shared_ptr<UserDataStore> userDataStore;
private: private:
//boost::shared_array<uint8_t> rowData; //boost::shared_array<uint8_t> rowData;
//boost::shared_ptr<StringStore> strings; //boost::shared_ptr<StringStore> strings;
@ -187,14 +243,17 @@ class Row
{ {
public: public:
struct Pointer { struct Pointer {
inline Pointer() : data(NULL), strings(NULL) { } inline Pointer() : data(NULL), strings(NULL), userDataStore(NULL) { }
// Pointer(uint8_t*) implicitly makes old code compatible with the string table impl; // Pointer(uint8_t*) implicitly makes old code compatible with the string table impl;
// make it explicit to identify things that still might need to be changed // make it explicit to identify things that still might need to be changed
inline Pointer(uint8_t *d) : data(d), strings(NULL) { } inline Pointer(uint8_t *d) : data(d), strings(NULL), userDataStore(NULL) { }
inline Pointer(uint8_t *d, StringStore *s) : data(d), strings(s) { } inline Pointer(uint8_t *d, StringStore *s) : data(d), strings(s), userDataStore(NULL) { }
inline Pointer(uint8_t *d, StringStore *s, UserDataStore *u) :
data(d), strings(s), userDataStore(u) { }
uint8_t *data; uint8_t *data;
StringStore *strings; StringStore *strings;
UserDataStore *userDataStore;
}; };
Row(); Row();
@ -290,6 +349,11 @@ class Row
inline const uint8_t* getVarBinaryField(uint32_t& len, uint32_t colIndex) const; inline const uint8_t* getVarBinaryField(uint32_t& len, uint32_t colIndex) const;
inline void setVarBinaryField(const uint8_t* val, uint32_t len, uint32_t colIndex); inline void setVarBinaryField(const uint8_t* val, uint32_t len, uint32_t colIndex);
inline boost::shared_ptr<mcsv1sdk::UserData> getUserData(uint32_t colIndex) const;
inline void setUserData(mcsv1sdk::mcsv1Context& context,
boost::shared_ptr<mcsv1sdk::UserData> userData,
uint32_t len, uint32_t colIndex);
uint64_t getNullValue(uint32_t colIndex) const; uint64_t getNullValue(uint32_t colIndex) const;
bool isNullValue(uint32_t colIndex) const; bool isNullValue(uint32_t colIndex) const;
@ -332,6 +396,7 @@ class Row
inline bool equals(const Row &, uint32_t lastCol) const; inline bool equals(const Row &, uint32_t lastCol) const;
inline bool equals(const Row &) const; inline bool equals(const Row &) const;
inline void setUserDataStore(UserDataStore* u) {userDataStore = u;}
private: private:
uint32_t columnCount; uint32_t columnCount;
uint64_t baseRid; uint64_t baseRid;
@ -353,10 +418,12 @@ class Row
boost::shared_array<bool> forceInline; boost::shared_array<bool> forceInline;
inline bool inStringTable(uint32_t col) const; inline bool inStringTable(uint32_t col) const;
UserDataStore* userDataStore; // For UDAF
friend class RowGroup; friend class RowGroup;
}; };
inline Row::Pointer Row::getPointer() const { return Pointer(data, strings); } inline Row::Pointer Row::getPointer() const { return Pointer(data, strings, userDataStore); }
inline uint8_t * Row::getData() const { return data; } inline uint8_t * Row::getData() const { return data; }
inline void Row::setPointer(const Pointer &p) inline void Row::setPointer(const Pointer &p)
@ -368,6 +435,7 @@ inline void Row::setPointer(const Pointer &p)
useStringTable = hasStrings; useStringTable = hasStrings;
offsets = (useStringTable ? stOffsets : oldOffsets); offsets = (useStringTable ? stOffsets : oldOffsets);
} }
userDataStore = p.userDataStore;
} }
inline void Row::setData(const Pointer &p) { setPointer(p); } inline void Row::setData(const Pointer &p) { setPointer(p); }
@ -613,6 +681,15 @@ inline const uint8_t* Row::getVarBinaryField(uint32_t& len, uint32_t colIndex) c
} }
} }
inline boost::shared_ptr<mcsv1sdk::UserData> Row::getUserData(uint32_t colIndex) const
{
if (!userDataStore)
{
return boost::shared_ptr<mcsv1sdk::UserData>();
}
return userDataStore->getUserData(*((uint32_t *) &data[offsets[colIndex]]));
}
inline double Row::getDoubleField(uint32_t colIndex) const inline double Row::getDoubleField(uint32_t colIndex) const
{ {
return *((double *) &data[offsets[colIndex]]); return *((double *) &data[offsets[colIndex]]);
@ -783,6 +860,19 @@ inline void Row::setVarBinaryField(const uint8_t *val, uint32_t len, uint32_t co
} }
} }
inline void Row::setUserData(mcsv1sdk::mcsv1Context& context,
boost::shared_ptr<mcsv1sdk::UserData> userData,
uint32_t len, uint32_t colIndex)
{
if (!userDataStore)
{
return;
}
uint32_t offset = userDataStore->storeUserData(context, userData, len);
*((uint32_t *) &data[offsets[colIndex]]) = offset;
*((uint32_t *) &data[offsets[colIndex] + 4]) = len;
}
inline void Row::copyField(uint32_t destIndex, uint32_t srcIndex) const inline void Row::copyField(uint32_t destIndex, uint32_t srcIndex) const
{ {
uint32_t n = offsets[destIndex + 1] - offsets[destIndex]; uint32_t n = offsets[destIndex + 1] - offsets[destIndex];
@ -1149,6 +1239,7 @@ inline void RowGroup::getRow(uint32_t rowNum, Row *r) const
r->baseRid = getBaseRid(); r->baseRid = getBaseRid();
r->data = &(data[headerSize + (rowNum * offsets[columnCount])]); r->data = &(data[headerSize + (rowNum * offsets[columnCount])]);
r->strings = strings; r->strings = strings;
r->userDataStore = rgData->userDataStore.get();
} }
inline void RowGroup::setData(uint8_t *d) inline void RowGroup::setData(uint8_t *d)
@ -1523,13 +1614,14 @@ inline RGData & RGData::operator=(const RGData &r)
{ {
rowData = r.rowData; rowData = r.rowData;
strings = r.strings; strings = r.strings;
userDataStore = r.userDataStore;
return *this; return *this;
} }
inline void RGData::getRow(uint32_t num, Row *row) inline void RGData::getRow(uint32_t num, Row *row)
{ {
uint32_t size = row->getSize(); uint32_t size = row->getSize();
row->setData(Row::Pointer(&rowData[RowGroup::getHeaderSize() + (num * size)], strings.get())); row->setData(Row::Pointer(&rowData[RowGroup::getHeaderSize() + (num * size)], strings.get(), userDataStore.get()));
} }
} }

434
utils/rowgroup/rowgroup.vpj Normal file → Executable file
View File

@ -1,220 +1,220 @@
<!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd"> <!DOCTYPE Project SYSTEM "http://www.slickedit.com/dtd/vse/10.0/vpj.dtd">
<Project <Project
Version="10.0" Version="10.0"
VendorName="SlickEdit" VendorName="SlickEdit"
TemplateName="GNU C/C++" TemplateName="GNU C/C++"
WorkingDir="."> WorkingDir=".">
<Config <Config
Name="Debug" Name="Debug"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdrowgroup.so" OutputFile="%bdrowgroup.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -g -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -g -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Config <Config
Name="Release" Name="Release"
Type="gnuc" Type="gnuc"
DebugCallbackName="gdb" DebugCallbackName="gdb"
Version="1" Version="1"
OutputFile="%bdrowgroup.so" OutputFile="%bdrowgroup.so"
CompilerConfigName="Latest Version"> CompilerConfigName="Latest Version">
<Menu> <Menu>
<Target <Target
Name="Compile" Name="Compile"
MenuCaption="&amp;Compile" MenuCaption="&amp;Compile"
Dialog="_gnuc_options_form Compile" Dialog="_gnuc_options_form Compile"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
OutputExts="*.o" OutputExts="*.o"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/> <Exec CmdLine='g++ -c %xup %defd -o "%bd%n%oe" %i "%f"'/>
</Target> </Target>
<Target <Target
Name="Link" Name="Link"
MenuCaption="&amp;Link" MenuCaption="&amp;Link"
ShowOnMenu="Never" ShowOnMenu="Never"
Dialog="_gnuc_options_form Link" Dialog="_gnuc_options_form Link"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveCurrent" SaveOption="SaveCurrent"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/> <Exec CmdLine='g++ %xup -o "%o" %f %libs -shared -fPIC'/>
</Target> </Target>
<Target <Target
Name="Build" Name="Build"
MenuCaption="&amp;Build" MenuCaption="&amp;Build"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine="make"/> <Exec CmdLine="make"/>
</Target> </Target>
<Target <Target
Name="Rebuild" Name="Rebuild"
MenuCaption="&amp;Rebuild" MenuCaption="&amp;Rebuild"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Debug" Name="Debug"
MenuCaption="&amp;Debug" MenuCaption="&amp;Debug"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveNone" SaveOption="SaveNone"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="Execute" Name="Execute"
MenuCaption="E&amp;xecute" MenuCaption="E&amp;xecute"
Dialog="_gnuc_options_form Run/Debug" Dialog="_gnuc_options_form Run/Debug"
BuildFirst="1" BuildFirst="1"
CaptureOutputWith="ProcessBuffer" CaptureOutputWith="ProcessBuffer"
Deletable="0" Deletable="0"
SaveOption="SaveWorkspaceFiles" SaveOption="SaveWorkspaceFiles"
RunFromDir="%rw"> RunFromDir="%rw">
<Exec CmdLine=""/> <Exec CmdLine=""/>
</Target> </Target>
<Target <Target
Name="dash" Name="dash"
MenuCaption="-" MenuCaption="-"
Deletable="0"> Deletable="0">
<Exec/> <Exec/>
</Target> </Target>
<Target <Target
Name="GNU C Options" Name="GNU C Options"
MenuCaption="GNU C &amp;Options..." MenuCaption="GNU C &amp;Options..."
ShowOnMenu="HideIfNoCmdLine" ShowOnMenu="HideIfNoCmdLine"
Deletable="0" Deletable="0"
SaveOption="SaveNone"> SaveOption="SaveNone">
<Exec <Exec
CmdLine="gnucoptions" CmdLine="gnucoptions"
Type="Slick-C"/> Type="Slick-C"/>
</Target> </Target>
</Menu> </Menu>
<List Name="GNUC Options"> <List Name="GNUC Options">
<Item <Item
Name="LinkerOutputType" Name="LinkerOutputType"
Value="SharedLibrary"/> Value="SharedLibrary"/>
</List> </List>
</Config> </Config>
<Files> <Files>
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="rowaggregation.cpp"/> <F N="rowaggregation.cpp"/>
<F N="rowgroup.cpp"/> <F N="rowgroup.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="rowaggregation.h"/> <F N="rowaggregation.h"/>
<F N="rowgroup.h"/> <F N="rowgroup.h"/>
</Folder> </Folder>
<Folder <Folder
Name="Resource Files" Name="Resource Files"
Filters="*.ico;*.cur;*.dlg"/> Filters="*.ico;*.cur;*.dlg"/>
<Folder <Folder
Name="Bitmaps" Name="Bitmaps"
Filters="*.bmp"/> Filters="*.bmp"/>
<Folder <Folder
Name="Other Files" Name="Other Files"
Filters=""> Filters="">
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

4
utils/udfsdk/CMakeLists.txt Normal file → Executable file
View File

@ -4,13 +4,13 @@ include_directories( ${ENGINE_COMMON_INCLUDES}
########### next target ############### ########### next target ###############
set(udfsdk_LIB_SRCS udfsdk.cpp) set(udfsdk_LIB_SRCS udfsdk.cpp mcsv1_udaf.cpp allnull.cpp ssq.cpp median.cpp)
add_definitions(-DMYSQL_DYNAMIC_PLUGIN) add_definitions(-DMYSQL_DYNAMIC_PLUGIN)
add_library(udfsdk SHARED ${udfsdk_LIB_SRCS}) add_library(udfsdk SHARED ${udfsdk_LIB_SRCS})
set_target_properties(udfsdk PROPERTIES VERSION 1.0.0 SOVERSION 1) set_target_properties(udfsdk PROPERTIES VERSION 1.1.0 SOVERSION 1)
install(TARGETS udfsdk DESTINATION ${ENGINE_LIBDIR} COMPONENT libs) install(TARGETS udfsdk DESTINATION ${ENGINE_LIBDIR} COMPONENT libs)

96
utils/udfsdk/allnull.cpp Executable file
View File

@ -0,0 +1,96 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <sstream>
#include <cstring>
#include "allnull.h"
#include "bytestream.h"
#include "objectreader.h"
using namespace mcsv1sdk;
struct allnull_data
{
uint64_t totalQuantity;
uint64_t totalNulls;
};
#define OUT_TYPE int64_t
mcsv1_UDAF::ReturnCode allnull::init(mcsv1Context* context,
COL_TYPES& colTypes)
{
context->setUserDataSize(sizeof(allnull_data));
if (colTypes.size() < 1)
{
// The error message will be prepended with
// "The storage engine for the table doesn't support "
context->setErrorMessage("allnull() with 0 arguments");
return mcsv1_UDAF::ERROR;
}
context->setResultType(CalpontSystemCatalog::TINYINT);
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode allnull::finish(mcsv1Context* context)
{
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode allnull::reset(mcsv1Context* context)
{
struct allnull_data* data = (struct allnull_data*)context->getUserData()->data;
data->totalQuantity = 0;
data->totalNulls = 0;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode allnull::nextValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsIn)
{
struct allnull_data* data = (struct allnull_data*)context->getUserData()->data;
for (size_t i = 0; i < context->getParameterCount(); i++)
{
data->totalQuantity++;
if (context->isParamNull(0))
{
data->totalNulls++;
}
}
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode allnull::subEvaluate(mcsv1Context* context, const UserData* userDataIn)
{
struct allnull_data* outData = (struct allnull_data*)context->getUserData()->data;
struct allnull_data* inData = (struct allnull_data*)userDataIn->data;
outData->totalQuantity += inData->totalQuantity;
outData->totalNulls += inData->totalNulls;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode allnull::evaluate(mcsv1Context* context, static_any::any& valOut)
{
OUT_TYPE allNull;
struct allnull_data* data = (struct allnull_data*)context->getUserData()->data;
allNull = data->totalQuantity > 0 && data->totalNulls == data->totalQuantity;
valOut = allNull;
return mcsv1_UDAF::SUCCESS;
}

225
utils/udfsdk/allnull.h Executable file
View File

@ -0,0 +1,225 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***********************************************************************
* $Id$
*
* mcsv1_UDAF.h
***********************************************************************/
/**
* Columnstore interface for writing a User Defined Aggregate
* Functions (UDAF) and User Defined Analytic Functions (UDAnF)
* or a function that can act as either - UDA(n)F
*
* The basic steps are:
*
* 1. Create a the UDA(n)F function interface in some .h file.
* 2. Create the UDF function implementation in some .cpp file
* 3. Create the connector stub (MariaDB UDAF definition) for
* this UDF function.
* 4. build the dynamic library using all of the source.
* 5 Put the library in $COLUMNSTORE_INSTALL/lib of
* all modules
* 6. restart the Columnstore system.
* 7. notify mysqld about the new functions with commands like:
*
* // An example of xor over a range for UDAF and UDAnF
* CREATE AGGREGATE FUNCTION mcs_bit_xor returns BOOL soname
* 'libudfsdk.so';
*
* // An example that only makes sense as a UDAnF
* CREATE AGGREGATE FUNCTION mcs_interpolate returns REAL
* soname 'libudfsdk.so';
*
* The UDAF functions may run distributed in the Columnstore
* engine. UDAnF do not run distributed.
*
* UDAF is User Defined Aggregate Function.
* UDAnF is User Defined Analytic Function.
* UDA(n)F is an acronym for a function that could be either. It
* is also used to describe the interface that is used for
* either.
*/
#ifndef HEADER_allnull
#define HEADER_allnull
#include <cstdlib>
#include <string>
#include <vector>
#include <boost/any.hpp>
#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif
#include "mcsv1_udaf.h"
#include "calpontsystemcatalog.h"
#include "windowfunctioncolumn.h"
using namespace execplan;
#if defined(_MSC_VER) && defined(xxxRGNODE_DLLEXPORT)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
namespace mcsv1sdk
{
// Override mcsv1_UDAF to build your User Defined Aggregate (UDAF) and/or
// User Defined Analytic Function (UDAnF).
// These will be singleton classes, so don't put any instance
// specific data in here. All instance data is stored in mcsv1Context
// passed to each user function and retrieved by the getUserData() method.
//
// Each API function returns a ReturnCode. If ERROR is returned at any time,
// the query is aborted, getInterrupted() will begin to return true and the
// message set in config->setErrorMessage() is returned to MariaDB.
class allnull : public mcsv1_UDAF
{
public:
// Defaults OK
allnull() : mcsv1_UDAF(){};
virtual ~allnull(){};
/**
* init()
*
* Mandatory. Implement this to initialize flags and instance
* data. Called once per SQL statement. You can do any sanity
* checks here.
*
* colTypes (in) - A vector of ColDataType defining the
* parameters of the UDA(n)F call. These can be used to decide
* to override the default return type. If desired, the new
* return type can be set by context->setReturnType() and
* decimal precision can be set in context->
* setResultDecimalCharacteristics.
*
* Return mcsv1_UDAF::ERROR on any error, such as non-compatible
* colTypes or wrong number of arguments. Else return
* mcsv1_UDAF::SUCCESS.
*/
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes);
/**
* finish()
*
* Mandatory. Completes the UDA(n)F. Called once per SQL
* statement. Do not free any memory allocated by
* context->setUserDataSize(). The SDK Framework owns that memory
* and will handle that. Often, there is nothing to do here.
*/
virtual ReturnCode finish(mcsv1Context* context);
/**
* reset()
*
* Mandatory. Reset the UDA(n)F for a new group, partition or,
* in some cases, new Window Frame. Do not free any memory
* allocated by context->setUserDataSize(). The SDK Framework owns
* that memory and will handle that. Use this opportunity to
* reset any variables in context->getUserData() needed for the
* next aggregation. May be called multiple times if running in
* a ditributed fashion.
*
* Use this opportunity to initialize the userData.
*/
virtual ReturnCode reset(mcsv1Context* context);
/**
* nextValue()
*
* Mandatory. Handle a single row.
*
* colsIn - A vector of data structure describing the input
* data.
*
* This function is called once for every row in the filtered
* result set (before aggregation). It is very important that
* this function is efficient.
*
* If the UDAF is running in a distributed fashion, nextValue
* cannot depend on order, as it will only be called for each
* row found on the specific PM.
*
* valsIn (in) - a vector of the parameters from the row.
*/
virtual ReturnCode nextValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsIn);
/**
* subEvaluate()
*
* Mandatory -- Called if the UDAF is running in a distributed
* fashion. Columnstore tries to run all aggregate functions
* distributed, depending on context.
*
* Perform an aggregation on rows partially aggregated by
* nextValue. Columnstore calls nextValue for each row on a
* given PM for a group (GROUP BY). subEvaluate is called on the
* UM to consolodate those values into a single instance of
* userData. Keep your aggregated totals in context's userData.
* The first time this is called for a group, reset() would have
* been called with this version of userData.
*
* Called for every partial data set in each group in GROUP BY.
*
* When subEvaluate has been called for all subAggregated data
* sets, Evaluate will be called with the same context as here.
*
* valIn (In) - This is a pointer to a memory block of the size
* set in setUserDataSize. It will contain the value of userData
* as seen in the last call to NextValue for a given PM.
*
*/
virtual ReturnCode subEvaluate(mcsv1Context* context, const UserData* userDataIn);
/**
* evaluate()
*
* Mandatory. Get the aggregated value.
*
* Called for every new group if UDAF GROUP BY, UDAnF partition
* or, in some cases, new Window Frame.
*
* Set the aggregated value into valOut. The datatype is assumed
* to be the same as that set in the init() function;
*
* If the UDAF is running in a distributed fashion, evaluate is
* called after a series of subEvaluate calls.
*
* valOut (out) - Set the aggregated value here. The datatype is
* assumed to be the same as that set in the init() function;
*
* To return a NULL value, don't assign to valOut.
*/
virtual ReturnCode evaluate(mcsv1Context* context, static_any::any& valOut);
protected:
};
}; // namespace
#undef EXPORT
#endif // HEADER_allnull.h

258
utils/udfsdk/mcsv1_udaf.cpp Executable file
View File

@ -0,0 +1,258 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <sstream>
#include <cstring>
#include <stdexcept>
#include "mcsv1_udaf.h"
#include "bytestream.h"
#include "objectreader.h"
using namespace mcsv1sdk;
/**
* All UDA(n)F functions must be registered in the function map.
* They will be picked up by the Columnstore modules during
* startup.
*
* This is a temporary kludge until we get the library loader
* task complete
*/
UDAF_MAP UDAFMap::fm;
#include "allnull.h"
#include "ssq.h"
#include "median.h"
UDAF_MAP& UDAFMap::getMap()
{
if (fm.size() > 0)
{
return fm;
}
// first: function name
// second: Function pointer
// please use lower case for the function name. Because the names might be
// case-insensitive in MySQL depending on the setting. In such case,
// the function names passed to the interface is always in lower case.
fm["allnull"] = new allnull();
fm["ssq"] = new ssq();
fm["median"] = new median();
return fm;
}
int32_t mcsv1Context::getColWidth()
{
if (fColWidth > 0)
{
return fColWidth;
}
// JIT initialization for types that have a defined size.
switch (fResultType)
{
case CalpontSystemCatalog::BIT:
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::UTINYINT:
case CalpontSystemCatalog::CHAR:
fColWidth = 1;
break;
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::USMALLINT:
fColWidth = 2;
break;
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::UMEDINT:
case CalpontSystemCatalog::UINT:
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::UFLOAT:
case CalpontSystemCatalog::DATE:
fColWidth = 4;
break;
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::UBIGINT:
case CalpontSystemCatalog::DECIMAL:
case CalpontSystemCatalog::UDECIMAL:
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::UDOUBLE:
case CalpontSystemCatalog::DATETIME:
case CalpontSystemCatalog::STRINT:
fColWidth = 8;
break;
case CalpontSystemCatalog::LONGDOUBLE:
fColWidth = sizeof(long double);
break;
default:
break;
}
return fColWidth;
}
bool mcsv1Context::operator==(const mcsv1Context& c) const
{
// We don't test the per row data fields. They don't determine
// if it's the same Context.
if (getName() != c.getName()
|| fRunFlags != c.fRunFlags
|| fContextFlags != c.fContextFlags
|| fUserDataSize != c.fUserDataSize
|| fResultType != c.fResultType
|| fResultscale != c.fResultscale
|| fResultPrecision != c.fResultPrecision
|| fRowsInPartition != c.fRowsInPartition
|| fStartFrame != c.fStartFrame
|| fEndFrame != c.fEndFrame
|| fStartConstant != c.fStartConstant
|| fEndConstant != c.fEndConstant)
return false;
return true;
}
bool mcsv1Context::operator!=(const mcsv1Context& c) const
{
return (!(*this == c));
}
const std::string mcsv1Context::toString() const
{
std::ostringstream output;
output << "mcsv1Context: " << getName() << std::endl;
output << " RunFlags=" << fRunFlags << " ContextFlags=" << fContextFlags << std::endl;
output << " UserDataSize=" << fUserDataSize << " ResultType=" << colDataTypeToString(fResultType) << std::endl;
output << " Resultscale=" << fResultscale << " ResultPrecision=" << fResultPrecision << std::endl;
output << " ErrorMsg=" << errorMsg << std::endl;
output << " bInterrupted=" << bInterrupted << " RowsInPartition=" << fRowsInPartition << std::endl;
output << " StartFrame=" << fStartFrame << " EndFrame=" << fEndFrame << std::endl;
output << " StartConstant=" << fStartConstant << " EndConstant=" << fEndConstant << std::endl;
return output.str();
}
mcsv1sdk::mcsv1_UDAF* mcsv1Context::getFunction()
{
if (func)
{
return func;
}
// Just in time initialization
if (functionName.length() == 0)
{
std::ostringstream errmsg;
errmsg << "mcsv1Context::getFunction: " << functionName << " is empty";
throw std::logic_error(errmsg.str());
}
mcsv1sdk::UDAF_MAP::iterator funcIter = mcsv1sdk::UDAFMap::getMap().find(functionName);
if (funcIter == mcsv1sdk::UDAFMap::getMap().end())
{
std::ostringstream errmsg;
errmsg << "mcsv1Context::getFunction: " << functionName << " is undefined";
throw std::logic_error(errmsg.str());
}
func = funcIter->second;
return func;
}
mcsv1sdk::mcsv1_UDAF* mcsv1Context::getFunction() const
{
return const_cast<mcsv1Context*>(this)->getFunction();
}
void mcsv1Context::createUserData()
{
// Try the function. If not implemented, create a byte array.
UserData* userData = NULL;
mcsv1_UDAF::ReturnCode rc = getFunction()->createUserData(userData, fUserDataSize);
if (rc == mcsv1_UDAF::ERROR)
{
std::ostringstream errmsg;
errmsg << "mcsv1Context::createUserData: " << functionName << errorMsg.c_str();
throw std::logic_error(errmsg.str());
}
setUserData(userData);
}
void mcsv1Context::serialize(messageqcpp::ByteStream& b) const
{
b.needAtLeast(sizeof(mcsv1Context));
b << (ObjectReader::id_t) ObjectReader::MCSV1_CONTEXT;
b << functionName;
b << fRunFlags;
// Dont send context flags, These are set for each call
b << fUserDataSize;
b << (uint32_t)fResultType;
b << fResultscale;
b << fResultPrecision;
b << errorMsg;
// Don't send dataflags. These are set for each call
// bInterrupted is set internally.
b << fRowsInPartition;
b << (uint32_t)fStartFrame;
b << (uint32_t)fEndFrame;
b << fStartConstant;
b << fEndConstant;
}
void mcsv1Context::unserialize(messageqcpp::ByteStream& b)
{
ObjectReader::checkType(b, ObjectReader::MCSV1_CONTEXT);
b >> functionName;
b >> fRunFlags;
b >> fUserDataSize;
uint32_t iResultType;
b >> iResultType;
fResultType = (CalpontSystemCatalog::ColDataType)iResultType;
b >> fResultscale;
b >> fResultPrecision;
b >> errorMsg;
b >> fRowsInPartition;
uint32_t frame;
b >> frame;
fStartFrame = (WF_FRAME)frame;
b >> frame;
fEndFrame = (WF_FRAME)frame;
b >> fStartConstant;
b >> fEndConstant;
}
void UserData::serialize(messageqcpp::ByteStream& bs) const
{
bs << size;
bs.append(data, size);
}
void UserData::unserialize(messageqcpp::ByteStream& bs)
{
bs >> size;
memcpy(data, bs.buf(), size);
bs.advance(size);
}
const std::string typeStr("");
const static_any::any& mcsv1_UDAF::charTypeId = (char)1;
const static_any::any& mcsv1_UDAF::scharTypeId = (signed char)1;
const static_any::any& mcsv1_UDAF::shortTypeId = (short)1;
const static_any::any& mcsv1_UDAF::intTypeId = (int)1;
const static_any::any& mcsv1_UDAF::longTypeId = (long)1;
const static_any::any& mcsv1_UDAF::llTypeId = (long long)1;
const static_any::any& mcsv1_UDAF::ucharTypeId = (unsigned char)1;
const static_any::any& mcsv1_UDAF::ushortTypeId = (unsigned short)1;
const static_any::any& mcsv1_UDAF::uintTypeId = (unsigned int)1;
const static_any::any& mcsv1_UDAF::ulongTypeId = (unsigned long)1;
const static_any::any& mcsv1_UDAF::ullTypeId = (unsigned long long)1;
const static_any::any& mcsv1_UDAF::floatTypeId = (float)1;
const static_any::any& mcsv1_UDAF::doubleTypeId = (double)1;
const static_any::any& mcsv1_UDAF::strTypeId = typeStr;

990
utils/udfsdk/mcsv1_udaf.h Executable file
View File

@ -0,0 +1,990 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***********************************************************************
* $Id$
*
* mcsv1_UDAF.h
***********************************************************************/
/**
* Columnstore interface for writing a User Defined Aggregate
* Functions (UDAF) and User Defined Analytic Functions (UDAnF)
* or a function that can act as either - UDA(n)F
*
* The basic steps are:
*
* 1. Create a the UDA(n)F function interface in some .h file.
* 2. Create the UDF function implementation in some .cpp file
* 3. Create the connector stub (MariaDB UDAF definition) for
* this UDF function.
* 4. build the dynamic library using all of the source.
* 5 Put the library in $COLUMNSTORE_INSTALL/lib of
* all modules
* 6. restart the Columnstore system.
* 7. notify mysqld about the new functions with commands like:
*
* // An example of xor over a range for UDAF and UDAnF
* CREATE AGGREGATE FUNCTION mcs_bit_xor returns BOOL soname
* 'libudfsdk.so';
*
* // An example that only makes sense as a UDAnF
* CREATE AGGREGATE FUNCTION mcs_interpolate returns REAL
* soname 'libudfsdk.so';
*
* The UDAF functions may run distributed in the Columnstore
* engine. UDAnF do not run distributed.
*
* UDAF is User Defined Aggregate Function.
* UDAnF is User Defined Analytic Function.
* UDA(n)F is an acronym for a function that could be either. It
* is also used to describe the interface that is used for
* either.
*/
#ifndef HEADER_mcsv1_udaf
#define HEADER_mcsv1_udaf
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/any.hpp>
#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif
#include "any.hpp"
#include "calpontsystemcatalog.h"
#include "wf_frame.h"
using namespace execplan;
#if defined(_MSC_VER) && defined(xxxRGNODE_DLLEXPORT)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
namespace mcsv1sdk
{
/**
* A map from name to function object.
*
* This is temporary until we get the library loading task
* complete
*
* TODO: Remove when library loading is enabled.
*/
class mcsv1_UDAF;
typedef std::tr1::unordered_map<std::string, mcsv1_UDAF*> UDAF_MAP;
class UDAFMap
{
public:
EXPORT UDAFMap(){};
EXPORT ~UDAFMap(){};
static EXPORT UDAF_MAP& getMap();
private:
static UDAF_MAP fm;
};
/**
* A class to hold your user data
*
* If your UDAF only needs a fixed sized data struct, you need
* do nothing with this. Call setUserDataSize in your init
* function with the required size and the framework will take
* care of it.
*
* If you need something more or just want to control things,
* then override UserData with your data structure and
* implement createUserData in your function object to create
* your data structure. Your UserData destuctor should take care
* of any cleanup you may need (Simple containers clean
* themselves up).
*/
class mcsv1Context;
struct UserData
{
UserData() : size(0), data(NULL) {};
UserData(size_t sz) {size = sz; data = new uint8_t[sz];}
virtual ~UserData() { if (data) delete [] data;}
/**
* serialize()
*
* User data is passed between process. In order to do so, it
* must be serialized. Since user data can have sub objects,
* containers and the like, it is up to the UDAF to provide the
* serialize function. The streaming functionality of
* messageqcpp::ByteStream must be used.
*
* The default streams the size and data buffer to the
* ByteStream
*/
virtual void serialize(messageqcpp::ByteStream& bs) const;
/**
* unserialize()
*
* User data is passed between process. In order to do so, it
* must be unserialized. Since user data can have sub objects,
* containers and the like, it is up to the UDAF to provide the
* unserialize function. The streaming functionality of
* messageqcpp::ByteStream must be used.
*
* data is the datablock returned by createUserData.
*
* The default creates the data array and streams into data.
*/
virtual void unserialize(messageqcpp::ByteStream& bs);
// The default data store. You may or may not wish to use these fields.
uint32_t size;
uint8_t* data;
private:
// For now, copy construction is unwanted
UserData(UserData&);
};
// Flags to define the type and limitations of a UDA(n)F
// Used in context->fRunFlags
static uint64_t UDAF_OVER_REQUIRED __attribute__ ((unused)) = 1; // May only be used as UDAnF
static uint64_t UDAF_OVER_ALLOWED __attribute__ ((unused)) = 1 << 1; // May be used as UDAF or UDAnF
static uint64_t UDAF_ORDER_REQUIRED __attribute__ ((unused)) = 1 << 2; // If used as UDAnF, ORDER BY is required
static uint64_t UDAF_ORDER_ALLOWED __attribute__ ((unused)) = 1 << 3; // If used as UDAnF, ORDER BY is optional
static uint64_t UDAF_WINDOWFRAME_REQUIRED __attribute__ ((unused)) = 1 << 4; // If used as UDAnF, a WINDOW FRAME is required
static uint64_t UDAF_WINDOWFRAME_ALLOWED __attribute__ ((unused)) = 1 << 5; // If used as UDAnF, a WINDOW FRAME is optional
static uint64_t UDAF_MAYBE_NULL __attribute__ ((unused)) = 1 << 6; // If UDA(n)F might return NULL.
static uint64_t UDAF_IGNORE_NULLS __attribute__ ((unused)) = 1 << 7; // If UDA(n)F wants NULL rows suppressed.
// Flags set by the framework to define the context of the call.
// User code shouldn't use these directly
// used in context->fContextFlags
static uint64_t CONTEXT_IS_ANALYTIC __attribute__ ((unused)) = 1; // If called using OVER
static uint64_t CONTEXT_HAS_CURRENT_ROW __attribute__ ((unused)) = 1 << 1; // The current window contains the current row.
static uint64_t CONTEXT_IS_PM __attribute__ ((unused)) = 1 << 2; // The call was made by the PM
// Flags that describe the contents of a specific input parameter
// These will be set in context->dataFlags for each method call by the framework.
// User code shouldn't use these directly
static uint64_t PARAM_IS_NULL __attribute__ ((unused)) = 1;
static uint64_t PARAM_IS_CONSTANT __attribute__ ((unused)) = 1 << 1;
// shorthand for the list of columns in the call sent to init()
// first is the actual column name and second is the data type in Columnstore.
typedef std::vector<std::pair<std::string, CalpontSystemCatalog::ColDataType> >COL_TYPES;
// This is the context class that is passed to all API callbacks
// The framework potentially sets data here for each invocation of
// mcsv1_UDAF methods. Access methods are given for data useful to UDA(n)F.
// Don't modify anything directly except data retrieved with getUserData().
// UDA(n)F devlopers should not modify this class. The framework and other UDA(n)F
// rely on it being as it was when they were compiled.
//
// It's probable that future versions of Columnstore will add functionality to
// the context. UDA(n)F may need to be re-compiled in this case.
class mcsv1Context
{
public:
EXPORT mcsv1Context();
EXPORT mcsv1Context(const mcsv1Context& rhs);
// The destructor is virtual only in case a version 2 is made derived from v1
// to promote backward compatibility.
// mcsv1Context should never be subclassed by UDA(n)F developers
EXPORT virtual ~mcsv1Context();
// Set an error message if something goes wrong
EXPORT void setErrorMessage(std::string errmsg);
// Get the previously set error message
EXPORT const std::string& getErrorMessage() const;
// Set the flags as a set. Return the previous flags.
EXPORT uint64_t setRunFlags(uint64_t flags);
// return the flags
EXPORT uint64_t getRunFlags() const;
// The following set, get, clear and toggle methods can be used to manipulate
// multiple flags by ORing them together in the call sequence.
// Ex setRunFlag(UDAF_OVER_REQUIRED | UDAF_ORDER_REQUIRED);
// sets both flags and returns true if BOTH flags are already set.
//
// Set a specific flag and return its previous setting
EXPORT bool setRunFlag(uint64_t flag);
// Get a specific flag
EXPORT bool getRunFlag(uint64_t flag);
// clear a specific flag and return its previous setting
EXPORT bool clearRunFlag(uint64_t flag);
// toggle a specific flag and return its previous setting
EXPORT bool toggleRunFlag(uint64_t flag);
// Use these to determine the way your UDA(n)F was called
// Valid in all method calls
EXPORT bool isAnalytic();
EXPORT bool isWindowHasCurrentRow();
// Determine if the call is made by the UM
// This could be because the UDA(n)F is not being distributed
// Or it could be during setup or during consolodation of PM values.
// valid in all calls
EXPORT bool isUM();
// Determine if the call is made by the PM
// This will be during partial aggregation performed on the PM
// valid in all calls
EXPORT bool isPM();
// Parameter refinement description accessors
// valid in nextValue, dropValue and evaluateCumulative
size_t getParameterCount() const;
// Determine if an input parameter is NULL
// valid in nextValue, dropValue and evaluateCumulative
EXPORT bool isParamNull(int paramIdx);
// If a parameter is a constant, the UDA(n)F could presumably optimize its workings.
// During the first call to nextValue() or evaluateCumulative().
// Is there a better way to determine this?
// valid in nextValue, dropValue and evaluateCumulative
EXPORT bool isParamConstant(int paramIdx);
// For getting the result type.
EXPORT CalpontSystemCatalog::ColDataType getResultType() const;
// For getting the decimal characteristics for the return value.
// These will be set to the default before init().
EXPORT int32_t getScale() const;
EXPORT int32_t getPrecision() const;
// If you want to change the result type
// valid in init()
EXPORT bool setResultType(CalpontSystemCatalog::ColDataType resultType);
// For setting the decimal characteristics for the return value.
// This only makes sense if the return type is decimal, but should be set
// to (0, -1) for other types if the inout is decimal.
// valid in init()
EXPORT bool setScale(int32_t scale);
EXPORT bool setPrecision(int32_t precision);
// For all types, get the return column width in bytes. Ex. INT will return 4.
EXPORT int32_t getColWidth();
// For non-numric return types, set the return column width. This defaults
// to the the length of the input.
// valid in init()
EXPORT bool setColWidth(int32_t colWidth);
// If a method is known to take a while, call this periodically to see if something
// interupted the processing. If getInterrupted() returns true, then the executing
// method should clean up and exit.
EXPORT bool getInterrupted() const;
// Returns the actual number of rows in the partition. If no partitioning, returns 0.
// valid in reset()
EXPORT uint64_t getRowsInPartition() const;
// Returns the number of rows in the aggregate. This could be the total number of rows,
// the number of rows in the group, or the number of rows in the PM's subaggregate,
// depending on the context it was called.
// valid in subEvaluate() end evaluate().
EXPORT uint64_t getRowCnt() const;
// Allocate instance specific memory. This should be type cast to a structure overlay
// defined by the function. The actual allocatoin occurs in the various modules that
// do the aggregation. If the UDAF is being calculated in a distributed fashion, then
// multiple instances of this data may be allocated. Calls to the subaggregate functions
// do not share a context.
// You do not need to worry about freeing this memory. The framework handles all management.
// Call this during init()
EXPORT void setUserDataSize(int bytes);
// Call this everywhere except init()
EXPORT UserData* getUserData();
// Many UDAnF need a default Window Frame. If none is set here, the default is
// UNBOUNDED PRECEDING to CURRENT ROW.
// It's possible to not allow the the WINDOW FRAME phrase in the UDAnF by setting
// the UDAF_WINDOWFRAME_REQUIRED and UDAF_WINDOWFRAME_ALLOWED both to false. Columnstore
// requires a Window Frame in order to process UDAnF. In this case, the default will
// be used for all calls.
// Possible values for start frame are
// WF_UNBOUNDED_PRECEDING, WF_CURRENT_ROW, WF_PRECEDING or WF_FOLLOWING
// possible values for end frame are
// WF_CURRENT_ROW, WF_UNBOUNDED_FOLLOWING, WF_PRECEDING or WF_FOLLOWING
// If WF_PRECEEdING and/or WF_FOLLOWING, a start or end constant should
// be included to say how many preceeding or following is the default
// Set this during init()
EXPORT bool setDefaultWindowFrame(WF_FRAME defaultStartFrame,
WF_FRAME defaultEndFrame,
int32_t startConstant = 0, // For WF_PRECEEDING or WF_FOLLOWING
int32_t endConstant = 0); // For WF_PRECEEDING or WF_FOLLOWING
// There may be times you want to know the actual frame set by the caller
EXPORT void getStartFrame(WF_FRAME& startFrame, int32_t& startConstant) const;
EXPORT void getEndFrame(WF_FRAME& endFrame, int32_t& endConstant) const;
// Deep Equivalence
bool operator==(const mcsv1Context& c) const;
bool operator!=(const mcsv1Context& c) const;
// stream operator for debugging
EXPORT const std::string toString() const;
// Get the name of the function
EXPORT const std::string& getName() const;
EXPORT mcsv1Context& operator=(const mcsv1Context& rhs);
EXPORT mcsv1Context& copy(const mcsv1Context& rhs);
private:
uint64_t fRunFlags; // Set by the user to define the type of UDA(n)F
uint64_t fContextFlags; // Set by the framework to define this specific call.
int32_t fUserDataSize;
boost::shared_ptr<UserData> fUserData;
CalpontSystemCatalog::ColDataType fResultType;
int32_t fColWidth; // The length in bytes of the return type
int32_t fResultscale; // For scale, the number of digits to the right of the decimal
int32_t fResultPrecision; // The max number of digits allowed in the decimal value
std::string errorMsg;
std::vector<uint32_t>* dataFlags; // one entry for each parameter
bool* bInterrupted; // Gets set to true by the Framework if something happens
uint64_t fRowsInPartition; // Only valid in reset()
int64_t fRowCnt; // The number of rows involved in this aggregate.
WF_FRAME fStartFrame; // Is set to default to start, then modified by the actual frame in the call
WF_FRAME fEndFrame; // Is set to default to start, then modified by the actual frame in the call
int32_t fStartConstant; // for start frame WF_PRECEEDIMG or WF_FOLLOWING
int32_t fEndConstant; // for end frame WF_PRECEEDIMG or WF_FOLLOWING
std::string functionName;
mcsv1sdk::mcsv1_UDAF* func;
public:
// For use by the framework
EXPORT void serialize(messageqcpp::ByteStream& b) const;
EXPORT void unserialize(messageqcpp::ByteStream& b);
EXPORT void createUserData();
EXPORT void setUserData(boost::shared_ptr<UserData> userData);
EXPORT void setUserData(UserData* userData);
EXPORT void setName(std::string name);
EXPORT void setContextFlags(uint64_t flags);
EXPORT void setContextFlag(uint64_t flag);
EXPORT void clearContextFlag(uint64_t flag);
EXPORT uint64_t getContextFlags() const;
EXPORT uint32_t getUserDataSize() const;
EXPORT std::vector<uint32_t>& getDataFlags();
EXPORT void setDataFlags(std::vector<uint32_t>* flags);
EXPORT void setInterrupted(bool interrupted);
EXPORT void setInterrupted(bool* interrupted);
EXPORT void setRowCnt(uint64_t cnt);
EXPORT mcsv1sdk::mcsv1_UDAF* getFunction();
EXPORT mcsv1sdk::mcsv1_UDAF* getFunction() const;
EXPORT boost::shared_ptr<UserData> getUserDataSP();
};
// Since aggregate functions can operate on any data type, we use the following structure
// to define the input row data. To be type insensiteve, data is stored in type static_any::any.
//
// To access the data it must be type cast to the correct type using boost::any_cast.
// example for int data:
//
// if (dataType == CalpontSystemCatalog::INT)
// int myint = boost::any_cast<int>columnData;
//
// For multi-paramter aggregations, the colsIn vector of next_value()
// contains the ordered set of row parameters.
//
// For char, varchar, text, varbinary and blob types, columnData will be std::string.
struct ColumnDatum
{
CalpontSystemCatalog::ColDataType dataType; // defined in calpontsystemcatalog.h
static_any::any columnData;
uint32_t scale; // If dataType is a DECIMAL type
uint32_t precision; // If dataType is a DECIMAL type
ColumnDatum() : dataType(CalpontSystemCatalog::UNDEFINED), scale(0), precision(-1){};
};
// Override mcsv1_UDAF to build your User Defined Aggregate (UDAF) and/or
// User Defined Analytic Function (UDAnF).
// These will be singleton classes, so don't put any instance
// specific data in here. All instance data is stored in mcsv1Context
// passed to each user function and retrieved by the getUserData() method.
//
// Each API function returns a ReturnCode. If ERROR is returned at any time,
// the query is aborted, getInterrupted() will begin to return true and the
// message set in config->setErrorMessage() is returned to MariaDB.
class mcsv1_UDAF
{
public:
enum ReturnCode
{
ERROR = 0,
SUCCESS = 1,
NOT_IMPLEMENTED = 2 // User UDA(n)F shouldn't return this
};
// Defaults OK
mcsv1_UDAF(){};
virtual ~mcsv1_UDAF(){};
/**
* init()
*
* Mandatory. Implement this to initialize flags and instance
* data. Called once per SQL statement. You can do any sanity
* checks here.
*
* colTypes (in) - A vector of ColDataType defining the
* parameters of the UDA(n)F call. These can be used to decide
* to override the default return type. If desired, the new
* return type can be set by context->setReturnType() and
* decimal scale and precision can be set by context->setScale
* and context->setPrecision respectively.
*
* Return mcsv1_UDAF::ERROR on any error, such as non-compatible
* colTypes or wrong number of arguments. Else return
* mcsv1_UDAF::SUCCESS.
*/
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes) = 0;
/**
* finish()
*
* Mandatory. Completes the UDA(n)F. Called once per SQL
* statement. Do not free any memory allocated by
* createUserData(). The SDK Framework owns that memory
* and will handle that. Often, there is nothing to do here.
*/
virtual ReturnCode finish(mcsv1Context* context) = 0;
/**
* reset()
*
* Mandatory. Reset the UDA(n)F for a new group, partition or,
* in some cases, new Window Frame. Do not free any memory
* allocated by createUserData(). The SDK Framework owns
* that memory and will handle that. Use this opportunity to
* reset any variables in context->getUserData() needed for the
* next aggregation. May be called multiple times if running in
* a ditributed fashion.
*
* Use this opportunity to initialize the userData.
*/
virtual ReturnCode reset(mcsv1Context* context) = 0;
/**
* nextValue()
*
* Mandatory. Handle a single row.
*
* colsIn - A vector of data structure describing the input
* data.
*
* This function is called once for every row in the filtered
* result set (before aggregation). It is very important that
* this function is efficient.
*
* If the UDAF is running in a distributed fashion, nextValue
* cannot depend on order, as it will only be called for each
* row found on the specific PM.
*
* valsIn (in) - a vector of the parameters from the row.
*/
virtual ReturnCode nextValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsIn) = 0;
/**
* subEvaluate()
*
* Mandatory -- Called if the UDAF is running in a distributed
* fashion. Columnstore tries to run all aggregate functions
* distributed, depending on context.
*
* Perform an aggregation on rows partially aggregated by
* nextValue. Columnstore calls nextValue for each row on a
* given PM for a group (GROUP BY). subEvaluate is called on the
* UM to consolodate those values into a single instance of
* userData. Keep your aggregated totals in context's userData.
* The first time this is called for a group, reset() would have
* been called with this version of userData.
*
* Called for every partial data set in each group in GROUP BY.
*
* When subEvaluate has been called for all subAggregated data
* sets, Evaluate will be called with the same context as here.
*
* valIn (In) - This is a pointer to a UserData class with the
* partially aggregated values. It will contain the value of
* userData as seen in the last call to NextValue for a given
* PM.
*
*/
virtual ReturnCode subEvaluate(mcsv1Context* context, const UserData* userDataIn) = 0;
/**
* evaluate()
*
* Mandatory. Get the aggregated value.
*
* Called for every new group if UDAF GROUP BY, UDAnF partition
* or, in some cases, new Window Frame.
*
* Set the aggregated value into valOut. The datatype is assumed
* to be the same as that set in the init() function;
*
* If the UDAF is running in a distributed fashion, evaluate is
* called after a series of subEvaluate calls.
*
* valOut (out) - Set the aggregated value here. The datatype is
* assumed to be the same as that set in the init() function;
*
* To return a NULL value, don't assign to valOut.
*/
virtual ReturnCode evaluate(mcsv1Context* context, static_any::any& valOut) = 0;
/**
* dropValue()
*
* Optional -- If defined, the server will call this instead of
* reset for UDAnF.
*
* Don't implement if a UDAnF has one or more of the following:
* The UDAnF can't be used with a Window Frame
* The UDAnF is not reversable in some way
* The UDAnF is not interested in optimal performance
*
* If not implemented, reset() followed by a series of
* nextValue() will be called for each movement of the Window
* Frame.
*
* If implemented, then each movement of the Window Frame will
* result in dropValue() being called for each row falling out
* of the Frame and nextValue() being called for each new row
* coming into the Frame.
*
* valsDropped (in) - a vector of the parameters from the row
* leaving the Frame
*
* dropValue() will not be called for unbounded/current row type
* frames, as those are already optimized.
*/
virtual ReturnCode dropValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsDropped);
/**
* createUserData()
*
* Optional -- The default is to create a data byte array of
* size as set in context->setUserDataSize()
*
* Create your variable length data structure via
* userData = new <UserData_type>
*
* The data structure may contain references to containers or
* pointers to other objects. Remember that for distributed
* processing, this may be called multiple times for variaous
* computing blocks. At the least, it will be called once per PM
* that processes the data, and once more for the UM. For UDAnF,
* it may only be called once.
*
* Set length to the base length of the data structure you
* create.
*
*/
virtual ReturnCode createUserData(UserData*& userdata, int32_t& length);
protected:
// These are handy for testing the actual type of static_any
static const static_any::any& charTypeId;
static const static_any::any& scharTypeId;
static const static_any::any& shortTypeId;
static const static_any::any& intTypeId;
static const static_any::any& longTypeId;
static const static_any::any& llTypeId;
static const static_any::any& ucharTypeId;
static const static_any::any& ushortTypeId;
static const static_any::any& uintTypeId;
static const static_any::any& ulongTypeId;
static const static_any::any& ullTypeId;
static const static_any::any& floatTypeId;
static const static_any::any& doubleTypeId;
static const static_any::any& strTypeId;
};
/***********************************************************************
* There is no user modifiable code past this point
***********************************************************************/
// Function definitions for mcsv1Context
inline mcsv1Context::mcsv1Context() :
fRunFlags(UDAF_OVER_ALLOWED | UDAF_ORDER_ALLOWED | UDAF_WINDOWFRAME_ALLOWED),
fContextFlags(0),
fUserDataSize(0),
fResultType(CalpontSystemCatalog::UNDEFINED),
fColWidth(0),
fResultscale(0),
fResultPrecision(18),
dataFlags(NULL),
bInterrupted(NULL),
fRowsInPartition(0),
fStartFrame(WF_UNBOUNDED_PRECEDING),
fEndFrame(WF_CURRENT_ROW),
fStartConstant(0),
fEndConstant(0),
func(NULL)
{
}
inline mcsv1Context::mcsv1Context(const mcsv1Context& rhs) :
fContextFlags(0),
fColWidth(0),
dataFlags(NULL),
bInterrupted(NULL),
func(NULL)
{
copy(rhs);
}
inline mcsv1Context& mcsv1Context::copy(const mcsv1Context& rhs)
{
fRunFlags = rhs.getRunFlags();
fResultType = rhs.getResultType();
fUserDataSize = rhs.getUserDataSize();
fResultscale = rhs.getScale();
fResultPrecision = rhs.getPrecision();
rhs.getStartFrame(fStartFrame, fStartConstant);
rhs.getEndFrame(fEndFrame, fEndConstant);
functionName = rhs.getName();
bInterrupted = rhs.bInterrupted; // Multiple threads will use the same reference
return *this;
}
inline mcsv1Context::~mcsv1Context()
{
}
inline mcsv1Context& mcsv1Context::operator=(const mcsv1Context& rhs)
{
fContextFlags = 0;
fColWidth = 0;
dataFlags = NULL;
bInterrupted = NULL;
func = NULL;
return copy(rhs);
}
inline void mcsv1Context::setErrorMessage(std::string errmsg)
{
errorMsg = errmsg;
}
inline const std::string& mcsv1Context::getErrorMessage() const
{
return errorMsg;
}
inline uint64_t mcsv1Context::setRunFlags(uint64_t flags)
{
uint64_t f = fRunFlags;
fRunFlags = flags;
return f;
}
inline uint64_t mcsv1Context::getRunFlags() const
{
return fRunFlags;
}
inline bool mcsv1Context::setRunFlag(uint64_t flag)
{
bool b = fRunFlags & flag;
fRunFlags |= flag;
return b;
}
inline bool mcsv1Context::getRunFlag(uint64_t flag)
{
return fRunFlags & flag;
}
inline bool mcsv1Context::clearRunFlag(uint64_t flag)
{
bool b = fRunFlags & flag;
fRunFlags &= ~flag;
return b;
}
inline bool mcsv1Context::toggleRunFlag(uint64_t flag)
{
bool b = fRunFlags & flag;
fRunFlags ^= flag;
return b;
}
inline bool mcsv1Context::isAnalytic()
{
return fContextFlags & CONTEXT_IS_ANALYTIC;
}
inline bool mcsv1Context::isWindowHasCurrentRow()
{
return fContextFlags & CONTEXT_HAS_CURRENT_ROW;
}
inline bool mcsv1Context::isUM()
{
return !(fContextFlags & CONTEXT_IS_PM);
}
inline bool mcsv1Context::isPM()
{
return fContextFlags & CONTEXT_IS_PM;
}
inline size_t mcsv1Context::getParameterCount() const
{
if (dataFlags)
return dataFlags->size();
return 0;
}
inline bool mcsv1Context::isParamNull(int paramIdx)
{
if (dataFlags)
return (*dataFlags)[paramIdx] & PARAM_IS_NULL;
return false;
}
inline bool mcsv1Context::isParamConstant(int paramIdx)
{
if (dataFlags)
return (*dataFlags)[paramIdx] & PARAM_IS_CONSTANT;
return false;
}
inline CalpontSystemCatalog::ColDataType mcsv1Context::getResultType() const
{
return fResultType;
}
inline bool mcsv1Context::setResultType(CalpontSystemCatalog::ColDataType resultType)
{
fResultType = resultType;
return true; // We may want to sanity check here.
}
inline int32_t mcsv1Context::getScale() const
{
return fResultscale;
}
inline int32_t mcsv1Context::getPrecision() const
{
return fResultPrecision;
}
inline bool mcsv1Context::setScale(int32_t scale)
{
fResultscale = scale;
return true;
}
inline bool mcsv1Context::setPrecision(int32_t precision)
{
fResultPrecision = precision;
return true;
}
inline bool mcsv1Context::setColWidth(int32_t colWidth)
{
fColWidth = colWidth;
return true;
}
inline void mcsv1Context::setInterrupted(bool interrupted)
{
if (bInterrupted)
{
*bInterrupted = interrupted;
}
}
inline void mcsv1Context::setInterrupted(bool* interrupted)
{
bInterrupted = interrupted;
}
inline bool mcsv1Context::getInterrupted() const
{
if (bInterrupted)
{
return bInterrupted;
}
return false;
}
inline uint64_t mcsv1Context::getRowsInPartition() const
{
return fRowsInPartition;
}
inline uint64_t mcsv1Context::getRowCnt() const
{
return fRowCnt;
}
inline void mcsv1Context::setUserDataSize(int bytes)
{
fUserDataSize = bytes;
}
inline UserData* mcsv1Context::getUserData()
{
if (!fUserData)
{
createUserData();
}
return fUserData.get();
}
inline boost::shared_ptr<UserData> mcsv1Context::getUserDataSP()
{
if (!fUserData)
{
createUserData();
}
return fUserData;
}
inline void mcsv1Context::setUserData(boost::shared_ptr<UserData> userData)
{
fUserData = userData;
}
inline void mcsv1Context::setUserData(UserData* userData)
{
if (userData)
{
fUserData.reset(userData);
}
else
{
fUserData.reset();
}
}
inline bool mcsv1Context::setDefaultWindowFrame(WF_FRAME defaultStartFrame,
WF_FRAME defaultEndFrame,
int32_t startConstant,
int32_t endConstant)
{
// TODO: Add sanity checks
fStartFrame = defaultStartFrame;
fEndFrame = defaultEndFrame;
fStartConstant = startConstant;
fEndConstant = endConstant;
return true;
}
inline void mcsv1Context::getStartFrame(WF_FRAME& startFrame, int32_t& startConstant) const
{
startFrame = fStartFrame;
startConstant = fStartConstant;
}
inline void mcsv1Context::getEndFrame(WF_FRAME& endFrame, int32_t& endConstant) const
{
endFrame = fEndFrame;
endConstant = fEndConstant;
}
inline const std::string& mcsv1Context::getName() const
{
return functionName;
}
inline void mcsv1Context::setName(std::string name)
{
functionName = name;
}
inline void mcsv1Context::setRowCnt(uint64_t cnt)
{
fRowCnt = cnt;
}
inline uint64_t mcsv1Context::getContextFlags() const
{
return fContextFlags;
}
inline void mcsv1Context::setContextFlags(uint64_t flags)
{
fContextFlags = flags;
}
inline void mcsv1Context::setContextFlag(uint64_t flag)
{
fContextFlags |= flag;
}
inline void mcsv1Context::clearContextFlag(uint64_t flag)
{
fContextFlags &= ~flag;
}
inline uint32_t mcsv1Context::getUserDataSize() const
{
return fUserDataSize;
}
inline std::vector<uint32_t>& mcsv1Context::getDataFlags()
{
return *dataFlags;
}
inline void mcsv1Context::setDataFlags(std::vector<uint32_t>* flags)
{
dataFlags = flags;
}
inline mcsv1_UDAF::ReturnCode mcsv1_UDAF::dropValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsDropped)
{
return NOT_IMPLEMENTED;
}
inline mcsv1_UDAF::ReturnCode mcsv1_UDAF::createUserData(UserData*& userData, int32_t& length)
{
userData = new UserData(length);
userData->size = length;
return SUCCESS;
}
}; // namespace mcssdk
#undef EXPORT
#endif // HEADER_mcsv1_udaf.h

314
utils/udfsdk/median.cpp Executable file
View File

@ -0,0 +1,314 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <sstream>
#include <cstring>
#include <typeinfo>
#include "median.h"
#include "bytestream.h"
#include "objectreader.h"
using namespace mcsv1sdk;
mcsv1_UDAF::ReturnCode median::init(mcsv1Context* context,
COL_TYPES& colTypes)
{
if (colTypes.size() < 1)
{
// The error message will be prepended with
// "The storage engine for the table doesn't support "
context->setErrorMessage("median() with 0 arguments");
return mcsv1_UDAF::ERROR;
}
if (colTypes.size() > 1)
{
context->setErrorMessage("median() with more than 1 argument");
return mcsv1_UDAF::ERROR;
}
if (!(isNumeric(colTypes[0].second)))
{
// The error message will be prepended with
// "The storage engine for the table doesn't support "
context->setErrorMessage("median() with non-numeric argument");
return mcsv1_UDAF::ERROR;
}
context->setResultType(CalpontSystemCatalog::DOUBLE);
context->setColWidth(8);
context->setScale(context->getScale()*2);
context->setPrecision(19);
context->setRunFlag(mcsv1sdk::UDAF_IGNORE_NULLS);
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode median::finish(mcsv1Context* context)
{
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode median::reset(mcsv1Context* context)
{
MedianData* data = static_cast<MedianData*>(context->getUserData());
data->mData.clear();
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode median::nextValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsIn)
{
static_any::any& valIn = valsIn[0].columnData;
MEDIAN_DATA& data = static_cast<MedianData*>(context->getUserData())->mData;
DATATYPE val = 0.0;
if (valIn.empty())
{
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
}
if (valIn.compatible(charTypeId))
{
val = valIn.cast<char>();
}
else if (valIn.compatible(scharTypeId))
{
val = valIn.cast<signed char>();
}
else if (valIn.compatible(shortTypeId))
{
val = valIn.cast<short>();
}
else if (valIn.compatible(intTypeId))
{
val = valIn.cast<int>();
}
else if (valIn.compatible(longTypeId))
{
val = valIn.cast<long>();
}
else if (valIn.compatible(llTypeId))
{
val = valIn.cast<long long>();
}
else if (valIn.compatible(ucharTypeId))
{
val = valIn.cast<unsigned char>();
}
else if (valIn.compatible(ushortTypeId))
{
val = valIn.cast<unsigned short>();
}
else if (valIn.compatible(uintTypeId))
{
val = valIn.cast<unsigned int>();
}
else if (valIn.compatible(ulongTypeId))
{
val = valIn.cast<unsigned long>();
}
else if (valIn.compatible(ullTypeId))
{
val = valIn.cast<unsigned long long>();
}
else if (valIn.compatible(floatTypeId))
{
val = valIn.cast<float>();
}
else if (valIn.compatible(doubleTypeId))
{
val = valIn.cast<double>();
}
// For decimal types, we need to move the decimal point.
uint32_t scale = valsIn[0].scale;
if (val != 0 && scale > 0)
{
val /= pow(10.0, (double)scale);
}
data[val]++;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode median::subEvaluate(mcsv1Context* context, const UserData* userDataIn)
{
if (!userDataIn)
{
return mcsv1_UDAF::SUCCESS;
}
MEDIAN_DATA& outData = static_cast<MedianData*>(context->getUserData())->mData;
const MEDIAN_DATA& inData = static_cast<const MedianData*>(userDataIn)->mData;
MEDIAN_DATA::const_iterator iter = inData.begin();
for (; iter != inData.end(); ++iter)
{
outData[iter->first] += iter->second;
}
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode median::evaluate(mcsv1Context* context, static_any::any& valOut)
{
uint64_t cnt1=0, cnt2=0;
MEDIAN_DATA& data = static_cast<MedianData*>(context->getUserData())->mData;
MEDIAN_DATA::iterator iter(data.begin());
MEDIAN_DATA::iterator revfrom(data.end());
MEDIAN_DATA::reverse_iterator riter(revfrom);
cnt1 += iter->second;
cnt2 += riter->second;
while (iter->first < riter->first)
{
while (cnt1 < cnt2 && iter->first < riter->first)
{
++iter;
cnt1 += iter->second;
}
while (cnt2 < cnt1 &&iter->first < riter->first)
{
++riter;
cnt2 += riter->second;
}
while (cnt1 == cnt2 && iter->first < riter->first)
{
++iter;
cnt1 += iter->second;
if (iter->first > riter->first)
{
break;
}
++riter;
cnt2 += riter->second;
}
}
valOut = (iter->first + riter->first) / 2;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode median::dropValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsDropped)
{
static_any::any& valIn = valsDropped[0].columnData;
MEDIAN_DATA& data = static_cast<MedianData*>(context->getUserData())->mData;
DATATYPE val = 0.0;
if (valIn.empty())
{
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
}
if (valIn.compatible(charTypeId))
{
val = valIn.cast<char>();
}
else if (valIn.compatible(scharTypeId))
{
val = valIn.cast<signed char>();
}
else if (valIn.compatible(shortTypeId))
{
val = valIn.cast<short>();
}
else if (valIn.compatible(intTypeId))
{
val = valIn.cast<int>();
}
else if (valIn.compatible(longTypeId))
{
val = valIn.cast<long>();
}
else if (valIn.compatible(llTypeId))
{
val = valIn.cast<long long>();
}
else if (valIn.compatible(ucharTypeId))
{
val = valIn.cast<unsigned char>();
}
else if (valIn.compatible(ushortTypeId))
{
val = valIn.cast<unsigned short>();
}
else if (valIn.compatible(uintTypeId))
{
val = valIn.cast<unsigned int>();
}
else if (valIn.compatible(ulongTypeId))
{
val = valIn.cast<unsigned long>();
}
else if (valIn.compatible(ullTypeId))
{
val = valIn.cast<unsigned long long>();
}
else if (valIn.compatible(floatTypeId))
{
val = valIn.cast<float>();
}
else if (valIn.compatible(doubleTypeId))
{
val = valIn.cast<double>();
}
// For decimal types, we need to move the decimal point.
uint32_t scale = valsDropped[0].scale;
if (val != 0 && scale > 0)
{
val /= pow(10.0, (double)scale);
}
data[val]--;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode median::createUserData(UserData*& userData, int32_t& length)
{
userData = new MedianData;
length = sizeof(MedianData);
return mcsv1_UDAF::SUCCESS;
}
void MedianData::serialize(messageqcpp::ByteStream& bs) const
{
MEDIAN_DATA::const_iterator iter = mData.begin();
DATATYPE num;
uint32_t cnt;
bs << (int32_t)mData.size();
for (; iter != mData.end(); ++iter)
{
num = iter->first;
bs << num;
cnt = iter->second;
bs << cnt;
}
}
void MedianData::unserialize(messageqcpp::ByteStream& bs)
{
mData.clear();
int32_t sz;
DATATYPE num;
uint32_t cnt;
bs >> sz;
for (int i = 0; i < sz; ++i)
{
bs >> num;
bs >> cnt;
mData[num] = cnt;
}
}

294
utils/udfsdk/median.h Executable file
View File

@ -0,0 +1,294 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***********************************************************************
* $Id$
*
* mcsv1_UDAF.h
***********************************************************************/
/**
* Columnstore interface for writing a User Defined Aggregate
* Functions (UDAF) and User Defined Analytic Functions (UDAnF)
* or a function that can act as either - UDA(n)F
*
* The basic steps are:
*
* 1. Create a the UDA(n)F function interface in some .h file.
* 2. Create the UDF function implementation in some .cpp file
* 3. Create the connector stub (MariaDB UDAF definition) for
* this UDF function.
* 4. build the dynamic library using all of the source.
* 5 Put the library in $COLUMNSTORE_INSTALL/lib of
* all modules
* 6. restart the Columnstore system.
* 7. notify mysqld about the new function:
*
* CREATE AGGREGATE FUNCTION median returns REAL soname
* 'libudf_mysql.so';
*
* The UDAF functions may run distributed in the Columnstore
* engine. UDAnF do not run distributed.
*
* UDAF is User Defined Aggregate Function.
* UDAnF is User Defined Analytic Function.
* UDA(n)F is an acronym for a function that could be either. It
* is also used to describe the interface that is used for
* either.
*/
#ifndef HEADER_median
#define HEADER_median
#include <cstdlib>
#include <string>
#include <vector>
#include <boost/any.hpp>
#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif
#include "mcsv1_udaf.h"
#include "calpontsystemcatalog.h"
#include "windowfunctioncolumn.h"
using namespace execplan;
#if defined(_MSC_VER) && defined(xxxRGNODE_DLLEXPORT)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
namespace mcsv1sdk
{
#define DATATYPE double
typedef std::map<DATATYPE, uint32_t> MEDIAN_DATA;
// Override UserData for data storage
struct MedianData : public UserData
{
MedianData() {};
virtual ~MedianData(){}
virtual void serialize(messageqcpp::ByteStream& bs) const;
virtual void unserialize(messageqcpp::ByteStream& bs);
MEDIAN_DATA mData;
private:
// For now, copy construction is unwanted
MedianData(UserData&);
};
// Override mcsv1_UDAF to build your User Defined Aggregate (UDAF) and/or
// User Defined Analytic Function (UDAnF).
// These will be singleton classes, so don't put any instance
// specific data in here. All instance data is stored in mcsv1Context
// passed to each user function and retrieved by the getUserData() method.
//
// Each API function returns a ReturnCode. If ERROR is returned at any time,
// the query is aborted, getInterrupted() will begin to return true and the
// message set in config->setErrorMessage() is returned to MariaDB.
// Return the median value of the dataset
class median : public mcsv1_UDAF
{
public:
// Defaults OK
median() : mcsv1_UDAF(){};
virtual ~median(){};
/**
* init()
*
* Mandatory. Implement this to initialize flags and instance
* data. Called once per SQL statement. You can do any sanity
* checks here.
*
* colTypes (in) - A vector of ColDataType defining the
* parameters of the UDA(n)F call. These can be used to decide
* to override the default return type. If desired, the new
* return type can be set by context->setReturnType() and
* decimal scale and precision can be set by context->setScale
* and context->setPrecision respectively.
*
* Return mcsv1_UDAF::ERROR on any error, such as non-compatible
* colTypes or wrong number of arguments. Else return
* mcsv1_UDAF::SUCCESS.
*/
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes);
/**
* finish()
*
* Mandatory. Completes the UDA(n)F. Called once per SQL
* statement. Do not free any memory allocated by
* context->setUserDataSize(). The SDK Framework owns that memory
* and will handle that. Often, there is nothing to do here.
*/
virtual ReturnCode finish(mcsv1Context* context);
/**
* reset()
*
* Mandatory. Reset the UDA(n)F for a new group, partition or,
* in some cases, new Window Frame. Do not free any memory
* allocated by context->setUserDataSize(). The SDK Framework owns
* that memory and will handle that. Use this opportunity to
* reset any variables in context->getUserData() needed for the
* next aggregation. May be called multiple times if running in
* a ditributed fashion.
*
* Use this opportunity to initialize the userData.
*/
virtual ReturnCode reset(mcsv1Context* context);
/**
* nextValue()
*
* Mandatory. Handle a single row.
*
* colsIn - A vector of data structure describing the input
* data.
*
* This function is called once for every row in the filtered
* result set (before aggregation). It is very important that
* this function is efficient.
*
* If the UDAF is running in a distributed fashion, nextValue
* cannot depend on order, as it will only be called for each
* row found on the specific PM.
*
* valsIn (in) - a vector of the parameters from the row.
*/
virtual ReturnCode nextValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsIn);
/**
* subEvaluate()
*
* Mandatory -- Called if the UDAF is running in a distributed
* fashion. Columnstore tries to run all aggregate functions
* distributed, depending on context.
*
* Perform an aggregation on rows partially aggregated by
* nextValue. Columnstore calls nextValue for each row on a
* given PM for a group (GROUP BY). subEvaluate is called on the
* UM to consolodate those values into a single instance of
* userData. Keep your aggregated totals in context's userData.
* The first time this is called for a group, reset() would have
* been called with this version of userData.
*
* Called for every partial data set in each group in GROUP BY.
*
* When subEvaluate has been called for all subAggregated data
* sets, Evaluate will be called with the same context as here.
*
* valIn (In) - This is a pointer to a memory block of the size
* set in setUserDataSize. It will contain the value of userData
* as seen in the last call to NextValue for a given PM.
*
*/
virtual ReturnCode subEvaluate(mcsv1Context* context, const UserData* valIn);
/**
* evaluate()
*
* Mandatory. Get the aggregated value.
*
* Called for every new group if UDAF GROUP BY, UDAnF partition
* or, in some cases, new Window Frame.
*
* Set the aggregated value into valOut. The datatype is assumed
* to be the same as that set in the init() function;
*
* If the UDAF is running in a distributed fashion, evaluate is
* called after a series of subEvaluate calls.
*
* valOut (out) - Set the aggregated value here. The datatype is
* assumed to be the same as that set in the init() function;
*
* To return a NULL value, don't assign to valOut.
*/
virtual ReturnCode evaluate(mcsv1Context* context, static_any::any& valOut);
/**
* dropValue()
*
* Optional -- If defined, the server will call this instead of
* reset for UDAnF.
*
* Don't implement if a UDAnF has one or more of the following:
* The UDAnF can't be used with a Window Frame
* The UDAnF is not reversable in some way
* The UDAnF is not interested in optimal performance
*
* If not implemented, reset() followed by a series of
* nextValue() will be called for each movement of the Window
* Frame.
*
* If implemented, then each movement of the Window Frame will
* result in dropValue() being called for each row falling out
* of the Frame and nextValue() being called for each new row
* coming into the Frame.
*
* valsDropped (in) - a vector of the parameters from the row
* leaving the Frame
*
* dropValue() will not be called for unbounded/current row type
* frames, as those are already optimized.
*/
virtual ReturnCode dropValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsDropped);
/**
* createUserData()
*
* Optional -- If defined, the server will call this instead of
* createUserData on context.
*
* Create your variable length data structure via
* data = new <datatype>
*
* The data structure may contain references to containers or
* pointers to other objects. Remember that for distributed
* processing, this may be called multiple times for variaous
* computing blocks. At the least, it will be called once per PM
* that processes the data, and once more for the UM. For UDAnF,
* it may only be called once.
*
* Set length to the length of the data structure you create.
*
* For each call to createUserData(), there will be a
* corresponding deleteUserData() where you must clean up. Any
* memory leaks are your fault.
*
*/
virtual ReturnCode createUserData(UserData*& data, int32_t& length);
protected:
};
}; // namespace
#undef EXPORT
#endif // HEADER_median.h

250
utils/udfsdk/ssq.cpp Executable file
View File

@ -0,0 +1,250 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <sstream>
#include <cstring>
#include <typeinfo>
#include "ssq.h"
#include "bytestream.h"
#include "objectreader.h"
using namespace mcsv1sdk;
#define DATATYPE double
struct ssq_data
{
uint64_t scale;
DATATYPE sumsq;
ssq_data() : scale(0){}
};
#define OUT_TYPE int64_t
mcsv1_UDAF::ReturnCode ssq::init(mcsv1Context* context,
COL_TYPES& colTypes)
{
if (colTypes.size() < 1)
{
// The error message will be prepended with
// "The storage engine for the table doesn't support "
context->setErrorMessage("ssq() with 0 arguments");
return mcsv1_UDAF::ERROR;
}
if (colTypes.size() > 1)
{
context->setErrorMessage("ssq() with more than 1 argument");
return mcsv1_UDAF::ERROR;
}
if (!(isNumeric(colTypes[0].second)))
{
// The error message will be prepended with
// "The storage engine for the table doesn't support "
context->setErrorMessage("ssq() with non-numeric argument");
return mcsv1_UDAF::ERROR;
}
context->setUserDataSize(sizeof(ssq_data));
context->setResultType(CalpontSystemCatalog::DOUBLE);
context->setColWidth(8);
context->setScale(context->getScale()*2);
context->setPrecision(19);
context->setRunFlag(mcsv1sdk::UDAF_IGNORE_NULLS);
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode ssq::finish(mcsv1Context* context)
{
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode ssq::reset(mcsv1Context* context)
{
struct ssq_data* data = (struct ssq_data*)context->getUserData()->data;
if (data)
{
data->scale = 0;
data->sumsq = 0;
}
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode ssq::nextValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsIn)
{
static_any::any& valIn = valsIn[0].columnData;
struct ssq_data* data = (struct ssq_data*)context->getUserData()->data;
DATATYPE val = 0.0;
if (valIn.empty())
{
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
}
if (valIn.compatible(charTypeId))
{
val = valIn.cast<char>();
}
else if (valIn.compatible(scharTypeId))
{
val = valIn.cast<signed char>();
}
else if (valIn.compatible(shortTypeId))
{
val = valIn.cast<short>();
}
else if (valIn.compatible(intTypeId))
{
val = valIn.cast<int>();
}
else if (valIn.compatible(longTypeId))
{
val = valIn.cast<long>();
}
else if (valIn.compatible(llTypeId))
{
val = valIn.cast<long long>();
}
else if (valIn.compatible(ucharTypeId))
{
val = valIn.cast<unsigned char>();
}
else if (valIn.compatible(ushortTypeId))
{
val = valIn.cast<unsigned short>();
}
else if (valIn.compatible(uintTypeId))
{
val = valIn.cast<unsigned int>();
}
else if (valIn.compatible(ulongTypeId))
{
val = valIn.cast<unsigned long>();
}
else if (valIn.compatible(ullTypeId))
{
val = valIn.cast<unsigned long long>();
}
else if (valIn.compatible(floatTypeId))
{
val = valIn.cast<float>();
}
else if (valIn.compatible(doubleTypeId))
{
val = valIn.cast<double>();
}
// For decimal types, we need to move the decimal point.
uint32_t scale = valsIn[0].scale;
if (val != 0 && scale > 0)
{
val /= pow(10.0, (double)scale);
}
data->sumsq += val*val;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode ssq::subEvaluate(mcsv1Context* context, const UserData* userDataIn)
{
struct ssq_data* outData = (struct ssq_data*)context->getUserData()->data;
struct ssq_data* inData = (struct ssq_data*)userDataIn->data;
outData->sumsq += inData->sumsq;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode ssq::evaluate(mcsv1Context* context, static_any::any& valOut)
{
struct ssq_data* data = (struct ssq_data*)context->getUserData()->data;
valOut = data->sumsq;
return mcsv1_UDAF::SUCCESS;
}
mcsv1_UDAF::ReturnCode ssq::dropValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsDropped)
{
static_any::any& valIn = valsDropped[0].columnData;
struct ssq_data* data = (struct ssq_data*)context->getUserData()->data;
DATATYPE val = 0.0;
if (valIn.empty())
{
return mcsv1_UDAF::SUCCESS; // Ought not happen when UDAF_IGNORE_NULLS is on.
}
if (valIn.compatible(charTypeId))
{
val = valIn.cast<char>();
}
else if (valIn.compatible(scharTypeId))
{
val = valIn.cast<signed char>();
}
else if (valIn.compatible(shortTypeId))
{
val = valIn.cast<short>();
}
else if (valIn.compatible(intTypeId))
{
val = valIn.cast<int>();
}
else if (valIn.compatible(longTypeId))
{
val = valIn.cast<long>();
}
else if (valIn.compatible(llTypeId))
{
val = valIn.cast<long long>();
}
else if (valIn.compatible(ucharTypeId))
{
val = valIn.cast<unsigned char>();
}
else if (valIn.compatible(ushortTypeId))
{
val = valIn.cast<unsigned short>();
}
else if (valIn.compatible(uintTypeId))
{
val = valIn.cast<unsigned int>();
}
else if (valIn.compatible(ulongTypeId))
{
val = valIn.cast<unsigned long>();
}
else if (valIn.compatible(ullTypeId))
{
val = valIn.cast<unsigned long long>();
}
else if (valIn.compatible(floatTypeId))
{
val = valIn.cast<float>();
}
else if (valIn.compatible(doubleTypeId))
{
val = valIn.cast<double>();
}
// For decimal types, we need to move the decimal point.
uint32_t scale = valsDropped[0].scale;
if (val != 0 && scale > 0)
{
val /= pow(10.0, (double)scale);
}
data->sumsq -= val*val;
return mcsv1_UDAF::SUCCESS;
}

248
utils/udfsdk/ssq.h Executable file
View File

@ -0,0 +1,248 @@
/* Copyright (C) 2017 MariaDB Corporaton
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 of
the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
/***********************************************************************
* $Id$
*
* mcsv1_UDAF.h
***********************************************************************/
/**
* Columnstore interface for writing a User Defined Aggregate
* Functions (UDAF) and User Defined Analytic Functions (UDAnF)
* or a function that can act as either - UDA(n)F
*
* The basic steps are:
*
* 1. Create a the UDA(n)F function interface in some .h file.
* 2. Create the UDF function implementation in some .cpp file
* 3. Create the connector stub (MariaDB UDAF definition) for
* this UDF function.
* 4. build the dynamic library using all of the source.
* 5 Put the library in $COLUMNSTORE_INSTALL/lib of
* all modules
* 6. restart the Columnstore system.
* 7. notify mysqld about the new function:
*
* CREATE AGGREGATE FUNCTION ssq returns REAL soname
* 'libudf_mysql.so';
*
* The UDAF function will run distributed in the Columnstore
* engine. UDAnF do not run distributed.
*
* UDAF is User Defined Aggregate Function.
* UDAnF is User Defined Analytic Function.
* UDA(n)F is an acronym for a function that could be either. It
* is also used to describe the interface that is used for
* either.
*/
#ifndef HEADER_ssq
#define HEADER_ssq
#include <cstdlib>
#include <string>
#include <vector>
#include <boost/any.hpp>
#ifdef _MSC_VER
#include <unordered_map>
#else
#include <tr1/unordered_map>
#endif
#include "mcsv1_udaf.h"
#include "calpontsystemcatalog.h"
#include "windowfunctioncolumn.h"
using namespace execplan;
#if defined(_MSC_VER) && defined(xxxRGNODE_DLLEXPORT)
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
namespace mcsv1sdk
{
// Override mcsv1_UDAF to build your User Defined Aggregate (UDAF) and/or
// User Defined Analytic Function (UDAnF).
// These will be singleton classes, so don't put any instance
// specific data in here. All instance data is stored in mcsv1Context
// passed to each user function and retrieved by the getUserData() method.
//
// Each API function returns a ReturnCode. If ERROR is returned at any time,
// the query is aborted, getInterrupted() will begin to return true and the
// message set in config->setErrorMessage() is returned to MariaDB.
// A simple aggregate to return the sum of squares
class ssq : public mcsv1_UDAF
{
public:
// Defaults OK
ssq() : mcsv1_UDAF(){};
virtual ~ssq(){};
/**
* init()
*
* Mandatory. Implement this to initialize flags and instance
* data. Called once per SQL statement. You can do any sanity
* checks here.
*
* colTypes (in) - A vector of ColDataType defining the
* parameters of the UDA(n)F call. These can be used to decide
* to override the default return type. If desired, the new
* return type can be set by context->setReturnType() and
* decimal scale and precision can be set by context->setScale
* and context->setPrecision respectively.
*
* Return mcsv1_UDAF::ERROR on any error, such as non-compatible
* colTypes or wrong number of arguments. Else return
* mcsv1_UDAF::SUCCESS.
*/
virtual ReturnCode init(mcsv1Context* context,
COL_TYPES& colTypes);
/**
* finish()
*
* Mandatory. Completes the UDA(n)F. Called once per SQL
* statement. Do not free any memory allocated by
* context->createUserData(). The SDK Framework owns that memory
* and will handle that. Often, there is nothing to do here.
*/
virtual ReturnCode finish(mcsv1Context* context);
/**
* reset()
*
* Mandatory. Reset the UDA(n)F for a new group, partition or,
* in some cases, new Window Frame. Do not free any memory
* allocated by context->createUserData(). The SDK Framework
* owns that memory and will handle that. Use this opportunity
* to reset any variables in context->getUserData() needed for
* the next aggregation. May be called multiple times on
* different modules.
*/
virtual ReturnCode reset(mcsv1Context* context);
/**
* nextValue()
*
* Mandatory. Handle a single row.
*
* colsIn - A vector of data structure describing the input
* data.
*
* This function is called once for every row in the filtered
* result set (before aggregation). It is very important that
* this function is efficient.
*
* If the UDAF is running in a distributed fashion, nextValue
* cannot depend on order, as it will only be called for each
* row found on the specific PM.
*
* valsIn (in) - a vector of the parameters from the row.
*/
virtual ReturnCode nextValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsIn);
/**
* subEvaluate()
*
* Mandatory -- Called if the UDAF is running in a distributed
* fashion. Columnstore tries to run all aggregate functions
* distributed, depending on context.
*
* Perform an aggregation on rows partially aggregated by
* nextValue. Columnstore calls nextValue for each row on a
* given PM for a group (GROUP BY). subEvaluate is called on the
* UM to consolodate those values into a single instance of
* userData. Keep your aggregated totals in context's userData.
* The first time this is called for a group, reset() would have
* been called with this version of userData.
*
* Called for every partial data set in each group in GROUP BY.
*
* When subEvaluate has been called for all subAggregated data
* sets, Evaluate will be called.
*
* valIn (In) - This is a pointer to a memory block of the size
* set in setUserDataSize. It will contain the value of userData
* as seen in the last call to NextValue for a given PM.
*
*/
virtual ReturnCode subEvaluate(mcsv1Context* context, const UserData* userDataIn);
/**
* evaluate()
*
* Mandatory. Get the aggregated value.
*
* Called for every new group if UDAF GROUP BY, UDAnF partition
* or, in some cases, new Window Frame.
*
* Set the aggregated value into valOut. The datatype is assumed
* to be the same as that set in the init() function;
*
* If the UDAF is running in a distributed fashion, evaluate is
* called after a series of subEvaluate calls.
*
* valOut (out) - Set the aggregated value here. The datatype is
* assumed to be the same as that set in the init() function;
*
* To return a NULL value, don't assign to valOut.
*/
virtual ReturnCode evaluate(mcsv1Context* context, static_any::any& valOut);
/**
* dropValue()
*
* Optional -- If defined, the server will call this instead of
* reset for UDAnF.
*
* Don't implement if a UDAnF has one or more of the following:
* The UDAnF can't be used with a Window Frame
* The UDAnF is not reversable in some way
* The UDAnF is not interested in optimal performance
*
* If not implemented, reset() followed by a series of
* nextValue() will be called for each movement of the Window
* Frame.
*
* If implemented, then each movement of the Window Frame will
* result in dropValue() being called for each row falling out
* of the Frame and nextValue() being called for each new row
* coming into the Frame.
*
* valsDropped (in) - a vector of the parameters from the row
* leaving the Frame
*
* dropValue() will not be called for unbounded/current row type
* frames, as those are already optimized.
*/
virtual ReturnCode dropValue(mcsv1Context* context,
std::vector<ColumnDatum>& valsDropped);
protected:
};
}; // namespace
#undef EXPORT
#endif // HEADER_ssq.h

228
utils/udfsdk/udfmysql.cpp Normal file → Executable file
View File

@ -168,13 +168,239 @@ void mcs_isnull_deinit(UDF_INIT* initid)
} }
#ifdef _MSC_VER #ifdef _MSC_VER
__declspec(dllexport) __declspec(dllexport)f
#endif #endif
long long mcs_isnull(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error) long long mcs_isnull(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
{ {
return 0; return 0;
} }
/**
* ALLNULL connector stub
*/
struct allnull_data
{
ulonglong totalQuantity;
ulonglong totalNulls;
};
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool allnull_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
struct allnull_data* data;
// if (args->arg_count != 1)
// {
// strcpy(message,"allnull() requires one argument");
// return 1;
// }
if (!(data = (struct allnull_data*) malloc(sizeof(struct allnull_data))))
{
strmov(message,"Couldn't allocate memory");
return 1;
}
data->totalQuantity = 0;
data->totalNulls = 0;
initid->ptr = (char*)data;
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void allnull_deinit(UDF_INIT* initid)
{
free(initid->ptr);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long allnull(UDF_INIT* initid, UDF_ARGS* args __attribute__((unused)),
char* is_null, char* error __attribute__((unused)))
{
struct allnull_data* data = (struct allnull_data*)initid->ptr;
return data->totalQuantity > 0 && data->totalNulls == data->totalQuantity;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void
allnull_clear(UDF_INIT* initid, char* is_null __attribute__((unused)),
char* message __attribute__((unused)))
{
struct allnull_data* data = (struct allnull_data*)initid->ptr;
data->totalQuantity = 0;
data->totalNulls = 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void
allnull_add(UDF_INIT* initid, UDF_ARGS* args,
char* is_null,
char* message __attribute__((unused)))
{
struct allnull_data* data = (struct allnull_data*)initid->ptr;
const char *word=args->args[0];
data->totalQuantity++;
if (!word)
{
data->totalNulls++;
}
}
/**
* SSQ connector stub
*/
struct ssq_data
{
double sumsq;
};
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool ssq_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
struct ssq_data* data;
if (args->arg_count != 1)
{
strcpy(message,"ssq() requires one argument");
return 1;
}
if (!(data = (struct ssq_data*) malloc(sizeof(struct ssq_data))))
{
strmov(message,"Couldn't allocate memory");
return 1;
}
data->sumsq = 0;
initid->ptr = (char*)data;
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void ssq_deinit(UDF_INIT* initid)
{
free(initid->ptr);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void
ssq_clear(UDF_INIT* initid, char* is_null __attribute__((unused)),
char* message __attribute__((unused)))
{
struct ssq_data* data = (struct ssq_data*)initid->ptr;
data->sumsq = 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void
ssq_add(UDF_INIT* initid, UDF_ARGS* args,
char* is_null,
char* message __attribute__((unused)))
{
struct ssq_data* data = (struct ssq_data*)initid->ptr;
double val = cvtArgToDouble(args->arg_type[0], args->args[0]);
data->sumsq = val*val;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long ssq(UDF_INIT* initid, UDF_ARGS* args __attribute__((unused)),
char* is_null, char* error __attribute__((unused)))
{
struct ssq_data* data = (struct ssq_data*)initid->ptr;
return data->sumsq;
}
//=======================================================================
/**
* MEDIAN connector stub
*/
#ifdef _MSC_VER
__declspec(dllexport)
#endif
my_bool median_init(UDF_INIT* initid, UDF_ARGS* args, char* message)
{
if (args->arg_count != 1)
{
strcpy(message,"median() requires one argument");
return 1;
}
/*
if (!(data = (struct ssq_data*) malloc(sizeof(struct ssq_data))))
{
strmov(message,"Couldn't allocate memory");
return 1;
}
data->sumsq = 0;
initid->ptr = (char*)data;
*/
return 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void median_deinit(UDF_INIT* initid)
{
// free(initid->ptr);
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void
median_clear(UDF_INIT* initid, char* is_null __attribute__((unused)),
char* message __attribute__((unused)))
{
// struct ssq_data* data = (struct ssq_data*)initid->ptr;
// data->sumsq = 0;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
void
median_add(UDF_INIT* initid, UDF_ARGS* args,
char* is_null,
char* message __attribute__((unused)))
{
// struct ssq_data* data = (struct ssq_data*)initid->ptr;
// double val = cvtArgToDouble(args->arg_type[0], args->args[0]);
// data->sumsq = val*val;
}
#ifdef _MSC_VER
__declspec(dllexport)
#endif
long long median(UDF_INIT* initid, UDF_ARGS* args __attribute__((unused)),
char* is_null, char* error __attribute__((unused)))
{
// struct ssq_data* data = (struct ssq_data*)initid->ptr;
// return data->sumsq;
return 0;
}
} }
// vim:ts=4 sw=4: // vim:ts=4 sw=4:

9
utils/udfsdk/udfsdk.vpj Normal file → Executable file
View File

@ -202,12 +202,20 @@
<Folder <Folder
Name="Source Files" Name="Source Files"
Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d">
<F N="allnull.cpp"/>
<F N="mcsv1_udaf.cpp"/>
<F N="median.cpp"/>
<F N="ssq.cpp"/>
<F N="udfinfinidb.cpp"/> <F N="udfinfinidb.cpp"/>
<F N="udfmysql.cpp"/> <F N="udfmysql.cpp"/>
</Folder> </Folder>
<Folder <Folder
Name="Header Files" Name="Header Files"
Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
<F N="allnull.h"/>
<F N="mcsv1_udaf.h"/>
<F N="median.h"/>
<F N="ssq.h"/>
<F N="udfsdk.h"/> <F N="udfsdk.h"/>
</Folder> </Folder>
<Folder <Folder
@ -222,6 +230,7 @@
<F <F
N="Makefile" N="Makefile"
Type="Makefile"/> Type="Makefile"/>
<F N="mcsv1_UDAF_base"/>
</Folder> </Folder>
</Files> </Files>
</Project> </Project>

2
utils/utils.vpj Normal file → Executable file
View File

@ -233,6 +233,7 @@
<F N="windowfunction/wf_row_number.cpp"/> <F N="windowfunction/wf_row_number.cpp"/>
<F N="windowfunction/wf_stats.cpp"/> <F N="windowfunction/wf_stats.cpp"/>
<F N="windowfunction/wf_sum_avg.cpp"/> <F N="windowfunction/wf_sum_avg.cpp"/>
<F N="windowfunction/wf_udaf.cpp"/>
<F N="windowfunction/windowframe.cpp"/> <F N="windowfunction/windowframe.cpp"/>
<F N="windowfunction/windowfunction.cpp"/> <F N="windowfunction/windowfunction.cpp"/>
<F N="windowfunction/windowfunctiontype.cpp"/> <F N="windowfunction/windowfunctiontype.cpp"/>
@ -277,6 +278,7 @@
<F N="windowfunction/wf_row_number.h"/> <F N="windowfunction/wf_row_number.h"/>
<F N="windowfunction/wf_stats.h"/> <F N="windowfunction/wf_stats.h"/>
<F N="windowfunction/wf_sum_avg.h"/> <F N="windowfunction/wf_sum_avg.h"/>
<F N="windowfunction/wf_udaf.h"/>
<F N="windowfunction/windowframe.h"/> <F N="windowfunction/windowframe.h"/>
<F N="windowfunction/windowfunction.h"/> <F N="windowfunction/windowfunction.h"/>
<F N="windowfunction/windowfunctiontype.h"/> <F N="windowfunction/windowfunctiontype.h"/>

3
utils/windowfunction/CMakeLists.txt Normal file → Executable file
View File

@ -21,7 +21,8 @@ set(windowfunction_LIB_SRCS
wf_ranking.cpp wf_ranking.cpp
wf_row_number.cpp wf_row_number.cpp
wf_stats.cpp wf_stats.cpp
wf_sum_avg.cpp) wf_sum_avg.cpp
wf_udaf.cpp)
add_library(windowfunction SHARED ${windowfunction_LIB_SRCS}) add_library(windowfunction SHARED ${windowfunction_LIB_SRCS})

508
utils/windowfunction/wf_udaf.cpp Executable file
View File

@ -0,0 +1,508 @@
/************************************************************************************
Copyright (C) 2017 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
*************************************************************************************/
//#define NDEBUG
#include <cassert>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
#include <boost/shared_ptr.hpp>
using namespace boost;
#include "loggingid.h"
#include "errorcodes.h"
#include "idberrorinfo.h"
using namespace logging;
#include "rowgroup.h"
using namespace rowgroup;
#include "idborderby.h"
using namespace ordering;
#include "joblisttypes.h"
#include "calpontsystemcatalog.h"
#include "constantcolumn.h"
using namespace execplan;
#include "windowfunctionstep.h"
using namespace joblist;
#include "wf_udaf.h"
namespace windowfunction
{
template<typename T>
boost::shared_ptr<WindowFunctionType> WF_udaf<T>::makeFunction(int id, const string& name, int ct, mcsv1sdk::mcsv1Context& context)
{
boost::shared_ptr<WindowFunctionType> func;
switch (ct)
{
case CalpontSystemCatalog::TINYINT:
case CalpontSystemCatalog::SMALLINT:
case CalpontSystemCatalog::MEDINT:
case CalpontSystemCatalog::INT:
case CalpontSystemCatalog::BIGINT:
case CalpontSystemCatalog::DECIMAL:
{
func.reset(new WF_udaf<int64_t>(id, name, context));
break;
}
case CalpontSystemCatalog::UTINYINT:
case CalpontSystemCatalog::USMALLINT:
case CalpontSystemCatalog::UMEDINT:
case CalpontSystemCatalog::UINT:
case CalpontSystemCatalog::UBIGINT:
case CalpontSystemCatalog::UDECIMAL:
{
func.reset(new WF_udaf<uint64_t>(id, name, context));
break;
}
case CalpontSystemCatalog::DOUBLE:
case CalpontSystemCatalog::UDOUBLE:
{
func.reset(new WF_udaf<double>(id, name, context));
break;
}
case CalpontSystemCatalog::FLOAT:
case CalpontSystemCatalog::UFLOAT:
{
func.reset(new WF_udaf<float>(id, name, context));
break;
}
case CalpontSystemCatalog::CHAR:
case CalpontSystemCatalog::VARCHAR:
case CalpontSystemCatalog::VARBINARY:
case CalpontSystemCatalog::TEXT:
case CalpontSystemCatalog::BLOB:
{
func.reset(new WF_udaf<string>(id, name, context));
break;
}
default:
{
string errStr = name + "(" + colType2String[ct] + ")";
errStr = IDBErrorInfo::instance()->errorMsg(ERR_WF_INVALID_PARM_TYPE, errStr);
cerr << errStr << endl;
throw IDBExcept(errStr, ERR_WF_INVALID_PARM_TYPE);
break;
}
}
// Get the UDAnF function object
WF_udaf* wfUDAF = (WF_udaf*)func.get();
mcsv1sdk::mcsv1Context& udafContext = wfUDAF->getContext();
udafContext.setInterrupted(wfUDAF->getInterruptedPtr());
wfUDAF->resetData();
return func;
}
template<typename T>
WF_udaf<T>::WF_udaf(WF_udaf& rhs) : fUDAFContext(rhs.getContext()),
bInterrupted(rhs.getInterrupted()),
fDistinct(rhs.getDistinct())
{
getContext().setInterrupted(getInterruptedPtr());
}
template<typename T>
WindowFunctionType* WF_udaf<T>::clone() const
{
return new WF_udaf(*const_cast<WF_udaf*>(this));
}
template<typename T>
void WF_udaf<T>::resetData()
{
getContext().getFunction()->reset(&getContext());
fSet.clear();
WindowFunctionType::resetData();
}
template<typename T>
void WF_udaf<T>::parseParms(const std::vector<execplan::SRCP>& parms)
{
bRespectNulls = true;
// parms[1]: respect null | ignore null
ConstantColumn* cc = dynamic_cast<ConstantColumn*>(parms[1].get());
idbassert(cc != NULL);
bool isNull = false; // dummy, harded coded
bRespectNulls = (cc->getIntVal(fRow, isNull) > 0);
}
template<typename T>
bool WF_udaf<T>::dropValues(int64_t b, int64_t e)
{
if (!bHasDropValue)
{
// Save work if we discovered dropValue is not implemented in the UDAnF
return false;
}
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
uint64_t colOut = fFieldIndex[0];
uint64_t colIn = fFieldIndex[1];
mcsv1sdk::ColumnDatum datum;
datum.dataType = fRow.getColType(colIn);
datum.scale = fRow.getScale(colIn);
datum.precision = fRow.getPrecision(colOut);
for (int64_t i = b; i < e; i++)
{
if (i % 1000 == 0 && fStep->cancelled())
break;
fRow.setData(getPointer(fRowData->at(i)));
// Turn on NULL flags
std::vector<uint32_t> flags;
uint32_t flag = 0;
if (fRow.isNullValue(colIn) == true)
{
if (!bRespectNulls)
{
continue;
}
flag |= mcsv1sdk::PARAM_IS_NULL;
}
flags.push_back(flag);
getContext().setDataFlags(&flags);
T valIn;
getValue(colIn, valIn, &datum.dataType);
// Check for distinct, if turned on.
// TODO: when we impliment distinct, we need to revist this.
if ((fDistinct) || (fSet.find(valIn) != fSet.end()))
{
continue;
}
datum.columnData = valIn;
std::vector<mcsv1sdk::ColumnDatum> valsIn;
valsIn.push_back(datum);
rc = getContext().getFunction()->dropValue(&getContext(), valsIn);
if (rc == mcsv1sdk::mcsv1_UDAF::NOT_IMPLEMENTED)
{
bHasDropValue = false;
return false;
}
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
bInterrupted = true;
string errStr = IDBErrorInfo::instance()->errorMsg(ERR_WF_UDANF_ERROR, getContext().getErrorMessage());
cerr << errStr << endl;
throw IDBExcept(errStr, ERR_WF_UDANF_ERROR);
}
}
return true;
}
// Sets the value from valOut into column colOut, performing any conversions.
template<typename T>
void WF_udaf<T>::SetUDAFValue(static_any::any& valOut, int64_t colOut,
int64_t b, int64_t e, int64_t c)
{
static const static_any::any& charTypeId = (char)1;
static const static_any::any& scharTypeId = (signed char)1;
static const static_any::any& shortTypeId = (short)1;
static const static_any::any& intTypeId = (int)1;
static const static_any::any& longTypeId = (long)1;
static const static_any::any& llTypeId = (long long)1;
static const static_any::any& ucharTypeId = (unsigned char)1;
static const static_any::any& ushortTypeId = (unsigned short)1;
static const static_any::any& uintTypeId = (unsigned int)1;
static const static_any::any& ulongTypeId = (unsigned long)1;
static const static_any::any& ullTypeId = (unsigned long long)1;
static const static_any::any& floatTypeId = (float)1;
static const static_any::any& doubleTypeId = (double)1;
static const std::string typeStr("");
static const static_any::any& strTypeId = typeStr;
CDT colDataType = fRow.getColType(colOut);
if (valOut.empty())
{
// If valOut is empty, we return NULL
T* pv = NULL;
setValue(colDataType, b, e, c, pv);
fPrev = c;
return;
}
// This may seem a bit convoluted. Users shouldn't return a type
// that they didn't set in mcsv1_UDAF::init(), but this
// handles whatever return type is given and casts
// it to whatever they said to return.
int64_t intOut = 0;
uint64_t uintOut = 0;
float floatOut = 0.0;
double doubleOut = 0.0;
ostringstream oss;
std::string strOut;
if (valOut.compatible(charTypeId))
{
uintOut = intOut = valOut.cast<char>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(scharTypeId))
{
uintOut = intOut = valOut.cast<signed char>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(shortTypeId))
{
uintOut = intOut = valOut.cast<short>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(intTypeId))
{
uintOut = intOut = valOut.cast<int>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(longTypeId))
{
uintOut = intOut = valOut.cast<long>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(llTypeId))
{
uintOut = intOut = valOut.cast<long long>();
floatOut = intOut;
oss << intOut;
}
else if (valOut.compatible(ucharTypeId))
{
intOut = uintOut = valOut.cast<unsigned char>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(ushortTypeId))
{
intOut = uintOut = valOut.cast<unsigned short>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(uintTypeId))
{
intOut = uintOut = valOut.cast<unsigned int>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(ulongTypeId))
{
intOut = uintOut = valOut.cast<unsigned long>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(ullTypeId))
{
intOut = uintOut = valOut.cast<unsigned long long>();
floatOut = uintOut;
oss << uintOut;
}
else if (valOut.compatible(floatTypeId))
{
floatOut = valOut.cast<float>();
doubleOut = floatOut;
intOut = uintOut = floatOut;
oss << floatOut;
}
else if (valOut.compatible(doubleTypeId))
{
doubleOut = valOut.cast<double>();
floatOut = (float)doubleOut;
uintOut = (uint64_t)doubleOut;
intOut = (int64_t)doubleOut;
oss << doubleOut;
}
if (valOut.compatible(strTypeId))
{
std::string strOut = valOut.cast<std::string>();
// Convert the string to numeric type, just in case.
intOut = atol(strOut.c_str());
uintOut = strtoul(strOut.c_str(), NULL, 10);
doubleOut = strtod(strOut.c_str(), NULL);
floatOut = (float)doubleOut;
}
else
{
strOut = oss.str();
}
switch (colDataType)
{
case execplan::CalpontSystemCatalog::BIT:
case execplan::CalpontSystemCatalog::TINYINT:
case execplan::CalpontSystemCatalog::SMALLINT:
case execplan::CalpontSystemCatalog::MEDINT:
case execplan::CalpontSystemCatalog::INT:
case execplan::CalpontSystemCatalog::BIGINT:
case execplan::CalpontSystemCatalog::DECIMAL:
case execplan::CalpontSystemCatalog::UDECIMAL:
setValue(colDataType, b, e, c, &intOut);
break;
case execplan::CalpontSystemCatalog::UTINYINT:
case execplan::CalpontSystemCatalog::USMALLINT:
case execplan::CalpontSystemCatalog::UMEDINT:
case execplan::CalpontSystemCatalog::UINT:
case execplan::CalpontSystemCatalog::UBIGINT:
case execplan::CalpontSystemCatalog::DATE:
case execplan::CalpontSystemCatalog::DATETIME:
setValue(colDataType, b, e, c, &uintOut);
break;
case execplan::CalpontSystemCatalog::FLOAT:
case execplan::CalpontSystemCatalog::UFLOAT:
setValue(colDataType, b, e, c, &floatOut);
break;
case execplan::CalpontSystemCatalog::DOUBLE:
case execplan::CalpontSystemCatalog::UDOUBLE:
setValue(colDataType, b, e, c, &doubleOut);
break;
case execplan::CalpontSystemCatalog::CHAR:
case execplan::CalpontSystemCatalog::VARCHAR:
case execplan::CalpontSystemCatalog::TEXT:
case execplan::CalpontSystemCatalog::VARBINARY:
case execplan::CalpontSystemCatalog::CLOB:
case execplan::CalpontSystemCatalog::BLOB:
setValue(colDataType, b, e, c, &strOut);
break;
default:
{
std::ostringstream errmsg;
errmsg << "WF_udaf: No logic for data type: " << colDataType;
cerr << errmsg.str() << endl;
throw runtime_error(errmsg.str().c_str());
break;
}
}
}
template<typename T>
void WF_udaf<T>::operator()(int64_t b, int64_t e, int64_t c)
{
mcsv1sdk::mcsv1_UDAF::ReturnCode rc;
uint64_t colOut = fFieldIndex[0];
static_any::any valOut;
if ((fFrameUnit == WF__FRAME_ROWS) ||
(fPrev == -1) ||
(!fPeer->operator()(getPointer(fRowData->at(c)), getPointer(fRowData->at(fPrev)))))
{
// for unbounded - current row special handling
if (fPrev >= b && fPrev < c)
b = c;
else if (fPrev <= e && fPrev > c)
e = c;
uint64_t colIn = fFieldIndex[1];
mcsv1sdk::ColumnDatum datum;
datum.dataType = fRow.getColType(colIn);
datum.scale = fRow.getScale(colIn);
datum.precision = fRow.getPrecision(colOut);
if (b<=c && c<=e)
getContext().setContextFlag(mcsv1sdk::CONTEXT_HAS_CURRENT_ROW);
else
getContext().clearContextFlag(mcsv1sdk::CONTEXT_HAS_CURRENT_ROW);
for (int64_t i = b; i <= e; i++)
{
if (i % 1000 == 0 && fStep->cancelled())
break;
fRow.setData(getPointer(fRowData->at(i)));
// Turn on NULL flags
std::vector<uint32_t> flags;
uint32_t flag = 0;
if (fRow.isNullValue(colIn) == true)
{
if (!bRespectNulls)
{
continue;
}
flag |= mcsv1sdk::PARAM_IS_NULL;
}
flags.push_back(flag);
getContext().setDataFlags(&flags);
T valIn;
getValue(colIn, valIn, &datum.dataType);
// Check for distinct, if turned on.
if ((fDistinct) || (fSet.find(valIn) != fSet.end()))
{
continue;
}
if (fDistinct)
fSet.insert(valIn);
datum.columnData = valIn;
std::vector<mcsv1sdk::ColumnDatum> valsIn;
valsIn.push_back(datum);
rc = getContext().getFunction()->nextValue(&getContext(), valsIn);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
bInterrupted = true;
string errStr = IDBErrorInfo::instance()->errorMsg(ERR_WF_UDANF_ERROR, getContext().getErrorMessage());
cerr << errStr << endl;
throw IDBExcept(errStr, ERR_WF_UDANF_ERROR);
}
}
rc = getContext().getFunction()->evaluate(&getContext(), fValOut);
if (rc == mcsv1sdk::mcsv1_UDAF::ERROR)
{
bInterrupted = true;
string errStr = IDBErrorInfo::instance()->errorMsg(ERR_WF_UDANF_ERROR, getContext().getErrorMessage());
cerr << errStr << endl;
throw IDBExcept(errStr, ERR_WF_UDANF_ERROR);
}
}
SetUDAFValue(fValOut, colOut, b, e, c);
fPrev = c;
}
template
boost::shared_ptr<WindowFunctionType> WF_udaf<int64_t>::makeFunction(int id, const string& name, int ct, mcsv1sdk::mcsv1Context& context);
} //namespace
// vim:ts=4 sw=4:

77
utils/windowfunction/wf_udaf.h Executable file
View File

@ -0,0 +1,77 @@
/************************************************************************************
Copyright (C) 2017 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
*************************************************************************************/
#ifndef UTILS_WF_UDAF_H
#define UTILS_WF_UDAF_H
#include <set>
#include "windowfunctiontype.h"
#include "mcsv1_udaf.h"
namespace windowfunction
{
// A class to control the execution of User Define Analytic Functions (UDAnF)
// as defined by a specialization of mcsv1sdk::mcsv1_UDAF
// The template parameter is currently only used to support DISTINCT, as
// as that is done via a set<T>
template<typename T>
class WF_udaf : public WindowFunctionType
{
public:
WF_udaf(int id, const std::string& name, mcsv1sdk::mcsv1Context& context) :
WindowFunctionType(id, name), fUDAFContext(context), fDistinct(false), bHasDropValue(true) {}
WF_udaf(WF_udaf& rhs);
// pure virtual in base
void operator()(int64_t b, int64_t e, int64_t c);
WindowFunctionType* clone() const;
void resetData();
void parseParms(const std::vector<execplan::SRCP>&);
virtual bool dropValues(int64_t, int64_t);
mcsv1sdk::mcsv1Context& getContext() {return fUDAFContext;}
bool getInterrupted() {return bInterrupted;}
bool getInterruptedPtr() {return &bInterrupted;}
bool getDistinct() {return fDistinct;}
protected:
void SetUDAFValue(static_any::any& valOut, int64_t colOut, int64_t b, int64_t e, int64_t c);
mcsv1sdk::mcsv1Context fUDAFContext; // The UDAF context
bool bInterrupted; // Shared by all the threads
bool fDistinct;
bool bRespectNulls; // respect null | ignore null
bool bHasDropValue; // Set to false when we discover the UDAnF doesn't implement dropValue.
std::set<T> fSet; // To hold distinct values
static_any::any fValOut; // The return value
public:
static boost::shared_ptr<WindowFunctionType> makeFunction(int id, const string& name,
int ct, mcsv1sdk::mcsv1Context& context);
};
} // namespace
#endif // UTILS_WF_UDAF_H
// vim:ts=4 sw=4:

30
utils/windowfunction/windowfunction.cpp Normal file → Executable file
View File

@ -163,11 +163,35 @@ void WindowFunction::operator()()
} }
else else
{ {
pair<int64_t, int64_t> w;
pair<int64_t, int64_t> prevFrame;
int64_t b, e;
bool firstTime = true;
for (int64_t i = begin; i <= end && !fStep->cancelled(); i++) for (int64_t i = begin; i <= end && !fStep->cancelled(); i++)
{ {
pair<int64_t, int64_t> w = fFrame->getWindow(begin, end, i); w = fFrame->getWindow(begin, end, i);
fFunctionType->resetData(); b = w.first;
fFunctionType->operator()(w.first, w.second, i); e = w.second;
if (firstTime)
{
prevFrame = w;
}
// UDAnF functions may have a dropValue function implemented.
// If they do, we can optimize by calling dropValue() for those
// values leaving the window and nextValue for those entering, rather
// than a resetData() and then iterating over the entire window.
// Built-in functions may have this functionality added in the future.
if (fFunctionType->dropValues(prevFrame.first, w.first))
{
b = firstTime ? w.first : prevFrame.second+1;
}
else
{
fFunctionType->resetData();
}
fFunctionType->operator()(b, e, i);
prevFrame = w;
firstTime = false;
} }
} }
} }

63
utils/windowfunction/windowfunctiontype.cpp Normal file → Executable file
View File

@ -58,6 +58,7 @@ using namespace joblist;
#include "wf_row_number.h" #include "wf_row_number.h"
#include "wf_stats.h" #include "wf_stats.h"
#include "wf_sum_avg.h" #include "wf_sum_avg.h"
#include "wf_udaf.h"
namespace windowfunction namespace windowfunction
{ {
@ -137,13 +138,16 @@ map<string, int> WindowFunctionType::windowFunctionId = assign::map_list_of
(string("REGR_SXX"), WF__REGR_SXX) (string("REGR_SXX"), WF__REGR_SXX)
(string("REGR_SXY"), WF__REGR_SXY) (string("REGR_SXY"), WF__REGR_SXY)
(string("REGR_SYY"), WF__REGR_SYY) (string("REGR_SYY"), WF__REGR_SYY)
(string("UDAF_FUNC"), WF__UDAF)
; ;
boost::shared_ptr<WindowFunctionType> boost::shared_ptr<WindowFunctionType>
WindowFunctionType::makeWindowFunction(const string& name, int ct) WindowFunctionType::makeWindowFunction(const string& name, int ct, WindowFunctionColumn* wc)
{ {
boost::shared_ptr<WindowFunctionType> af; boost::shared_ptr<WindowFunctionType> af;
int functionId = windowFunctionId[algorithm::to_upper_copy(name)]; int functionId = windowFunctionId[algorithm::to_upper_copy(name)];
// The template parameters here are dummies to execute the static makeFunction
// which sets the real type based on ct.
switch (functionId) switch (functionId)
{ {
case WF__COUNT_ASTERISK: case WF__COUNT_ASTERISK:
@ -192,6 +196,9 @@ boost::shared_ptr<WindowFunctionType>
case WF__PERCENTILE_DISC: case WF__PERCENTILE_DISC:
af = WF_percentile<int64_t>::makeFunction(functionId, name, ct); af = WF_percentile<int64_t>::makeFunction(functionId, name, ct);
break; break;
case WF__UDAF:
af = WF_udaf<int64_t>::makeFunction(functionId, name, ct, wc->getUDAFContext());
break;
case WF__REGR_SLOPE: case WF__REGR_SLOPE:
case WF__REGR_INTERCEPT: case WF__REGR_INTERCEPT:
case WF__REGR_COUNT: case WF__REGR_COUNT:
@ -211,7 +218,6 @@ boost::shared_ptr<WindowFunctionType>
return af; return af;
} }
const string WindowFunctionType::toString() const const string WindowFunctionType::toString() const
{ {
ostringstream oss; ostringstream oss;
@ -223,77 +229,81 @@ const string WindowFunctionType::toString() const
return oss.str(); return oss.str();
} }
template<typename T> void WindowFunctionType::getValue(uint64_t i, T& t, CDT* cdt)
template<typename T> void WindowFunctionType::getValue(uint64_t i, T& t)
{ {
} }
template<> void WindowFunctionType::getValue<int64_t>(uint64_t i, int64_t& t, CDT* cdt)
template<> void WindowFunctionType::getValue<int64_t>(uint64_t i, int64_t& t)
{ {
t = fRow.getIntField(i); t = fRow.getIntField(i);
if (cdt)
{
*cdt = execplan::CalpontSystemCatalog::BIGINT;
}
} }
template<> void WindowFunctionType::getValue<uint64_t>(uint64_t i, uint64_t& t, CDT* cdt)
template<> void WindowFunctionType::getValue<uint64_t>(uint64_t i, uint64_t& t)
{ {
t = fRow.getUintField(i); t = fRow.getUintField(i);
if (cdt)
{
*cdt = execplan::CalpontSystemCatalog::UBIGINT;
}
} }
template<> void WindowFunctionType::getValue<double>(uint64_t i, double& t, CDT* cdt)
template<> void WindowFunctionType::getValue<double>(uint64_t i, double& t)
{ {
t = fRow.getDoubleField(i); t = fRow.getDoubleField(i);
if (cdt)
{
*cdt = execplan::CalpontSystemCatalog::DOUBLE;
}
} }
template<> void WindowFunctionType::getValue<float>(uint64_t i, float& t, CDT* cdt)
template<> void WindowFunctionType::getValue<float>(uint64_t i, float& t)
{ {
t = fRow.getFloatField(i); t = fRow.getFloatField(i);
if (cdt)
{
*cdt = execplan::CalpontSystemCatalog::FLOAT;
}
} }
template<> void WindowFunctionType::getValue<string>(uint64_t i, string& t, CDT* cdt)
template<> void WindowFunctionType::getValue<string>(uint64_t i, string& t)
{ {
t = fRow.getStringField(i); t = fRow.getStringField(i);
// By not setting cdt, we let it default to the column's type
} }
template<typename T> void WindowFunctionType::setValue(uint64_t i, T& t) template<typename T> void WindowFunctionType::setValue(uint64_t i, T& t)
{ {
} }
template<> void WindowFunctionType::setValue<int64_t>(uint64_t i, int64_t& t) template<> void WindowFunctionType::setValue<int64_t>(uint64_t i, int64_t& t)
{ {
fRow.setIntField(t, i); fRow.setIntField(t, i);
} }
template<> void WindowFunctionType::setValue<uint64_t>(uint64_t i, uint64_t& t) template<> void WindowFunctionType::setValue<uint64_t>(uint64_t i, uint64_t& t)
{ {
fRow.setUintField(t, i); fRow.setUintField(t, i);
} }
template<> void WindowFunctionType::setValue<double>(uint64_t i, double& t) template<> void WindowFunctionType::setValue<double>(uint64_t i, double& t)
{ {
fRow.setDoubleField(t, i); fRow.setDoubleField(t, i);
} }
template<> void WindowFunctionType::setValue<float>(uint64_t i, float& t) template<> void WindowFunctionType::setValue<float>(uint64_t i, float& t)
{ {
fRow.setFloatField(t, i); fRow.setFloatField(t, i);
} }
template<> void WindowFunctionType::setValue<string>(uint64_t i, string& t) template<> void WindowFunctionType::setValue<string>(uint64_t i, string& t)
{ {
fRow.setStringField(t, i); fRow.setStringField(t, i);
} }
template<typename T> template<typename T>
void WindowFunctionType::setValue(int ct, int64_t b, int64_t e, int64_t c, T* v) void WindowFunctionType::setValue(int ct, int64_t b, int64_t e, int64_t c, T* v)
{ {
@ -314,7 +324,6 @@ void WindowFunctionType::setValue(int ct, int64_t b, int64_t e, int64_t c, T* v)
} }
} }
template<typename T> template<typename T>
void WindowFunctionType::implicit2T(uint64_t i, T& t, int s) void WindowFunctionType::implicit2T(uint64_t i, T& t, int s)
{ {
@ -384,55 +393,47 @@ void WindowFunctionType::implicit2T(uint64_t i, T& t, int s)
} }
} }
template<> template<>
void WindowFunctionType::implicit2T<string>(uint64_t i, string& t, int) void WindowFunctionType::implicit2T<string>(uint64_t i, string& t, int)
{ {
t = fRow.getStringField(i); t = fRow.getStringField(i);
} }
template<typename T> template<typename T>
void WindowFunctionType::getConstValue(ConstantColumn* cc, T& t, bool& b) void WindowFunctionType::getConstValue(ConstantColumn* cc, T& t, bool& b)
{ {
} }
template<> template<>
void WindowFunctionType::getConstValue<int64_t>(ConstantColumn* cc, int64_t& t, bool& b) void WindowFunctionType::getConstValue<int64_t>(ConstantColumn* cc, int64_t& t, bool& b)
{ {
t = cc->getIntVal(fRow, b); t = cc->getIntVal(fRow, b);
} }
template<> template<>
void WindowFunctionType::getConstValue<uint64_t>(ConstantColumn* cc, uint64_t& t, bool& b) void WindowFunctionType::getConstValue<uint64_t>(ConstantColumn* cc, uint64_t& t, bool& b)
{ {
t = cc->getUintVal(fRow, b); t = cc->getUintVal(fRow, b);
} }
template<> template<>
void WindowFunctionType::getConstValue<double>(ConstantColumn* cc, double& t, bool& b) void WindowFunctionType::getConstValue<double>(ConstantColumn* cc, double& t, bool& b)
{ {
t = cc->getDoubleVal(fRow, b); t = cc->getDoubleVal(fRow, b);
} }
template<> template<>
void WindowFunctionType::getConstValue<float>(ConstantColumn* cc, float& t, bool& b) void WindowFunctionType::getConstValue<float>(ConstantColumn* cc, float& t, bool& b)
{ {
t = cc->getFloatVal(fRow, b); t = cc->getFloatVal(fRow, b);
} }
template<> template<>
void WindowFunctionType::getConstValue<string>(ConstantColumn* cc, string& t, bool& b) void WindowFunctionType::getConstValue<string>(ConstantColumn* cc, string& t, bool& b)
{ {
t = cc->getStrVal(fRow, b); t = cc->getStrVal(fRow, b);
} }
template void WindowFunctionType::implicit2T<int64_t>(uint64_t, int64_t&, int); template void WindowFunctionType::implicit2T<int64_t>(uint64_t, int64_t&, int);
template void WindowFunctionType::implicit2T<uint64_t>(uint64_t, uint64_t&, int); template void WindowFunctionType::implicit2T<uint64_t>(uint64_t, uint64_t&, int);
template void WindowFunctionType::implicit2T<float>(uint64_t, float&, int); template void WindowFunctionType::implicit2T<float>(uint64_t, float&, int);
@ -445,7 +446,6 @@ template void WindowFunctionType::setValue<double>(int, int64_t, int64_t, int64_
template void WindowFunctionType::setValue<string>(int, int64_t, int64_t, int64_t, string*); template void WindowFunctionType::setValue<string>(int, int64_t, int64_t, int64_t, string*);
void* WindowFunctionType::getNullValueByType(int ct, int pos) void* WindowFunctionType::getNullValueByType(int ct, int pos)
{ {
static uint64_t bigIntNull = joblist::BIGINTNULL; static uint64_t bigIntNull = joblist::BIGINTNULL;
@ -566,7 +566,6 @@ void* WindowFunctionType::getNullValueByType(int ct, int pos)
return v; return v;
} }
} //namespace } //namespace
// vim:ts=4 sw=4: // vim:ts=4 sw=4:

11
utils/windowfunction/windowfunctiontype.h Normal file → Executable file
View File

@ -98,8 +98,9 @@ const int WF__REGR_AVGY = 32;
const int WF__REGR_SXX = 33; const int WF__REGR_SXX = 33;
const int WF__REGR_SXY = 34; const int WF__REGR_SXY = 34;
const int WF__REGR_SYY = 35; const int WF__REGR_SYY = 35;
const int WF__UDAF = 36;
typedef execplan::CalpontSystemCatalog::ColDataType CDT;
/** @brief class WindowFunction /** @brief class WindowFunction
* *
@ -129,6 +130,10 @@ public:
// @brief virtual parseParms() // @brief virtual parseParms()
virtual void parseParms(const std::vector<execplan::SRCP>&) {} virtual void parseParms(const std::vector<execplan::SRCP>&) {}
// @brief virtual dropValues() For UDAnF functions
// return false if there's no dropValue() implemented in the function.
virtual bool dropValues(int64_t, int64_t) {return false;}
// @brief virtual display method // @brief virtual display method
virtual const std::string toString() const; virtual const std::string toString() const;
@ -148,14 +153,14 @@ public:
void peer(const boost::shared_ptr<ordering::EqualCompData>& p) { fPeer = p; } void peer(const boost::shared_ptr<ordering::EqualCompData>& p) { fPeer = p; }
void setCallback(joblist::WindowFunctionStep* step) { fStep = step; } void setCallback(joblist::WindowFunctionStep* step) { fStep = step; }
static boost::shared_ptr<WindowFunctionType> makeWindowFunction(const std::string&, int ct); static boost::shared_ptr<WindowFunctionType> makeWindowFunction(const std::string&, int ct, WindowFunctionColumn* wc);
protected: protected:
static std::map<std::string, int> windowFunctionId; static std::map<std::string, int> windowFunctionId;
// utility methods // utility methods
template<typename T> void getValue(uint64_t, T&); template<typename T> void getValue(uint64_t, T&, CDT* cdt = NULL);
template<typename T> void setValue(int, int64_t, int64_t, int64_t, T* = NULL); template<typename T> void setValue(int, int64_t, int64_t, int64_t, T* = NULL);
template<typename T> void setValue(uint64_t, T&); template<typename T> void setValue(uint64_t, T&);
template<typename T> void implicit2T(uint64_t, T&, int); template<typename T> void implicit2T(uint64_t, T&, int);

2
writeengine/splitter/we_splitterapp.cpp Normal file → Executable file
View File

@ -448,8 +448,6 @@ void WESplitterApp::invokeCpimport()
std::vector<char*> Cmds; std::vector<char*> Cmds;
char* ptr = 0;
std::istringstream ss(aCmdLineStr); std::istringstream ss(aCmdLineStr);
std::string arg; std::string arg;
std::vector<std::string> v2(20, ""); std::vector<std::string> v2(20, "");