DynamicDelegatingSegment.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/segment/DynamicDelegatingSegment.cpp#8 $
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 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/segment/DynamicDelegatingSegment.h"
00026 
00027 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/segment/DynamicDelegatingSegment.cpp#8 $");
00028 
00029 DynamicDelegatingSegment::DynamicDelegatingSegment(
00030     WeakSegment delegatingSegment)
00031     : Segment(SharedSegment(delegatingSegment)->getCache()),
00032       delegateSegment(delegatingSegment)
00033 {
00034     setUsablePageSize(SharedSegment(delegateSegment)->getUsablePageSize());
00035 }
00036 
00037 DynamicDelegatingSegment::~DynamicDelegatingSegment()
00038 {
00039 }
00040 
00041 void DynamicDelegatingSegment::closeImpl()
00042 {
00043     Segment::closeImpl();
00044     delegateSegment.reset();
00045 }
00046 
00047 BlockNum DynamicDelegatingSegment::getAllocatedSizeInPages()
00048 {
00049     SharedSegment pDelegateSegment = delegateSegment.lock();
00050     return pDelegateSegment->getAllocatedSizeInPages();
00051 }
00052 
00053 BlockNum DynamicDelegatingSegment::getNumPagesOccupiedHighWater()
00054 {
00055     SharedSegment pDelegateSegment = delegateSegment.lock();
00056     return pDelegateSegment->getNumPagesOccupiedHighWater();
00057 }
00058 
00059 BlockNum DynamicDelegatingSegment::getNumPagesExtended()
00060 {
00061     SharedSegment pDelegateSegment = delegateSegment.lock();
00062     return pDelegateSegment->getNumPagesExtended();
00063 }
00064 
00065 PageId DynamicDelegatingSegment::getPageSuccessor(PageId pageId)
00066 {
00067     SharedSegment pDelegateSegment = delegateSegment.lock();
00068     return pDelegateSegment->getPageSuccessor(pageId);
00069 }
00070 
00071 void DynamicDelegatingSegment::setPageSuccessor(
00072     PageId pageId,
00073     PageId successorId)
00074 {
00075     SharedSegment pDelegateSegment = delegateSegment.lock();
00076     pDelegateSegment->setPageSuccessor(pageId,successorId);
00077 }
00078 
00079 BlockId DynamicDelegatingSegment::translatePageId(PageId pageId)
00080 {
00081     SharedSegment pDelegateSegment = delegateSegment.lock();
00082     return pDelegateSegment->translatePageId(pageId);
00083 }
00084 
00085 PageId DynamicDelegatingSegment::translateBlockId(BlockId blockId)
00086 {
00087     SharedSegment pDelegateSegment = delegateSegment.lock();
00088     return pDelegateSegment->translateBlockId(blockId);
00089 }
00090 
00091 PageId DynamicDelegatingSegment::allocatePageId(PageOwnerId ownerId)
00092 {
00093     SharedSegment pDelegateSegment = delegateSegment.lock();
00094     return pDelegateSegment->allocatePageId(ownerId);
00095 }
00096 
00097 bool DynamicDelegatingSegment::ensureAllocatedSize(BlockNum nPages)
00098 {
00099     SharedSegment pDelegateSegment = delegateSegment.lock();
00100     return pDelegateSegment->ensureAllocatedSize(nPages);
00101 }
00102 
00103 void DynamicDelegatingSegment::deallocatePageRange(
00104     PageId startPageId,
00105     PageId endPageId)
00106 {
00107     SharedSegment pDelegateSegment = delegateSegment.lock();
00108     pDelegateSegment->deallocatePageRange(startPageId,endPageId);
00109 }
00110 
00111 bool DynamicDelegatingSegment::isPageIdAllocated(PageId pageId)
00112 {
00113     SharedSegment pDelegateSegment = delegateSegment.lock();
00114     return pDelegateSegment->isPageIdAllocated(pageId);
00115 }
00116 
00117 Segment::AllocationOrder DynamicDelegatingSegment::getAllocationOrder() const
00118 {
00119     SharedSegment pDelegateSegment = delegateSegment.lock();
00120     return pDelegateSegment->getAllocationOrder();
00121 }
00122 
00123 void DynamicDelegatingSegment::notifyPageMap(CachePage &page)
00124 {
00125     SharedSegment pDelegateSegment = delegateSegment.lock();
00126     pDelegateSegment->notifyPageMap(page);
00127 }
00128 
00129 void DynamicDelegatingSegment::notifyPageUnmap(CachePage &page)
00130 {
00131     SharedSegment pDelegateSegment = delegateSegment.lock();
00132     pDelegateSegment->notifyPageUnmap(page);
00133 }
00134 
00135 void DynamicDelegatingSegment::notifyAfterPageRead(CachePage &page)
00136 {
00137     SharedSegment pDelegateSegment = delegateSegment.lock();
00138     pDelegateSegment->notifyAfterPageRead(page);
00139 }
00140 
00141 void DynamicDelegatingSegment::notifyPageDirty(CachePage &page,bool bDataValid)
00142 {
00143     SharedSegment pDelegateSegment = delegateSegment.lock();
00144     pDelegateSegment->notifyPageDirty(page,bDataValid);
00145 }
00146 
00147 void DynamicDelegatingSegment::notifyBeforePageFlush(CachePage &page)
00148 {
00149     SharedSegment pDelegateSegment = delegateSegment.lock();
00150     pDelegateSegment->notifyBeforePageFlush(page);
00151 }
00152 
00153 void DynamicDelegatingSegment::notifyAfterPageFlush(CachePage &page)
00154 {
00155     SharedSegment pDelegateSegment = delegateSegment.lock();
00156     pDelegateSegment->notifyAfterPageFlush(page);
00157 }
00158 
00159 bool DynamicDelegatingSegment::canFlushPage(CachePage &page)
00160 {
00161     SharedSegment pDelegateSegment = delegateSegment.lock();
00162     return pDelegateSegment->canFlushPage(page);
00163 }
00164 
00165 void DynamicDelegatingSegment::delegatedCheckpoint(
00166     Segment &delegatingSegment,CheckpointType checkpointType)
00167 {
00168     // Because the delegating segment is referenced through a weak pointer,
00169     // that segment may have already been freed during close database by the
00170     // time this method is called.  So, we need to make sure it's still
00171     // available before de-referencing it.
00172     SharedSegment pDelegateSegment = delegateSegment.lock();
00173     if (pDelegateSegment) {
00174         pDelegateSegment->delegatedCheckpoint(
00175             delegatingSegment,
00176             checkpointType);
00177     }
00178 }
00179 
00180 bool DynamicDelegatingSegment::isWriteVersioned()
00181 {
00182     SharedSegment pDelegateSegment = delegateSegment.lock();
00183     return pDelegateSegment->isWriteVersioned();
00184 }
00185 
00186 PageId DynamicDelegatingSegment::updatePage(
00187     PageId pageId,
00188     bool needsTranslation)
00189 {
00190     SharedSegment pDelegateSegment = delegateSegment.lock();
00191     return pDelegateSegment->updatePage(pageId, needsTranslation);
00192 }
00193 
00194 MappedPageListener *DynamicDelegatingSegment::getMappedPageListener(
00195     BlockId blockId)
00196 {
00197     // Unlike DelegatingSegment, we return the listener associated with the
00198     // delegating segment rather than the segment itself
00199     SharedSegment pDelegateSegment = delegateSegment.lock();
00200     return pDelegateSegment->getMappedPageListener(blockId);
00201 }
00202 
00203 void DynamicDelegatingSegment::setDelegatingSegment(
00204     WeakSegment delegatingSegment)
00205 {
00206     delegateSegment = delegatingSegment;
00207 }
00208 
00209 SharedSegment DynamicDelegatingSegment::getDelegateSegment()
00210 {
00211     return delegateSegment.lock();
00212 }
00213 
00214 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/segment/DynamicDelegatingSegment.cpp#8 $");
00215 
00216 // End DynamicDelegatingSegment.cpp

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