MockProducerExecStream.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/exec/MockProducerExecStream.h#18 $
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_MockProducerExecStream_Included
00025 #define Fennel_MockProducerExecStream_Included
00026 
00027 #include "fennel/exec/SingleOutputExecStream.h"
00028 #include "fennel/tuple/TupleData.h"
00029 #include <string>
00030 #include <iostream>
00031 
00032 FENNEL_BEGIN_NAMESPACE
00033 
00041 template <class T>
00042 class ColumnGenerator
00043 {
00044 public:
00045     virtual ~ColumnGenerator()
00046     {
00047     }
00048 
00049     virtual T next() = 0;
00050 };
00051 
00052 typedef ColumnGenerator<int64_t> Int64ColumnGenerator;
00053 
00054 typedef boost::shared_ptr<Int64ColumnGenerator> SharedInt64ColumnGenerator;
00055 
00060 class FENNEL_EXEC_EXPORT MockProducerExecStreamGenerator
00061 {
00062 public:
00063     virtual ~MockProducerExecStreamGenerator();
00064 
00071     virtual int64_t generateValue(uint iRow, uint iCol) = 0;
00072 };
00073 
00074 typedef boost::shared_ptr<MockProducerExecStreamGenerator>
00075     SharedMockProducerExecStreamGenerator;
00076 
00077 typedef boost::shared_ptr<MockProducerExecStreamGenerator>
00078     SharedMockProducerExecStreamGenerator;
00079 
00083 struct FENNEL_EXEC_EXPORT MockProducerExecStreamParams
00084     : public SingleOutputExecStreamParams
00085 {
00089     uint64_t nRows;
00090 
00096     SharedMockProducerExecStreamGenerator pGenerator;
00097 
00102     bool saveTuples;
00103 
00109     std::ostream* echoTuples;
00110 
00117     SharedInt64ColumnGenerator pBatchGenerator;
00118 
00119     MockProducerExecStreamParams()
00120         : nRows(0), saveTuples(false), echoTuples(0) {}
00121 };
00122 
00129 class FENNEL_EXEC_EXPORT MockProducerExecStream
00130     : public SingleOutputExecStream
00131 {
00132     uint cbTuple;
00133     uint64_t nRowsMax;
00134     uint64_t nRowsProduced;
00135     TupleData outputData;
00136     SharedMockProducerExecStreamGenerator pGenerator;
00137     SharedInt64ColumnGenerator pBatchGenerator;
00138     bool saveTuples;
00139     std::ostream* echoTuples;
00140     std::vector<std::string> savedTuples;
00141 
00142 public:
00143     MockProducerExecStream();
00144 
00145     // implement ExecStream
00146     virtual void prepare(MockProducerExecStreamParams const &params);
00147     virtual void open(bool restart);
00148     virtual ExecStreamResult execute(ExecStreamQuantum const &quantum);
00149 
00150     const std::vector<std::string>& getRowVector() {
00151         return const_cast<const std::vector<std::string>&>(savedTuples);
00152     }
00153 
00156     uint64_t getProducedRowCount();
00157 };
00158 
00159 FENNEL_END_NAMESPACE
00160 
00161 #endif
00162 
00163 // End MockProducerExecStream.h

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