[TRAFODION-3110] Refactor LOB access to use the new implementation of HdfsClient
The CQD USE_LIBHDFS is now made effective for updateLOB and extract LOB utility commands Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/ee44ad98 Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/ee44ad98 Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/ee44ad98 Branch: refs/heads/master Commit: ee44ad98bc6c8857d0147e547c3902ad7d0c34cc Parents: 457e171 Author: selvaganesang <[email protected]> Authored: Wed Jun 27 20:41:24 2018 +0000 Committer: selvaganesang <[email protected]> Committed: Wed Jun 27 20:41:24 2018 +0000 ---------------------------------------------------------------------- core/sql/executor/ExExeUtilLoad.cpp | 19 +++++-------------- core/sql/exp/ExpLOBaccess.cpp | 3 ++- core/sql/generator/GenRelExeUtil.cpp | 10 ++++++---- 3 files changed, 13 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/ee44ad98/core/sql/executor/ExExeUtilLoad.cpp ---------------------------------------------------------------------- diff --git a/core/sql/executor/ExExeUtilLoad.cpp b/core/sql/executor/ExExeUtilLoad.cpp index bf4e1a5..960c31f 100644 --- a/core/sql/executor/ExExeUtilLoad.cpp +++ b/core/sql/executor/ExExeUtilLoad.cpp @@ -68,6 +68,7 @@ using std::ofstream; #include "ExpHbaseInterface.h" #include "ExHbaseAccess.h" #include "ExpErrorEnums.h" +#include "ExpLOBaccess.h" #include "HdfsClient_JNI.h" /////////////////////////////////////////////////////////////////// @@ -2545,11 +2546,7 @@ ExExeUtilLobExtractTcb::ExExeUtilLobExtractTcb requestTag_ = -1; lobLoc_[0] = '\0'; - exLobGlobals_ = NULL; - - ExpLOBinterfaceInit(exLobGlobals_,(NAHeap *)glob->getDefaultHeap(),currContext,TRUE, - lobTdb().getLobHdfsServer(), - lobTdb().getLobHdfsPort()); + exLobGlobals_ = ExpLOBoper::initLOBglobal((NAHeap *)glob->getDefaultHeap(), currContext, exe_util_tdb.useLibHdfs()); } void ExExeUtilLobExtractTcb::freeResources() @@ -2584,8 +2581,7 @@ void ExExeUtilLobExtractTcb::freeResources() lobDataLen_, lobData_, 3, // close 0); // open type not applicable - - ExpLOBinterfaceCleanup(exLobGlobals_); + ExpLOBoper::deleteLOBglobal(exLobGlobals_, (NAHeap *)(NAHeap *)getGlobals()->getDefaultHeap()); exLobGlobals_ = NULL; } @@ -3324,9 +3320,7 @@ ExExeUtilLobUpdateTcb::ExExeUtilLobUpdateTcb lobHandle_[0] = '\0'; exLobGlobals_=NULL; memset(lobLockId_,'\0',LOB_LOCK_ID_SIZE); - ExpLOBinterfaceInit(exLobGlobals_,(NAHeap *)glob->getDefaultHeap(),currContext,TRUE, - lobTdb().getLobHdfsServer(), - lobTdb().getLobHdfsPort()); + exLobGlobals_ = ExpLOBoper::initLOBglobal((NAHeap *)glob->getDefaultHeap(), currContext, exe_util_lobupdate_tdb.useLibHdfs()); } ExExeUtilLobUpdateTcb::~ExExeUtilLobUpdateTcb() @@ -3336,10 +3330,7 @@ ExExeUtilLobUpdateTcb::~ExExeUtilLobUpdateTcb() void ExExeUtilLobUpdateTcb::freeResources() { - ContextCli *currContext = - getGlobals()->castToExExeStmtGlobals()->castToExMasterStmtGlobals()-> - getStatement()->getContext(); - ExpLOBinterfaceCleanup(exLobGlobals_); + ExpLOBoper::deleteLOBglobal(exLobGlobals_, (NAHeap *)getGlobals()->getDefaultHeap()); exLobGlobals_ = NULL; } http://git-wip-us.apache.org/repos/asf/trafodion/blob/ee44ad98/core/sql/exp/ExpLOBaccess.cpp ---------------------------------------------------------------------- diff --git a/core/sql/exp/ExpLOBaccess.cpp b/core/sql/exp/ExpLOBaccess.cpp index 1defb3f..a24018a 100644 --- a/core/sql/exp/ExpLOBaccess.cpp +++ b/core/sql/exp/ExpLOBaccess.cpp @@ -1784,7 +1784,8 @@ Ex_Lob_Error ExLob::allocateDesc(ULng32 size, Int64 &descNum, Int64 &dataOffset, if (! useLibHdfs_) { if (size == 0) { - hdfsClientRetcode = HdfsClient::hdfsDeletePath(lobDataFile_.data()); + // Delete and Create the Hdfs file by passing overwrite to TRUE + hdfsClientRetcode = hdfsClient_->hdfsCreate(lobDataFile_.data(), TRUE, FALSE); if (hdfsClientRetcode != HDFS_CLIENT_OK) return LOB_DATA_FILE_WRITE_ERROR; else { http://git-wip-us.apache.org/repos/asf/trafodion/blob/ee44ad98/core/sql/generator/GenRelExeUtil.cpp ---------------------------------------------------------------------- diff --git a/core/sql/generator/GenRelExeUtil.cpp b/core/sql/generator/GenRelExeUtil.cpp index dbbbf56..1caa440 100644 --- a/core/sql/generator/GenRelExeUtil.cpp +++ b/core/sql/generator/GenRelExeUtil.cpp @@ -3646,6 +3646,8 @@ short ExeUtilLobInfo::codeGen(Generator * generator) (queue_index)64, 4, 64000); + + exe_util_tdb->setUseLibHdfs(CmpCommon::getDefault(USE_LIBHDFS) == DF_ON); generator->initTdbFields(exe_util_tdb); if(!generator->explainDisabled()) { @@ -3659,7 +3661,6 @@ short ExeUtilLobInfo::codeGen(Generator * generator) // users should not start a transaction. generator->setTransactionFlag(0); - return 0; } @@ -4076,7 +4077,8 @@ short ExeUtilLobExtract::codeGen(Generator * generator) 2, 32000); -if (handleInStringFormat_) + exe_util_tdb->setUseLibHdfs(CmpCommon::getDefault(USE_LIBHDFS) == DF_ON); + if (handleInStringFormat_) exe_util_tdb->setHandleInStringFormat(TRUE); if (handle_ == NULL) @@ -4267,8 +4269,7 @@ short ExeUtilLobUpdate::codeGen(Generator * generator) 2, 32000); - - + exe_util_lobupdate_tdb->setUseLibHdfs(CmpCommon::getDefault(USE_LIBHDFS) == DF_ON); if (updateAction_ == UpdateActionType::ERROR_IF_EXISTS_) exe_util_lobupdate_tdb->setErrorIfExists(TRUE); else @@ -4444,6 +4445,7 @@ short ExeUtilLobShowddl::codeGen(Generator * generator) 2, 32000); + exe_util_tdb->setUseLibHdfs(CmpCommon::getDefault(USE_LIBHDFS) == DF_ON); generator->initTdbFields(exe_util_tdb); if(!generator->explainDisabled()) {
