00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Fennel_SnapshotRandomAllocationSegment_Included
00025 #define Fennel_SnapshotRandomAllocationSegment_Included
00026
00027 #include "fennel/synch/SXMutex.h"
00028 #include "fennel/synch/SynchObj.h"
00029 #include "fennel/segment/DelegatingSegment.h"
00030 #include "fennel/segment/VersionedRandomAllocationSegment.h"
00031
00032 #include <boost/shared_ptr.hpp>
00033
00034 FENNEL_BEGIN_NAMESPACE
00035
00048 class FENNEL_SEGMENT_EXPORT SnapshotRandomAllocationSegment
00049 : public DelegatingSegment
00050 {
00055 ModifiedPageEntryMap modPageEntriesMap;
00056
00061 PageMap snapshotPageMap;
00062
00063
00064
00065
00066
00067
00068
00069
00079 SXMutex modPageMapMutex;
00080
00088 StrictMutex snapshotPageMapMutex;
00089
00093 VersionedRandomAllocationSegment *pVersionedRandomSegment;
00094
00098 TxnId snapshotCsn;
00099
00105 bool readOnlyCommittedData;
00106
00111 bool needPageFlush;
00112
00118 bool forceCacheUnmap;
00119
00128 PageId getSnapshotId(PageId pageId);
00129
00146 void incrPageUpdateCount(
00147 PageId pageId,
00148 PageOwnerId ownerId,
00149 ModifiedPageEntry::ModType modType);
00150
00158 PageId getAnchorPageId(PageId snapshotId);
00159
00167 bool isPageNewlyAllocated(PageId pageId);
00168
00182 void chainPageEntries(
00183 PageId pageId,
00184 PageId versionChainId,
00185 PageId successorId);
00186
00187 public:
00188 explicit SnapshotRandomAllocationSegment(
00189 SharedSegment delegateSegment,
00190 SharedSegment versionedSegment,
00191 TxnId snapshotCsnInit,
00192 bool readOnlyCommittedData);
00193
00197 TxnId getSnapshotCsn();
00198
00204 void commitChanges(TxnId commitCsn);
00205
00209 void rollbackChanges();
00210
00220 void versionPage(PageId destAnchorPageId, PageId srcAnchorPageId);
00221
00227 void setForceCacheUnmap();
00228
00229
00230 virtual BlockId translatePageId(PageId pageId);
00231 virtual PageId getPageSuccessor(PageId pageId);
00232 virtual void setPageSuccessor(PageId pageId, PageId successorId);
00233 virtual PageId allocatePageId(PageOwnerId ownerId);
00234 virtual void deallocatePageRange(PageId startPageId, PageId endPageId);
00235 virtual PageId updatePage(PageId pageId, bool needsTranslation = false);
00236 virtual MappedPageListener *getMappedPageListener(BlockId blockId);
00237 virtual void delegatedCheckpoint(
00238 Segment &delegatingSegment,
00239 CheckpointType checkpointType);
00240 virtual MappedPageListener *notifyAfterPageCheckpointFlush(CachePage &page);
00241 virtual bool canFlushPage(CachePage &page);
00242 virtual void notifyPageDirty(CachePage &page, bool bDataValid);
00243 virtual bool isWriteVersioned();
00244 };
00245
00246 FENNEL_END_NAMESPACE
00247
00248 #endif
00249
00250