BTreePrefetchSearchExecStream.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/ftrs/BTreePrefetchSearchExecStream.h#6 $
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) 2004-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_BTreePrefetchSearchExecStream_Included
00025 #define Fennel_BTreePrefetchSearchExecStream_Included
00026 
00027 #include "fennel/ftrs/BTreeSearchExecStream.h"
00028 #include "fennel/btree/BTreeNode.h"
00029 #include "fennel/segment/SegPageEntryIter.h"
00030 #include "fennel/segment/SegPageEntryIterSource.h"
00031 #include "fennel/common/SearchEndpoint.h"
00032 
00033 FENNEL_BEGIN_NAMESPACE
00034 
00039 struct FENNEL_FTRS_EXPORT BTreePrefetchSearchKey
00040 {
00044     SearchEndpoint lowerBoundDirective;
00045 
00049     SearchEndpoint upperBoundDirective;
00050 
00054     PBuffer lowerKeyBuffer;
00055 
00059     PBuffer upperKeyBuffer;
00060 
00065     bool newSearch;
00066 };
00067 
00072 struct FENNEL_FTRS_EXPORT BTreePrefetchSearchExecStreamParams
00073     : public BTreeSearchExecStreamParams
00074 {
00075 };
00076 
00096 class FENNEL_FTRS_EXPORT BTreePrefetchSearchExecStream
00097     : public BTreeSearchExecStream,
00098         public SegPageEntryIterSource<BTreePrefetchSearchKey>
00099 {
00100 protected:
00104     SegPageEntryIter<BTreePrefetchSearchKey> leafPageQueue;
00105 
00110     SharedBTreeLeafReader pLeafReader;
00111 
00115     SharedBTreeNonLeafReader pNonLeafReader;
00116 
00121     TupleAccessor savedLowerBoundAccessor;
00122 
00127     TupleAccessor savedUpperBoundAccessor;
00128 
00133     SearchEndpoint pfLowerBoundDirective;
00134 
00139     SearchEndpoint pfUpperBoundDirective;
00140 
00145     TupleData pfLowerBoundData;
00146 
00151     TupleData pfUpperBoundData;
00152 
00157     bool endOnNextKey;
00158 
00163     BTreePageLock scratchLock;
00164 
00168     uint scratchPageSize;
00169 
00174     uint nMiscCachePages;
00175 
00179     uint nPrefetchScratchPages;
00180 
00184     uint keyValuesSize;
00185 
00189     uint nEntriesPerScratchPage;
00190 
00195     bool bigMaxKey;
00196 
00200     std::vector<PBuffer> scratchPages;
00201 
00206     uint currPage;
00207 
00212     uint currPageEntry;
00213 
00217     bool initialPrefetchDone;
00218 
00222     bool processingDone;
00223 
00227     bool prevLeafSearchRc;
00228 
00232     bool rootOnly;
00233 
00238     bool returnedRoot;
00239 
00243     virtual SharedBTreeReader newReader();
00244 
00249     void allocateScratchPages();
00250 
00257     bool innerSearchLoop();
00258 
00264     void getPrefetchSearchKey();
00265 
00272     void setUpSearchKey(BTreePrefetchSearchKey const &searchKey);
00273 
00282     void setSearchKeyData(bool newSearch, BTreePrefetchSearchKey &searchKey);
00283 
00291     bool testNonLeafInterval();
00292 
00296     virtual void setAdditionalKeys();
00297 
00303     virtual void setLowerBoundKey(PConstBuffer buf);
00304 
00305 public:
00306     explicit BTreePrefetchSearchExecStream();
00307     virtual void prepare(BTreePrefetchSearchExecStreamParams const &params);
00308     virtual void getResourceRequirements(
00309         ExecStreamResourceQuantity &minQuantity,
00310         ExecStreamResourceQuantity &optQuantity,
00311         ExecStreamResourceSettingType &optType);
00312     virtual void setResourceAllocation(ExecStreamResourceQuantity &quantity);
00313     virtual void open(bool restart);
00314     virtual ExecStreamResult execute(ExecStreamQuantum const &quantum);
00315     virtual void initPrefetchEntry(BTreePrefetchSearchKey &searchKey);
00316     virtual PageId getNextPageForPrefetch(
00317         BTreePrefetchSearchKey &searchKey,
00318         bool &found);
00319     virtual void closeImpl();
00320 };
00321 
00322 FENNEL_END_NAMESPACE
00323 
00324 #endif
00325 
00326 // End BTreePrefetchSearchExecStream.h

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