Repository: trafodion
Updated Branches:
  refs/heads/master f06ea68bb -> 8bd408bdf


Removed usage of system new and moved allocation of LOB globals to be derived 
from a heap. Moved xLObHdfsRequest also to be derived from a heap


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/0da83d52
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/0da83d52
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/0da83d52

Branch: refs/heads/master
Commit: 0da83d525d7e25b546181b0360cf3f3d9d422721
Parents: 2e30aad
Author: Sandhya Sundaresan <[email protected]>
Authored: Thu Jan 18 16:17:41 2018 +0000
Committer: Sandhya Sundaresan <[email protected]>
Committed: Thu Jan 18 16:17:41 2018 +0000

----------------------------------------------------------------------
 core/sql/cli/Cli.cpp                  | 62 ++++++++++++++++++++++++++----
 core/sql/cli/Statement.cpp            |  4 +-
 core/sql/executor/ExExeUtilLoad.cpp   |  5 +--
 core/sql/executor/ExExeUtilMisc.cpp   |  2 +-
 core/sql/executor/ExFastTransport.cpp |  2 +-
 core/sql/executor/ExHdfsScan.cpp      |  2 +-
 core/sql/executor/ex_globals.cpp      |  4 ++
 core/sql/executor/ex_globals.h        |  2 +-
 core/sql/exp/ExpLOB.cpp               | 43 +++++++--------------
 core/sql/exp/ExpLOB.h                 |  4 +-
 core/sql/exp/ExpLOBaccess.cpp         | 62 ++++++++++++++++++++++--------
 core/sql/exp/ExpLOBaccess.h           |  4 +-
 core/sql/exp/ExpLOBinterface.cpp      | 17 ++++----
 core/sql/exp/ExpLOBinterface.h        |  2 +-
 14 files changed, 139 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/cli/Cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp
index be9181a..825d2a7 100644
--- a/core/sql/cli/Cli.cpp
+++ b/core/sql/cli/Cli.cpp
@@ -9542,7 +9542,7 @@ Lng32 SQLCLI_LOBddlInterface
  
 {
   Lng32 cliRC = 0;
-
+  ExLobGlobals *exLobGlob = NULL;
   ContextCli   & currContext = *(cliGlobals->currContext());
   ComDiagsArea & diags       = currContext.diags();
 
@@ -9611,12 +9611,28 @@ Lng32 SQLCLI_LOBddlInterface
            
          } // for
 
