SnapshotRandomAllocationSegment.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/segment/SnapshotRandomAllocationSegment.h#13 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2005-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 // Portions Copyright (C) 1999-2009 John V. Sichi
00008 //
00009 // This program is free software; you can redistribute it and/or modify it
00010 // under the terms of the GNU General Public License as published by the Free
00011 // Software Foundation; either version 2 of the License, or (at your option)
00012 // any later version approved by The Eigenbase Project.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with this program; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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     // NOTE jvs 23-Oct-2007: Both of these mutexes could become hotspots for
00064     // read-only access in a parallel query executor.  May need a C++
00065     // equivalent for ConcurrentHashMap.  Note that even SXMutex requires
00066     // briefly taking a StrictMutex under the covers.  Alternatively,
00067     // we could keep this class unchanged and then arrange for each
00068     // thread to get its own instance (maintaining its own private cache).
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     // implementation of Segment interface
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 // End SnapshotRandomAllocationSegment.h

Generated on Mon Jun 22 04:00:20 2009 for Fennel by  doxygen 1.5.1