From 2cb10f33a1cc8d3d94450fa45cc8f63ba32c137f Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Tue, 21 Oct 2003 20:40:01 +0000 Subject: Added Freeze evictor indices --- cpp/src/Freeze/Util.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 cpp/src/Freeze/Util.cpp (limited to 'cpp/src/Freeze/Util.cpp') diff --git a/cpp/src/Freeze/Util.cpp b/cpp/src/Freeze/Util.cpp new file mode 100644 index 00000000000..ebaca432024 --- /dev/null +++ b/cpp/src/Freeze/Util.cpp @@ -0,0 +1,77 @@ +// ********************************************************************** +// +// Copyright (c) 2003 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +#include +#include + +using namespace Freeze; +using namespace Ice; +using namespace std; + +void +Freeze::handleMemoryException(const DbMemoryException& dx, Key& key, Dbt& dbKey) +{ + if(dbKey.get_size() > dbKey.get_ulen()) + { + // + // Keep the old key size in case it's used as input + // + size_t oldKeySize = key.size(); + + key.resize(dbKey.get_size()); + initializeOutDbt(key, dbKey); + dbKey.set_size(oldKeySize); + } + else + { + // + // Real problem + // + DatabaseException ex(__FILE__, __LINE__); + ex.message = dx.what(); + throw ex; + } +} + +void +Freeze::handleMemoryException(const DbMemoryException& dx, Key& key, Dbt& dbKey, + Value& value, Dbt& dbValue) +{ + bool resized = false; + if(dbKey.get_size() > dbKey.get_ulen()) + { + size_t oldKeySize = key.size(); + key.resize(dbKey.get_size()); + initializeOutDbt(key, dbKey); + dbKey.set_size(oldKeySize); + resized = true; + } + + if(dbValue.get_size() > dbValue.get_ulen()) + { + value.resize(dbValue.get_size()); + initializeOutDbt(value, dbValue); + resized = true; + } + + if(!resized) + { + // + // Real problem + // + DatabaseException ex(__FILE__, __LINE__); + ex.message = dx.what(); + throw ex; + } +} -- cgit v1.2.3