+        //Initialize LOB interface 
+        
+        Int32 rc= 
ExpLOBoper::initLOBglobal(exLobGlob,currContext.exHeap(),&currContext,hdfsServer,hdfsPort);
+        if (rc)
+          {
+            {
+              cliRC = 0;
+               ComDiagsArea * da = &diags;
+               ExRaiseSqlError(currContext.exHeap(), &da, 
+                           (ExeErrorCode)(8442), NULL, &cliRC    , 
+                           &rc, NULL, (char*)"ExpLOBInterfaceCreate",
 
+                           getLobErrStr(rc));
+               goto error_return;
+             }
+          }
+          
        for (Lng32 i = 0; i < numLOBs; i++)
          {
            // create lob data tables
-           Lng32 rc = ExpLOBoper::createLOB
-             (NULL, &currContext,currContext.exHeap(),
+              rc = ExpLOBoper::createLOB
+             (exLobGlob, &currContext,
               lobLocList[i],  hdfsPort,hdfsServer,
               objectUID, lobNumList[i],lobMaxSize);
            
@@ -9726,10 +9742,26 @@ Lng32 SQLCLI_LOBddlInterface
         //lob data files.  Note that if there is an error in the drop of the 
         //descriptor tables above , the transaction will restore each of the 
         //above tables . 
+        //Initialize LOB interface 
+       
+        Int32 rc= 
ExpLOBoper::initLOBglobal(exLobGlob,currContext.exHeap(),&currContext,hdfsServer,hdfsPort);
+        if (rc)
+          {
+            {
+              cliRC = 0;
+               ComDiagsArea * da = &diags;
+               ExRaiseSqlError(currContext.exHeap(), &da, 
+                           (ExeErrorCode)(8442), NULL, &cliRC    , 
+                           &rc, NULL, (char*)"ExpLOBInterfaceCreate",
+
+                           getLobErrStr(rc));
+               goto error_return;
+             }
+          }
         for (Lng32 i = 0; i < numLOBs; i++)
          {
-           Lng32 rc = ExpLOBoper::dropLOB
-             (NULL, currContext.exHeap(),&currContext,
+             rc = ExpLOBoper::dropLOB
+             (exLobGlob,&currContext,
               lobLocList[i],hdfsPort,hdfsServer,
               objectUID, lobNumList[i]);
             // Ignore 'not found' error from hdfs file deletes until this is 
made transactional just like Hbase tables are.
@@ -9765,12 +9797,27 @@ Lng32 SQLCLI_LOBddlInterface
            
            goto error_return;
          }
-       
+       //Initialize LOB interface 
+        
+        Int32 rc= 
ExpLOBoper::initLOBglobal(exLobGlob,currContext.exHeap(),&currContext,hdfsServer,hdfsPort);
+        if (rc)
+          {
+            {
+              cliRC = 0;
+               ComDiagsArea * da = &diags;
+               ExRaiseSqlError(currContext.exHeap(), &da, 
+                           (ExeErrorCode)(8442), NULL, &cliRC    , 
+                           &rc, NULL, (char*)"ExpLOBInterfaceCreate",
+
+                           getLobErrStr(rc));
+               goto error_return;
+             }
+          }
        // drop descriptor table
        for (Lng32 i = 0; i < numLOBs; i++)
          {
            Lng32 rc = ExpLOBoper::dropLOB
-             (NULL, currContext.exHeap(),&currContext,
+             (exLobGlob,&currContext,
               lobLocList[i],hdfsPort, hdfsServer,
               objectUID, lobNumList[i]);
            
@@ -9919,6 +9966,7 @@ Lng32 SQLCLI_LOBddlInterface
     } // switch
 
  error_return:
+  ExpLOBinterfaceCleanup(exLobGlob);
   NADELETEBASIC(query, currContext.exHeap());
   NADELETEBASIC(hdfsServer,currContext.exHeap());
   delete cliInterface;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/cli/Statement.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Statement.cpp b/core/sql/cli/Statement.cpp
index 6d847f0..8e15d71 100644
--- a/core/sql/cli/Statement.cpp
+++ b/core/sql/cli/Statement.cpp
@@ -2136,12 +2136,12 @@ RETCODE 
Statement::doQuerySimilarityCheck(TrafQuerySimilarityInfo * qsi,
     } // for
 
   if (lobGlob)
-    ExpLOBinterfaceCleanup(lobGlob, &heap_);
+    ExpLOBinterfaceCleanup(lobGlob);
   return SUCCESS;
   
  error_return:
   if (lobGlob)
-    ExpLOBinterfaceCleanup(lobGlob, &heap_);
+    ExpLOBinterfaceCleanup(lobGlob);
   return ERROR;
 }
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/executor/ExExeUtilLoad.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilLoad.cpp 
b/core/sql/executor/ExExeUtilLoad.cpp
index ab1580c..5d253cd 100644
--- a/core/sql/executor/ExExeUtilLoad.cpp
+++ b/core/sql/executor/ExExeUtilLoad.cpp
@@ -2782,8 +2782,7 @@ void ExExeUtilLobExtractTcb::freeResources()
                0); // open type not applicable
 
     
-  ExpLOBinterfaceCleanup
-    (exLobGlobals_, currContext->exHeap());
+  ExpLOBinterfaceCleanup(exLobGlobals_);
   exLobGlobals_ = NULL;
 }
 
@@ -3505,7 +3504,7 @@ void ExExeUtilLobUpdateTcb::freeResources()
  ContextCli *currContext =
     getGlobals()->castToExExeStmtGlobals()->castToExMasterStmtGlobals()->
     getStatement()->getContext();
- ExpLOBinterfaceCleanup(exLobGlobals_, currContext->exHeap());
+ ExpLOBinterfaceCleanup(exLobGlobals_);
  exLobGlobals_ = NULL;
 }
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/executor/ExExeUtilMisc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilMisc.cpp 
b/core/sql/executor/ExExeUtilMisc.cpp
index 2ed95fb..ebf741a 100644
--- a/core/sql/executor/ExExeUtilMisc.cpp
+++ b/core/sql/executor/ExExeUtilMisc.cpp
@@ -2270,7 +2270,7 @@ void ExExeUtilHiveTruncateTcb::freeResources()
       hiveClient->executeHiveSQL(hiveDropDDL);
     }
   if (lobGlob_) {
-    ExpLOBinterfaceCleanup(lobGlob_, (NAHeap *)getGlobals()->getDefaultHeap());
+    ExpLOBinterfaceCleanup(lobGlob_);
     lobGlob_ = NULL;
   }
 }

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/executor/ExFastTransport.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExFastTransport.cpp 
b/core/sql/executor/ExFastTransport.cpp
index b1166bf..4d77319 100644
--- a/core/sql/executor/ExFastTransport.cpp
+++ b/core/sql/executor/ExFastTransport.cpp
@@ -465,7 +465,7 @@ ExHdfsFastExtractTcb::~ExHdfsFastExtractTcb()
 {
 
   if (lobGlob_) {
-    ExpLOBinterfaceCleanup(lobGlob_, (NAHeap *)getGlobals()->getDefaultHeap());
+    ExpLOBinterfaceCleanup(lobGlob_);
     lobGlob_ = NULL;
   }
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/executor/ExHdfsScan.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExHdfsScan.cpp b/core/sql/executor/ExHdfsScan.cpp
index f49ad06..7dd933b 100644
--- a/core/sql/executor/ExHdfsScan.cpp
+++ b/core/sql/executor/ExHdfsScan.cpp
@@ -280,7 +280,7 @@ void ExHdfsScanTcb::freeResources()
   }
   deallocateRuntimeRanges();
   if (lobGlob_) { 
-     ExpLOBinterfaceCleanup(lobGlob_, (NAHeap 
*)getGlobals()->getDefaultHeap());
+     ExpLOBinterfaceCleanup(lobGlob_);
      lobGlob_ = NULL;
   }
 }

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/executor/ex_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_globals.cpp b/core/sql/executor/ex_globals.cpp
index 0c81fdc..3d8bb62 100644
--- a/core/sql/executor/ex_globals.cpp
+++ b/core/sql/executor/ex_globals.cpp
@@ -45,6 +45,7 @@
 #include "Globals.h"
 #include "SqlStats.h"
 #include "ExpLOB.h"
