From 9052520ba21c824d526f67518c66a1c32c6a2f24 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 26 May 2010 14:59:20 +0000 Subject: The cache storage backend for myriad is fixed up to be used. --- src/cachestoremyriad.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cachestoremyriad.h b/src/cachestoremyriad.h index bffa0bb..400e3f7 100644 --- a/src/cachestoremyriad.h +++ b/src/cachestoremyriad.h @@ -50,18 +50,16 @@ namespace Bu public: CacheStoreMyriad( Bu::Stream &sArch, int iBlockSize=1024, int iPreAllocate=1 ) : - mStore( sArch ) + mStore( sArch, iBlockSize, iPreAllocate ) { try { - mStore.initialize(); MyriadStream ns = mStore.openStream( 1 ); Bu::Archive ar( ns, Bu::Archive::load ); ar >> hId; } catch( Bu::MyriadException &e ) { - mStore.initialize( iBlockSize, iPreAllocate ); int iStream = mStore.createStream(); if( iStream != 1 ) throw Bu::ExceptionBase("That's...horrible...id = %d.\n\n", @@ -99,6 +97,7 @@ namespace Bu hId.insert( key, iStream ); MyriadStream ns = mStore.openStream( iStream ); __cacheStoreMyriadStore( ns, *pSrc, key ); + ns.setSize( ns.tell() ); return key; } @@ -114,6 +113,7 @@ namespace Bu int iStream = hId.get( key ); MyriadStream ns = mStore.openStream( iStream ); __cacheStoreMyriadStore( ns, *pSrc, key ); + ns.setSize( ns.tell() ); } virtual void destroy( obtype *pObj, const keytype &key ) @@ -124,6 +124,13 @@ namespace Bu delete pObj; } + virtual void destroy( const keytype &key ) + { + int iStream = hId.get( key ); + mStore.deleteStream( iStream ); + hId.erase( key ); + } + virtual bool has( const keytype &key ) { return hId.has( key ); -- cgit v1.2.3