00001 /* 00002 // $Id: //open/dev/fennel/lucidera/colstore/LcsRowScanExecStream.h#21 $ 00003 // Fennel is a library of data storage and processing components. 00004 // Copyright (C) 2005-2009 LucidEra, Inc. 00005 // Copyright (C) 2005-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_LcsRowScanExecStream_Included 00023 #define Fennel_LcsRowScanExecStream_Included 00024 00025 #include <boost/scoped_array.hpp> 00026 #include <boost/scoped_ptr.hpp> 00027 #include "fennel/tuple/TupleDataWithBuffer.h" 00028 #include "fennel/lucidera/colstore/LcsRowScanBaseExecStream.h" 00029 #include "fennel/lucidera/bitmap/LbmRidReader.h" 00030 #include "fennel/lucidera/colstore/LcsResidualColumnFilters.h" 00031 #include "fennel/common/BernoulliRng.h" 00032 #include "fennel/common/FemEnums.h" 00033 00034 FENNEL_BEGIN_NAMESPACE 00035 00041 struct FENNEL_LCS_EXPORT LcsRowScanExecStreamParams 00042 : public LcsRowScanBaseExecStreamParams 00043 { 00044 static int32_t defaultSystemSamplingClumps; 00045 00052 bool isFullScan; 00053 00060 bool hasExtraFilter; 00061 00065 TupleProjection residualFilterCols; 00066 00071 TableSamplingMode samplingMode; 00072 00077 float samplingRate; 00078 00083 bool samplingIsRepeatable; 00084 00089 int32_t samplingRepeatableSeed; 00090 00094 int32_t samplingClumps; 00095 00102 int64_t samplingRowCount; 00103 }; 00104 00110 class FENNEL_LCS_EXPORT LcsRowScanExecStream 00111 : public LcsRowScanBaseExecStream 00112 { 00117 TupleDataWithBuffer outputTupleData; 00118 00129 uint iFilterToInitialize; 00130 00131 /* 00132 * Real output tuple. 00133 */ 00134 TupleData projOutputTupleData; 00135 00136 /* 00137 * projection for the output row. 00138 */ 00139 TupleProjection outputProj; 00140 00144 TupleData ridTupleData; 00145 00149 LbmRidReader ridReader; 00150 00154 RecordNum nRidsRead; 00155 00159 LcsRid inputRid; 00160 00164 LcsRid nextRid; 00165 00169 bool readDeletedRid; 00170 00174 bool deletedRidEos; 00175 00179 LcsRid deletedRid; 00180 00184 bool tupleFound; 00185 00189 bool isFullScan; 00190 00194 bool hasExtraFilter; 00195 00199 bool producePending; 00200 00207 boost::scoped_array<LcsResidualColumnFilters *> filters; 00208 00212 int32_t nFilters; 00213 00217 TableSamplingMode samplingMode; 00218 00222 float samplingRate; 00223 00227 bool isSamplingRepeatable; 00228 00232 int32_t repeatableSeed; 00233 00237 int32_t samplingClumps; 00238 00242 uint64_t clumpSize; 00243 00247 uint64_t clumpDistance; 00248 00252 uint64_t clumpPos; 00253 00257 uint64_t clumpSkipPos; 00258 00262 uint numClumps; 00263 00267 uint numClumpsBuilt; 00268 00272 boost::scoped_ptr<BernoulliRng> samplingRng; 00273 00278 int64_t rowCount; 00279 00283 bool ridRunsBuilt; 00284 00288 LcsRidRun currRidRun; 00289 00293 CircularBufferIter<LcsRidRun> ridRunIter; 00294 00303 virtual void buildOutputProj( 00304 TupleProjection &outputProj, 00305 LcsRowScanBaseExecStreamParams const ¶ms); 00306 00312 bool initializeFiltersIfNeeded(); 00313 00319 void prepareResidualFilters(LcsRowScanExecStreamParams const ¶ms); 00320 00324 void initializeSystemSampling(); 00325 00331 ExecStreamResult fillRidRunBuffer(); 00332 00333 public: 00334 LcsRowScanExecStream(); 00335 virtual void prepare(LcsRowScanExecStreamParams const ¶ms); 00336 virtual void open(bool restart); 00337 virtual ExecStreamResult execute(ExecStreamQuantum const &quantum); 00338 virtual void getResourceRequirements( 00339 ExecStreamResourceQuantity &minQuantity, 00340 ExecStreamResourceQuantity &optQuantity); 00341 virtual void closeImpl(); 00342 }; 00343 00344 FENNEL_END_NAMESPACE 00345 00346 #endif 00347 00348 // End LcsRowScanExecStream.h