ExecStreamFactory.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/farrago/ExecStreamFactory.h#34 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2003-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 // Portions Copyright (C) 1999-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_ExecStreamFactory_Included
00025 #define Fennel_ExecStreamFactory_Included
00026 
00027 #include "fennel/farrago/Fem.h"
00028 #include "fennel/common/ClosableObject.h"
00029 #include "fennel/exec/ExecStream.h"
00030 #include "fennel/exec/ExecStreamEmbryo.h"
00031 #include "fennel/farrago/CmdInterpreter.h"
00032 
00033 #include <boost/utility.hpp>
00034 
00035 FENNEL_BEGIN_NAMESPACE
00036 
00037 class BarrierExecStreamParams;
00038 class BTreeExecStreamParams;
00039 class BTreePrefetchSearchExecStreamParams;
00040 class BTreeReadExecStreamParams;
00041 class BTreeScanExecStreamParams;
00042 class BTreeSearchExecStreamParams;
00043 class FtrsTableIndexWriterParams;
00044 class FtrsTableWriterExecStreamParams;
00045 class JavaExecStreamParams;
00046 class TupleDescriptor;
00047 class TupleProjection;
00048 class StoredTypeDescriptorFactory;
00049 class SingleOutputExecStreamParams;
00050 class SortedAggExecStreamParams;
00051 
00058 class FENNEL_FARRAGO_EXPORT ExecStreamFactory
00059     : public boost::noncopyable, virtual public FemVisitor
00060 {
00061 protected:
00065     SharedDatabase pDatabase;
00066 
00070     SharedFtrsTableWriterFactory pTableWriterFactory;
00071 
00075     CmdInterpreter::StreamGraphHandle *pStreamGraphHandle;
00076 
00080     SegmentAccessor scratchAccessor;
00081 
00085     ExecStreamEmbryo embryo;
00086 
00090     ExecStreamGraphEmbryo *pGraphEmbryo;
00091 
00095     std::vector<SharedExecStreamSubFactory> subFactories;
00096 
00101     virtual void invokeVisit(
00102         ProxyExecutionStreamDef &);
00103 
00104     // Per-stream overrides for FemVisitor; add new stream types here
00105     virtual void visit(ProxyBarrierStreamDef &);
00106     virtual void visit(ProxyBufferingTupleStreamDef &);
00107     virtual void visit(ProxyBufferReaderStreamDef &);
00108     virtual void visit(ProxyBufferWriterStreamDef &);
00109     virtual void visit(ProxyCartesianProductStreamDef &);
00110     virtual void visit(ProxyIndexLoaderDef &);
00111     virtual void visit(ProxyIndexScanDef &);
00112     virtual void visit(ProxyIndexSearchDef &);
00113     virtual void visit(ProxyJavaSinkStreamDef &);
00114     virtual void visit(ProxyJavaTransformStreamDef &);
00115     virtual void visit(ProxyMergeStreamDef &);
00116     virtual void visit(ProxyMockTupleStreamDef &);
00117     virtual void visit(ProxyTableDeleterDef &);
00118     virtual void visit(ProxyTableInserterDef &);
00119     virtual void visit(ProxyTableUpdaterDef &);
00120     virtual void visit(ProxySortedAggStreamDef &);
00121     virtual void visit(ProxySortingStreamDef &);
00122     virtual void visit(ProxySplitterStreamDef &);
00123     virtual void visit(ProxyValuesStreamDef &);
00124     virtual void visit(ProxyReshapeStreamDef &);
00125     virtual void visit(ProxyNestedLoopJoinStreamDef &);
00126     virtual void visit(ProxyBernoulliSamplingStreamDef &);
00127     virtual void visit(ProxyCalcTupleStreamDef &streamDef);
00128     virtual void visit(ProxyCorrelationJoinStreamDef &streamDef);
00129     virtual void visit(ProxyCollectTupleStreamDef &streamDef);
00130     virtual void visit(ProxyUncollectTupleStreamDef &streamDef);
00131     virtual void visit(ProxyFlatFileTupleStreamDef &streamDef);
00132     virtual void visit(ProxyLhxJoinStreamDef &streamDef);
00133     virtual void visit(ProxyLhxAggStreamDef &streamDef);
00134 
00135     // helpers for above visitors
00136 
00137     void readBTreeReadStreamParams(
00138         BTreeReadExecStreamParams &,
00139         ProxyIndexScanDef &);
00140 
00141     void readIndexWriterParams(
00142         FtrsTableIndexWriterParams &,
00143         ProxyIndexWriterDef &);
00144 
00145     void readTableWriterStreamParams(
00146         FtrsTableWriterExecStreamParams &,
00147         ProxyTableWriterDef &);
00148 
00149     void readBarrierDynamicParams(
00150         BarrierExecStreamParams &,
00151         ProxyBarrierStreamDef &);
00152 
00153     void readColumnList(
00154         ProxyFlatFileTupleStreamDef &streamDef,
00155         std::vector<std::string> &names);
00156 
00157     void implementSortWithBTree(ProxySortingStreamDef &streamDef);
00158 
00159     char readCharParam(const std::string &val);
00160 
00161 public:
00162     explicit ExecStreamFactory(
00163         SharedDatabase pDatabase,
00164         SharedFtrsTableWriterFactory pTableWriterFactory,
00165         CmdInterpreter::StreamGraphHandle *pStreamGraphHandle);
00166 
00167     void setGraphEmbryo(
00168         ExecStreamGraphEmbryo &graphEmbryo);
00169 
00170     void setScratchAccessor(SegmentAccessor &scratchAccessor);
00171 
00172     void addSubFactory(SharedExecStreamSubFactory pSubFactory);
00173 
00174     SharedDatabase getDatabase();
00175 
00179     virtual ExecStreamEmbryo const &visitStream(
00180         ProxyExecutionStreamDef &);
00181 
00182     // helpers for subfactories
00183 
00185     void readTupleDescriptor(
00186         TupleDescriptor& desc, const SharedProxyTupleDescriptor def);
00187 
00198     void createPrivateScratchSegment(ExecStreamParams &params);
00199 
00200     void createQuotaAccessors(ExecStreamParams &params);
00201 
00202     void readExecStreamParams(
00203         ExecStreamParams &,
00204         ProxyExecutionStreamDef &);
00205 
00206     void readTupleStreamParams(
00207         SingleOutputExecStreamParams &,
00208         ProxyTupleStreamDef &);
00209 
00210     void initBTreePrefetchSearchParams(
00211         BTreePrefetchSearchExecStreamParams &,
00212         ProxyIndexSearchDef &);
00213 
00214     void readBTreeStreamParams(
00215         BTreeExecStreamParams &,
00216         ProxyIndexAccessorDef &);
00217 
00218     void readBTreeParams(
00219         BTreeParams &,
00220         ProxyIndexAccessorDef &);
00221 
00222     void readBTreeSearchStreamParams(
00223         BTreeSearchExecStreamParams &,
00224         ProxyIndexSearchDef &);
00225 
00226     void readAggStreamParams(
00227         SortedAggExecStreamParams &,
00228         ProxyAggStreamDef &);
00229 
00230     DynamicParamId readDynamicParamId(const int val);
00231 };
00232 
00233 class FENNEL_FARRAGO_EXPORT ExecStreamSubFactory
00234     : public boost::noncopyable
00235 {
00236 public:
00237     virtual ~ExecStreamSubFactory();
00238 
00250     virtual bool createStream(
00251         ExecStreamFactory &factory,
00252         ProxyExecutionStreamDef &streamDef,
00253         ExecStreamEmbryo &embryo) = 0;
00254 };
00255 
00256 FENNEL_END_NAMESPACE
00257 
00258 #endif
00259 
00260 // End ExecStreamFactory.h

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