+#include "ExpLOBaccess.h"
 
 ex_globals::ex_globals(short num_temps,
                       short create_gui_sched,
@@ -135,6 +136,9 @@ void ex_globals::deleteMe(NABoolean fatalError)
   statsArea_ = NULL;
   cleanupTcbs();
   tcbList_.deallocate();
+  ExpLOBinterfaceCleanup(exLobGlobals_);
+  exLobGlobals_ = NULL;
+
 }
 
 void ex_globals::deleteMemory(void *mem)

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/executor/ex_globals.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ex_globals.h b/core/sql/executor/ex_globals.h
index eeed8df..9edc328 100644
--- a/core/sql/executor/ex_globals.h
+++ b/core/sql/executor/ex_globals.h
@@ -267,7 +267,7 @@ private:
 
   // pool shared by among PAs under PAPA
   sql_buffer_pool *sharedPool_;
-  ExLobGlobals * exLobGlobals_;
+  ExLobGlobals *exLobGlobals_;
 
   // pointer passed to interface methods that store and retrieve lob data
   // from flatfile or hdfs filesystem.

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/exp/ExpLOB.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOB.cpp b/core/sql/exp/ExpLOB.cpp
index c4336f4..5d3bf05 100644
--- a/core/sql/exp/ExpLOB.cpp
+++ b/core/sql/exp/ExpLOB.cpp
@@ -56,10 +56,10 @@
 #include "ex_god.h"
 
 
