From 0bfe10a7d0ad6a9fa6f38c1b2eb0d8c67c7405ba Mon Sep 17 00:00:00 2001 From: drrtuy Date: Fri, 21 Feb 2025 17:02:42 +0000 Subject: [PATCH] feat(): use CountingAllocator for DISTINCT --- dbcon/joblist/jobstep.cpp | 6 ++++++ utils/windowfunction/idborderby.cpp | 6 ++++-- utils/windowfunction/idborderby.h | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dbcon/joblist/jobstep.cpp b/dbcon/joblist/jobstep.cpp index 8968c339d..18e20f4bd 100644 --- a/dbcon/joblist/jobstep.cpp +++ b/dbcon/joblist/jobstep.cpp @@ -217,6 +217,12 @@ void JobStep::handleException(std::exception_ptr e, const int errorCode, const u { std::rethrow_exception(e); } + // Add it here for now to handle potential bad_alloc exceptions + catch (std::bad_alloc& exc) + { + std::cerr << methodName << " caught a bad_alloc exception. " << std::endl; + catchHandler(methodName + " caught " + exc.what(), errorCode, fErrorInfo, fSessionId); + } catch (const IDBExcept& iex) { std::cerr << methodName << " caught a internal exception. " << std::endl; diff --git a/utils/windowfunction/idborderby.cpp b/utils/windowfunction/idborderby.cpp index ad52b0f37..53a4da9ee 100644 --- a/utils/windowfunction/idborderby.cpp +++ b/utils/windowfunction/idborderby.cpp @@ -747,13 +747,14 @@ IdbOrderBy::~IdbOrderBy() delete *i++; } +// INV fRm is not NULL here void IdbOrderBy::initialize(const RowGroup& rg) { // initialize rows IdbCompare::initialize(rg); auto newSize = rg.getSizeWithStrings(fRowsPerRG); - if (fRm && !fRm->getMemory(newSize, fSessionMemLimit)) + if (!fRm->getMemory(newSize, fSessionMemLimit)) { cerr << IDBErrorInfo::instance()->errorMsg(fErrorCode) << " @" << __FILE__ << ":" << __LINE__; throw IDBExcept(fErrorCode); @@ -773,7 +774,8 @@ void IdbOrderBy::initialize(const RowGroup& rg) if (fDistinct) { - fDistinctMap.reset(new DistinctMap_t(10, Hasher(this, getKeyLength()), Eq(this, getKeyLength()))); + auto alloc = fRm->getAllocator(); + fDistinctMap.reset(new DistinctMap_t(10, Hasher(this, getKeyLength()), Eq(this, getKeyLength()), alloc)); } } diff --git a/utils/windowfunction/idborderby.h b/utils/windowfunction/idborderby.h index 600a0f3da..9380cd491 100644 --- a/utils/windowfunction/idborderby.h +++ b/utils/windowfunction/idborderby.h @@ -29,8 +29,9 @@ #include -#include +#include +#include "countingallocator.h" #include "rowgroup.h" #include "hasher.h" #include "stlpoolallocator.h" @@ -455,9 +456,8 @@ class IdbOrderBy : public IdbCompare bool operator()(const rowgroup::Row::Pointer&, const rowgroup::Row::Pointer&) const; }; - typedef std::tr1::unordered_set > - DistinctMap_t; + using DistinctMap_t = std::unordered_set>; boost::scoped_ptr fDistinctMap; rowgroup::Row row1, row2; // scratch space for Hasher & Eq