00001 /* 00002 // $Id: //open/dev/fennel/lucidera/bitmap/LbmUnionExecStream.h#11 $ 00003 // Fennel is a library of data storage and processing components. 00004 // Copyright (C) 2006-2009 LucidEra, Inc. 00005 // Copyright (C) 2006-2009 The Eigenbase Project 00006 // 00007 // This program is free software; you can redistribute it and/or modify it 00008 // under the terms of the GNU General Public License as published by the Free 00009 // Software Foundation; either version 2 of the License, or (at your option) 00010 // any later version approved by The Eigenbase Project. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #ifndef Fennel_LbmUnionExecStream_Included 00023 #define Fennel_LbmUnionExecStream_Included 00024 00025 #include "fennel/tuple/TupleData.h" 00026 #include "fennel/exec/ConfluenceExecStream.h" 00027 #include "fennel/exec/DynamicParam.h" 00028 #include "fennel/lucidera/bitmap/LbmSeqSegmentReader.h" 00029 #include "fennel/lucidera/bitmap/LbmSegmentWriter.h" 00030 #include "fennel/lucidera/bitmap/LbmUnionWorkspace.h" 00031 00032 FENNEL_BEGIN_NAMESPACE 00033 00038 struct LbmUnionExecStreamParams : public ConfluenceExecStreamParams 00039 { 00043 LcsRid maxRid; 00044 00052 DynamicParamId ridLimitParamId; 00053 00061 DynamicParamId startRidParamId; 00062 00071 DynamicParamId segmentLimitParamId; 00072 }; 00073 00081 class FENNEL_LBM_EXPORT LbmUnionExecStream 00082 : public ConfluenceExecStream 00083 { 00084 // see LbmUnionExecStreamParams 00085 LcsRid maxRid; 00086 DynamicParamId ridLimitParamId; 00087 DynamicParamId startRidParamId; 00088 DynamicParamId segmentLimitParamId; 00089 00093 TupleDatum ridLimitDatum; 00094 00098 RecordNum ridLimit; 00099 00103 uint pageSize; 00104 00108 uint nWorkspacePages; 00109 00113 LbmSeqSegmentReader segmentReader; 00114 00118 LbmUnionWorkspace workspace; 00119 00123 LbmSegmentWriter segmentWriter; 00124 00128 SegmentAccessor scratchAccessor; 00129 00133 SegPageLock workspacePageLock; 00134 00138 SegPageLock writerPageLock; 00139 00143 TupleData inputTuple; 00144 00148 LbmByteSegment inputSegment; 00149 00153 PBuffer reverseArea; 00154 00155 uint reverseAreaSize; 00156 00160 TupleData outputTuple; 00161 00165 bool writePending; 00166 00170 bool producePending; 00171 00175 bool isDone; 00176 00180 LcsRid requestedSrid; 00181 00186 uint segmentsRemaining; 00187 00192 uint computeOptWorkspacePages(LcsRid maxRid); 00193 00198 uint computeRidLimit(uint nWorkspacePages); 00199 00203 bool isConsumerSridSet(); 00204 00208 bool isSegmentLimitSet(); 00209 00214 ExecStreamResult readSegment(); 00215 00223 bool writeSegment(); 00224 00229 void transferLast(); 00230 00237 bool transfer(); 00238 00242 bool produceTuple(); 00243 00244 public: 00245 virtual void prepare(LbmUnionExecStreamParams const ¶ms); 00246 virtual void open(bool restart); 00247 virtual ExecStreamResult execute(ExecStreamQuantum const &quantum); 00248 virtual void getResourceRequirements( 00249 ExecStreamResourceQuantity &minQuantity, 00250 ExecStreamResourceQuantity &optQuantity, 00251 ExecStreamResourceSettingType &optType); 00252 virtual void setResourceAllocation(ExecStreamResourceQuantity &quantity); 00253 virtual void closeImpl(); 00254 }; 00255 00256 FENNEL_END_NAMESPACE 00257 00258 #endif 00259 00260 // End LbmUnionExecStream.h