-Lng32 ExpLOBoper::initLOBglobal(ExLobGlobals *& exLobGlobals, NAHeap *lobHeap, 
ContextCli *currContext, char *hdfsServer ,Int32 port)
+Lng32 ExpLOBoper::initLOBglobal(ExLobGlobals *& exLobGlobals, NAHeap 
*parentHeap, ContextCli *currContext, char *hdfsServer ,Int32 port)
 {
   // call ExeLOBinterface to initialize lob globals
-  ExpLOBinterfaceInit(exLobGlobals, lobHeap,currContext,FALSE, hdfsServer,  
port);
+  ExpLOBinterfaceInit(exLobGlobals, parentHeap,currContext,FALSE, hdfsServer,  
port);
 
   return 0;
 }
@@ -151,7 +151,7 @@ char * ExpLOBoper::ExpGetLOBMDName(Lng32 schNameLen, char * 
schName,
 
   return outBuf;
 }
-Lng32 ExpLOBoper::createLOB(ExLobGlobals * exLobGlob, ContextCli *currContext, 
NAHeap * lobHeap, 
+Lng32 ExpLOBoper::createLOB(ExLobGlobals * exLobGlob, ContextCli *currContext, 
                            char * lobLoc,Int32 hdfsPort,char *hdfsServer,
                            Int64 uid, Lng32 num, Int64 lobMaxSize )
 {
@@ -162,20 +162,11 @@ Lng32 ExpLOBoper::createLOB(ExLobGlobals * exLobGlob, 
ContextCli *currContext, N
     return -1;
 
   Lng32 rc = 0;
-  void * exLobGlobL = NULL;
+  
   // Call ExeLOBinterface to create the LOB
-  if (exLobGlob == NULL)
-    {
-      rc = initLOBglobal(exLobGlob, lobHeap,currContext,hdfsServer,hdfsPort);
-      if (rc)
-       return rc;
-    }
-  else
-    exLobGlobL = exLobGlob;
 
   rc = ExpLOBinterfaceCreate(exLobGlob, lobName, lobLoc, 
Lob_HDFS_File,hdfsServer,lobMaxSize, hdfsPort);
-  if (exLobGlob == NULL)
-     ExpLOBinterfaceCleanup(exLobGlob, lobHeap);
+  
   return rc;
 }
 void ExpLOBoper::calculateNewOffsets(ExLobInMemoryDescChunksEntry *dcArray, 
Lng32 numEntries)
@@ -233,7 +224,7 @@ Lng32 ExpLOBoper::compactLobDataFile(ExLobGlobals 
*exLobGlob,ExLobInMemoryDescCh
   rc = ExpLOBinterfacePerformGC(exLobGlobL,tgtLobName, (void *)dcArray, 
numEntries,hdfsServer,hdfsPort,lobLoc,lobMaxChunkMemSize);
   
   if (exLobGlob == NULL)
-     ExpLOBinterfaceCleanup(exLobGlobL, lobHeap);
+     ExpLOBinterfaceCleanup(exLobGlobL);
   return rc;
 }
 
@@ -251,7 +242,7 @@ Int32 ExpLOBoper::restoreLobDataFile(ExLobGlobals 
*exLobGlob, char *lobName, NAH
     exLobGlobL = exLobGlob;
   rc = 
ExpLOBinterfaceRestoreLobDataFile(exLobGlobL,hdfsServer,hdfsPort,lobLoc,lobName);
   if (exLobGlob == NULL)
-     ExpLOBinterfaceCleanup(exLobGlobL, lobHeap);
+     ExpLOBinterfaceCleanup(exLobGlobL);
   return rc;
 
 }
@@ -270,12 +261,12 @@ Int32 ExpLOBoper::purgeBackupLobDataFile(ExLobGlobals 
*exLobGlob,char *lobName,
     exLobGlobL = exLobGlob;
   rc = ExpLOBinterfacePurgeBackupLobDataFile(exLobGlobL,(char 
*)hdfsServer,hdfsPort,lobLoc,lobName);
   if (exLobGlob == NULL)
-     ExpLOBinterfaceCleanup(exLobGlobL, lobHeap);
+     ExpLOBinterfaceCleanup(exLobGlobL);
   return rc;
 }
 
 
-Lng32 ExpLOBoper::dropLOB(ExLobGlobals * exLobGlob, NAHeap * lobHeap, 
ContextCli *currContext,
+Lng32 ExpLOBoper::dropLOB(ExLobGlobals * exLobGlob, ContextCli *currContext,
                          char * lobLoc,Int32 hdfsPort, char *hdfsServer,
                          Int64 uid, Lng32 num)
 {
@@ -286,20 +277,12 @@ Lng32 ExpLOBoper::dropLOB(ExLobGlobals * exLobGlob, 
NAHeap * lobHeap, ContextCli
     return -1;
 
   Lng32 rc = 0;
-  ExLobGlobals * exLobGlobL = NULL;
+ 
   // Call ExeLOBinterface to create the LOB
-  if (exLobGlob == NULL)
-    {
-      rc = initLOBglobal(exLobGlobL, lobHeap,currContext,hdfsServer,hdfsPort);
-      if (rc)
-       return rc;
-    }
-  else
-    exLobGlobL = exLobGlob;
+ 
   // Call ExeLOBinterface to drop the LOB
-  rc = ExpLOBinterfaceDrop(exLobGlobL,hdfsServer, hdfsPort, lobName, lobLoc);
-  if (exLobGlob == NULL)
-     ExpLOBinterfaceCleanup(exLobGlobL, lobHeap);
+  rc = ExpLOBinterfaceDrop(exLobGlob,hdfsServer, hdfsPort, lobName, lobLoc);
+  
   return rc;
 }
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/exp/ExpLOB.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOB.h b/core/sql/exp/ExpLOB.h
index f8a40cd..9c39876 100644
--- a/core/sql/exp/ExpLOB.h
+++ b/core/sql/exp/ExpLOB.h
@@ -124,11 +124,11 @@ public:
   static Int32 restoreLobDataFile(ExLobGlobals *lobGlob, char *lobName, NAHeap 
*lobHeap, ContextCli *currContext,char *hdfsServer, Int32 hdfsPort,char 
*lobLocation );
   static Int32 purgeBackupLobDataFile(ExLobGlobals *lobGlob,char *lobName, 
NAHeap *lobHeap, ContextCli *currContext, char *hdfsServer, Int32 hdfsPort, 
char *lobLocation);
 
-  static Lng32 createLOB(ExLobGlobals * lobGlob, ContextCli 
*currContext,NAHeap * lobHeap,
+  static Lng32 createLOB(ExLobGlobals * lobGlob, ContextCli *currContext,
                         char * lobLoc, Int32 hdfsPort, char *hdfsServer,
                         Int64 uid, Lng32 lobNum, Int64 lobMAxSize);
 
-  static Lng32 dropLOB(ExLobGlobals * lobGlob, NAHeap *lobHeap, ContextCli 
*currContext, 
+  static Lng32 dropLOB(ExLobGlobals * lobGlob, ContextCli *currContext, 
                       char * lobLoc,Int32 hdfsPort, char *hdfsServer,
                       Int64 uid, Lng32 lobNum);
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/exp/ExpLOBaccess.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBaccess.cpp b/core/sql/exp/ExpLOBaccess.cpp
index 58febe9..6b13f86 100644
--- a/core/sql/exp/ExpLOBaccess.cpp
+++ b/core/sql/exp/ExpLOBaccess.cpp
@@ -2566,8 +2566,8 @@ Ex_Lob_Error ExLobsOper (
     {
       if ((operation == Lob_Init))
        {
-          
-          globPtr = new ExLobGlobals();
+          NAHeap *lobHeap = (NAHeap *)blackBox;
+          globPtr = new (lobHeap) ExLobGlobals(lobHeap);
          if (globPtr == NULL) 
            return LOB_INIT_ERROR;
 
@@ -2877,7 +2877,7 @@ Ex_Lob_Error ExLobsOper (
       err = lobPtr->purgeLob();
       it = lobMap->find(string(lobName));
       lobMap->erase(it);
-      delete lobPtr;
+      NADELETE(lobPtr, ExLob,lobGlobals->getHeap()) ;
       lobPtr = NULL;
       if (err != LOB_OPER_OK)           
         lobDebugInfo("purgeLob failed ",err,__LINE__,lobGlobals->lobTrace_);
@@ -2887,7 +2887,7 @@ Ex_Lob_Error ExLobsOper (
       err = lobPtr->purgeLob();
       it = lobMap->find(string(lobName));
       lobMap->erase(it);
-      delete lobPtr;
+      NADELETE(lobPtr, ExLob,lobGlobals->getHeap()) ;
       lobPtr = NULL;
       if (err != LOB_OPER_OK)           
         lobDebugInfo("purgeLob failed ",err,__LINE__,lobGlobals->lobTrace_);
@@ -2925,7 +2925,7 @@ Ex_Lob_Error ExLobsOper (
       break;
 
     case Lob_Cleanup:
-        delete lobGlobals;
+        NADELETE(lobGlobals,ExLobGlobals, lobGlobals->getHeap());
         break;
      
     case Lob_PerformGC:
@@ -3393,14 +3393,14 @@ Ex_Lob_Error ExLob::sendReqToLobServer()
 // ExLobGlobals definitions
 ///////////////////////////////////////////////////////////////////////////////
 
-ExLobGlobals::ExLobGlobals() :
+ExLobGlobals::ExLobGlobals(NAHeap *lobHeap) :
     lobMap_(NULL), 
     fs_(NULL),
     isCliInitialized_(FALSE),
     threadTraceFile_(NULL),
     lobTrace_(FALSE),
     numWorkerThreads_(0),
-    heap_(NULL)
+    heap_(lobHeap)
 {
   //initialize the log file
   if (getenv("TRACE_HDFS_THREAD_ACTIONS"))
@@ -3418,9 +3418,7 @@ ExLobGlobals::~ExLobGlobals()
     ExLobCursor::bufferList_t::iterator c_it;
     ExLobCursorBuffer *buf = NULL;
 
-    preOpenListLock_.lock();
-    preOpenList_.clear();
-    preOpenListLock_.unlock();
+   
 
     if (numWorkerThreads_ > 0) { 
        for (int i=0; numWorkerThreads_-i > 0 && i < NUM_WORKER_THREADS; i++) {
@@ -3442,9 +3440,37 @@ ExLobGlobals::~ExLobGlobals()
     //Free the preOpenList AFTER the worker threads have left to avoid the 
     //case where a slow worker thread is still processing a preOpen and 
     //may access the preOpenList.
+  
+   
     preOpenListLock_.lock();
-    preOpenList_.clear();
+    ExLobPreOpen *po = NULL;
+    preOpenList_t::iterator p_it;
+    p_it = preOpenList_.begin();
+    while (p_it != preOpenList_.end()) 
+      {
+        po = *p_it;
+        NADELETE(po,ExLobPreOpen,heap_);
+        p_it = preOpenList_.erase(p_it);
+      }
+       
+        
     preOpenListLock_.unlock();
+        
+      
+    //Free the request list 
+    ExLobHdfsRequest *request;
+    reqList_t::iterator it;
+   
+    reqQueueLock_.lock();
+    it = reqQueue_.begin();
+    while (it != reqQueue_.end())
+      {
+        request = *it;
+        NADELETE(request,ExLobHdfsRequest,heap_);
+        it = reqQueue_.erase(it);
+      }       
+    reqQueueLock_.unlock();
+      
     // Free the post fetch bugf list AFTER the worker threads have left to 
     // avoid slow worker thread being stuck and master deallocating these 
     // buffers and not consuming the buffers which could cause a  lock.
@@ -3463,7 +3489,10 @@ ExLobGlobals::~ExLobGlobals()
     //delete the lobMap AFTER the worker threads have finished their pending 
     //work since they may still be using an objetc that was fetched off the 
lobMap_
     if (lobMap_) 
-      delete lobMap_;
+      {
+        NADELETE(lobMap_,lobMap_t,heap_);
+        lobMap_ = NULL;
+      }
     
     //msg_mon_close_process(&serverPhandle);
     if (threadTraceFile_)
@@ -3617,8 +3646,8 @@ Ex_Lob_Error 
ExLobGlobals::enqueueRequest(ExLobHdfsRequest *request)
 }
 
 Ex_Lob_Error ExLobGlobals::enqueuePrefetchRequest(ExLob *lobPtr, ExLobCursor 
*cursor)
-{// Leaving this allocated from system heap. Since this class contains hdfsFS 
unable to derive from LOB heap
-  ExLobHdfsRequest *request = new  ExLobHdfsRequest(Lob_Hdfs_Cursor_Prefetch, 
lobPtr, cursor);
+{
+  ExLobHdfsRequest *request = new  (heap_) 
ExLobHdfsRequest(Lob_Hdfs_Cursor_Prefetch, lobPtr, cursor);
    
    if (!request) {
      // return error
@@ -3631,8 +3660,7 @@ Ex_Lob_Error ExLobGlobals::enqueuePrefetchRequest(ExLob 
*lobPtr, ExLobCursor *cu
 
 Ex_Lob_Error ExLobGlobals::enqueueShutdownRequest()
 {
- // Leaving this allocated from system heap. Since this class contains hdfsFS 
unable to derive from LOB heap
-  ExLobHdfsRequest *request = new ExLobHdfsRequest(Lob_Hdfs_Shutdown);
+  ExLobHdfsRequest *request = new (heap_) ExLobHdfsRequest(Lob_Hdfs_Shutdown);
    
    if (!request) {
      // return error
@@ -3704,7 +3732,7 @@ void ExLobGlobals::doWorkInThread()
       }
       else {
          performRequest(request);
-         delete request;
+         NADELETE(request, ExLobHdfsRequest, heap_);
       }
    }
 

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/exp/ExpLOBaccess.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBaccess.h b/core/sql/exp/ExpLOBaccess.h
index 9246d6e..200091a 100644
--- a/core/sql/exp/ExpLOBaccess.h
+++ b/core/sql/exp/ExpLOBaccess.h
@@ -589,7 +589,7 @@ class ExLobGlobals
 {
   public :
   
-    ExLobGlobals(); 
+    ExLobGlobals(NAHeap *lobHeap=NULL); 
     ~ExLobGlobals();
 
     Ex_Lob_Error initialize();
@@ -602,7 +602,7 @@ class ExLobGlobals
     void doWorkInThread();
     ExLobHdfsRequest* getHdfsRequest();
     Ex_Lob_Error enqueueRequest(ExLobHdfsRequest *request);
-    Ex_Lob_Error enqueuePrefetchRequest(ExLob *lobPtr, ExLobCursor *cursor);
+  Ex_Lob_Error enqueuePrefetchRequest(ExLob *lobPtr, ExLobCursor *cursor);
     Ex_Lob_Error enqueueShutdownRequest();
     Ex_Lob_Error performRequest(ExLobHdfsRequest *request);
     Ex_Lob_Error addToPreOpenList(ExLobPreOpen *preOpenObj);

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/exp/ExpLOBinterface.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBinterface.cpp b/core/sql/exp/ExpLOBinterface.cpp
index 79bf622..718538e 100644
--- a/core/sql/exp/ExpLOBinterface.cpp
+++ b/core/sql/exp/ExpLOBinterface.cpp
@@ -34,7 +34,7 @@ using std::ofstream;
 #include "ExpLOBinterface.h"
 #include "ex_globals.h"
 
-Lng32 ExpLOBinterfaceInit(ExLobGlobals *& exLobGlob, NAHeap * lobHeap,
+Lng32 ExpLOBinterfaceInit(ExLobGlobals *& exLobGlob, NAHeap * parentHeap,
                           ContextCli *currContext,NABoolean isHiveRead,
                           char *hdfsServer, 
                           Int32 port)
@@ -45,7 +45,8 @@ Lng32 ExpLOBinterfaceInit(ExLobGlobals *& exLobGlob, NAHeap * 
lobHeap,
   Int64 cliError = -1; 
   Ex_Lob_Error status;
   Int32 dummyParam2 = 0;
-  
+
+  NAHeap *lobHeap = new ((NAHeap *)parentHeap) NAHeap("LOB Heap", (NAHeap 
*)parentHeap);
  
   err = ExLobsOper((char*)"dummy",
                   NULL, 0,
@@ -60,17 +61,17 @@ Lng32 ExpLOBinterfaceInit(ExLobGlobals *& exLobGlob, NAHeap 
* lobHeap,
                    1, // waited op
                   exLobGlob,
                   0,
-                  NULL, 0,
+                  lobHeap, 0,
                   0);
   if (exLobGlob)
     {
-      NAHeap *heap = new ((NAHeap *)lobHeap) NAHeap("LOB Heap", (NAHeap 
*)lobHeap);
+    
       if (isHiveRead)
         {
           ((ExLobGlobals *)exLobGlob)->startWorkerThreads();
-          heap->setThreadSafe();
+          lobHeap->setThreadSafe();
         }
-      ((ExLobGlobals *)exLobGlob)->setHeap(heap);
+      
       
     }
 
@@ -177,7 +178,7 @@ Lng32 ExpLOBinterfacePurgeBackupLobDataFile(ExLobGlobals *& 
exLobGlob, char *hdf
   else
     return 0;
 }
-Lng32 ExpLOBinterfaceCleanup(ExLobGlobals *& exLobGlob, NAHeap * lobHeap)
+Lng32 ExpLOBinterfaceCleanup(ExLobGlobals *& exLobGlob)
 {
   Ex_Lob_Error err;
   Ex_Lob_Error status;
@@ -197,7 +198,7 @@ Lng32 ExpLOBinterfaceCleanup(ExLobGlobals *& exLobGlob, 
NAHeap * lobHeap)
                    1, // waited op
                   exLobGlob,
                   0,
-                  lobHeap, 0
+                  NULL, 0
                   );
   if (err != LOB_OPER_OK)
     return -err;

http://git-wip-us.apache.org/repos/asf/trafodion/blob/0da83d52/core/sql/exp/ExpLOBinterface.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOBinterface.h b/core/sql/exp/ExpLOBinterface.h
index df6c142..fa4694d 100644
--- a/core/sql/exp/ExpLOBinterface.h
+++ b/core/sql/exp/ExpLOBinterface.h
@@ -82,7 +82,7 @@ enum ExpLOBinterfaceInputFlags
 
 Lng32 ExpLOBinterfaceInit(ExLobGlobals *& lobGlob, NAHeap *lobHeap, ContextCli 
*currContext,NABoolean isHiveRead, char *hdfsServer=(char *)"default", Int32 
port=0);
 
-Lng32 ExpLOBinterfaceCleanup(ExLobGlobals *& lobGlob, NAHeap *lobHeap);
+Lng32 ExpLOBinterfaceCleanup(ExLobGlobals *& lobGlob);
 
 Lng32 ExpLOBinterfaceCreate(ExLobGlobals * lobGlob, 
                            char * lobName,

Reply via email to