summaryrefslogtreecommitdiff
path: root/src/cachestoremyriad.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-05-26 14:59:20 +0000
committerMike Buland <eichlan@xagasoft.com>2010-05-26 14:59:20 +0000
commit9052520ba21c824d526f67518c66a1c32c6a2f24 (patch)
tree9120003ada0377a6fcf87db2637723643987ce8e /src/cachestoremyriad.h
parent1d02c374c8877d430f4ab35a790fc02f02974704 (diff)
downloadlibbu++-9052520ba21c824d526f67518c66a1c32c6a2f24.tar.gz
libbu++-9052520ba21c824d526f67518c66a1c32c6a2f24.tar.bz2
libbu++-9052520ba21c824d526f67518c66a1c32c6a2f24.tar.xz
libbu++-9052520ba21c824d526f67518c66a1c32c6a2f24.zip
The cache storage backend for myriad is fixed up to be used.
Diffstat (limited to '')
-rw-r--r--src/cachestoremyriad.h13
1 files changed, 10 insertions, 3 deletions
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
50 public: 50 public:
51 CacheStoreMyriad( Bu::Stream &sArch, 51 CacheStoreMyriad( Bu::Stream &sArch,
52 int iBlockSize=1024, int iPreAllocate=1 ) : 52 int iBlockSize=1024, int iPreAllocate=1 ) :
53 mStore( sArch ) 53 mStore( sArch, iBlockSize, iPreAllocate )
54 { 54 {
55 try 55 try
56 { 56 {
57 mStore.initialize();
58 MyriadStream ns = mStore.openStream( 1 ); 57 MyriadStream ns = mStore.openStream( 1 );
59 Bu::Archive ar( ns, Bu::Archive::load ); 58 Bu::Archive ar( ns, Bu::Archive::load );
60 ar >> hId; 59 ar >> hId;
61 } 60 }
62 catch( Bu::MyriadException &e ) 61 catch( Bu::MyriadException &e )
63 { 62 {
64 mStore.initialize( iBlockSize, iPreAllocate );
65 int iStream = mStore.createStream(); 63 int iStream = mStore.createStream();
66 if( iStream != 1 ) 64 if( iStream != 1 )
67 throw Bu::ExceptionBase("That's...horrible...id = %d.\n\n", 65 throw Bu::ExceptionBase("That's...horrible...id = %d.\n\n",
@@ -99,6 +97,7 @@ namespace Bu
99 hId.insert( key, iStream ); 97 hId.insert( key, iStream );
100 MyriadStream ns = mStore.openStream( iStream ); 98 MyriadStream ns = mStore.openStream( iStream );
101 __cacheStoreMyriadStore<keytype, obtype>( ns, *pSrc, key ); 99 __cacheStoreMyriadStore<keytype, obtype>( ns, *pSrc, key );
100 ns.setSize( ns.tell() );
102 return key; 101 return key;
103 } 102 }
104 103
@@ -114,6 +113,7 @@ namespace Bu
114 int iStream = hId.get( key ); 113 int iStream = hId.get( key );
115 MyriadStream ns = mStore.openStream( iStream ); 114 MyriadStream ns = mStore.openStream( iStream );
116 __cacheStoreMyriadStore<keytype, obtype>( ns, *pSrc, key ); 115 __cacheStoreMyriadStore<keytype, obtype>( ns, *pSrc, key );
116 ns.setSize( ns.tell() );
117 } 117 }
118 118
119 virtual void destroy( obtype *pObj, const keytype &key ) 119 virtual void destroy( obtype *pObj, const keytype &key )
@@ -124,6 +124,13 @@ namespace Bu
124 delete pObj; 124 delete pObj;
125 } 125 }
126 126
127 virtual void destroy( const keytype &key )
128 {
129 int iStream = hId.get( key );
130 mStore.deleteStream( iStream );
131 hId.erase( key );
132 }
133
127 virtual bool has( const keytype &key ) 134 virtual bool has( const keytype &key )
128 { 135 {
129 return hId.has( key ); 136 return hId.has( key );