00001 /* 00002 // $Id: //open/dev/fennel/exec/ExecStream.h#19 $ 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_ExecStream_Included 00025 #define Fennel_ExecStream_Included 00026 00027 #include "fennel/exec/ExecStreamDefs.h" 00028 #include "fennel/exec/ErrorSource.h" 00029 #include "fennel/common/ClosableObject.h" 00030 #include "fennel/common/TraceSource.h" 00031 #include "fennel/tuple/TupleDescriptor.h" 00032 #include "fennel/tuple/TupleFormat.h" 00033 00034 #include <boost/utility.hpp> 00035 #include <vector> 00036 00037 FENNEL_BEGIN_NAMESPACE 00038 00046 class FENNEL_EXEC_EXPORT ExecStream 00047 : public boost::noncopyable, 00048 virtual public ClosableObject, 00049 virtual public TraceSource, 00050 virtual public ErrorSource 00051 { 00052 friend class ExecStreamGraphImpl; 00053 protected: 00054 00061 bool isOpen; 00062 00068 ExecStreamGraph *pGraph; 00069 00073 ExecStreamId id; 00074 00078 std::string name; 00079 00085 SharedDynamicParamManager pDynamicParamManager; 00086 00087 00094 SharedLogicalTxn pTxn; 00095 00096 00100 ExecStreamResourceQuantity resourceAllocation; 00101 00105 SharedCacheAccessor pQuotaAccessor; 00106 00110 SharedCacheAccessor pScratchQuotaAccessor; 00111 00117 explicit ExecStream(); 00118 00119 // interface methods below are protected because they should only be called 00120 // indirectly via ExecStreamGraph interface 00121 00126 virtual void closeImpl(); 00127 00128 public: 00132 virtual bool canEarlyClose(); 00133 00137 inline ExecStreamGraph &getGraph() const; 00138 00142 inline ExecStreamId getStreamId() const; 00143 00150 virtual void setInputBufAccessors( 00151 std::vector<SharedExecStreamBufAccessor> const &inAccessors) = 0; 00152 00159 virtual void setOutputBufAccessors( 00160 std::vector<SharedExecStreamBufAccessor> const &outAccessors) = 0; 00161 00174 virtual void prepare(ExecStreamParams const ¶ms); 00175 00193 virtual void getResourceRequirements( 00194 ExecStreamResourceQuantity &minQuantity, 00195 ExecStreamResourceQuantity &optQuantity, 00196 ExecStreamResourceSettingType &optType); 00197 00198 virtual void getResourceRequirements( 00199 ExecStreamResourceQuantity &minQuantity, 00200 ExecStreamResourceQuantity &optQuantity); 00201 00211 virtual void setResourceAllocation( 00212 ExecStreamResourceQuantity &quantity); 00213 00222 virtual void open(bool restart); 00223 00227 virtual void setName(std::string const &); 00228 00232 virtual std::string const &getName() const; 00233 00241 virtual ExecStreamResult execute(ExecStreamQuantum const &quantum) = 0; 00242 00251 virtual bool mayBlock() const; 00252 00261 virtual void checkAbort() const; 00262 00269 virtual ExecStreamBufProvision getOutputBufProvision() const; 00270 00277 virtual ExecStreamBufProvision getOutputBufConversion() const; 00278 00285 virtual ExecStreamBufProvision getInputBufProvision() const; 00286 }; 00287 00288 inline ExecStreamId ExecStream::getStreamId() const 00289 { 00290 return id; 00291 } 00292 00293 inline ExecStreamGraph &ExecStream::getGraph() const 00294 { 00295 assert(pGraph); 00296 return *pGraph; 00297 } 00298 00299 FENNEL_END_NAMESPACE 00300 00301 #endif 00302 00303 // End ExecStream.h