ReshapeExecStream.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/exec/ReshapeExecStream.h#9 $
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_ReshapeExecStream_Included
00025 #define Fennel_ReshapeExecStream_Included
00026 
00027 #include "fennel/common/FemEnums.h"
00028 #include "fennel/exec/ConduitExecStream.h"
00029 #include "fennel/exec/DynamicParam.h"
00030 #include "fennel/tuple/TupleProjectionAccessor.h"
00031 
00032 #include <boost/shared_array.hpp>
00033 
00034 FENNEL_BEGIN_NAMESPACE
00035 
00040 struct FENNEL_EXEC_EXPORT ReshapeParameter
00041 {
00045     DynamicParamId dynamicParamId;
00046 
00051     uint compareOffset;
00052 
00057     bool outputParam;
00058 
00059     ReshapeParameter(
00060         DynamicParamId dynamicParamIdInit,
00061         uint compareOffsetInit,
00062         bool outputParamInit) :
00063         dynamicParamId(dynamicParamIdInit),
00064         compareOffset(compareOffsetInit),
00065         outputParam(outputParamInit)
00066     {
00067     }
00068 };
00069 
00073 struct FENNEL_EXEC_EXPORT ReshapeExecStreamParams
00074     : public ConduitExecStreamParams
00075 {
00081     CompOperator compOp;
00082 
00086     boost::shared_array<FixedBuffer> pCompTupleBuffer;
00087 
00094     TupleProjection inputCompareProj;
00095 
00099     TupleProjection outputProj;
00100 
00105     std::vector<ReshapeParameter> dynamicParameters;
00106 };
00107 
00130 class FENNEL_EXEC_EXPORT ReshapeExecStream
00131     : public ConduitExecStream
00132 {
00136     CompOperator compOp;
00137 
00141     std::vector<ReshapeParameter> dynamicParameters;
00142 
00147     bool paramsRead;
00148 
00153     TupleData paramCompareData;
00154 
00159     TupleProjectionAccessor inputCompareProjAccessor;
00160 
00165     TupleData inputCompareData;
00166 
00170     boost::shared_array<FixedBuffer> compTupleBuffer;
00171 
00175     TupleDescriptor compTupleDesc;
00176 
00180     uint numCompDynParams;
00181 
00185     TupleProjection lastKey;
00186 
00190     TupleDescriptor lastKeyDesc;
00191 
00195     TupleProjectionAccessor outputProjAccessor;
00196 
00201     TupleDescriptor inputOutputDesc;
00202 
00206     TupleData inputOutputData;
00207 
00211     TupleDescriptor outputDesc;
00212 
00216     TupleData outputData;
00217 
00222     bool castRequired;
00223 
00227     bool producePending;
00228 
00239     void initCompareData(
00240         ReshapeExecStreamParams const &params,
00241         TupleDescriptor const &inputDesc,
00242         TupleAccessor const &inputAccessor);
00243 
00254     void copyCompareTuple(
00255         TupleDescriptor const &tupleDesc,
00256         TupleData &tupleData,
00257         PBuffer tupleBuffer);
00258 
00271     bool checkCastTypes(
00272         const TupleProjection &compareProj,
00273         const TupleDescriptor &inputTupleDesc,
00274         const TupleDescriptor &outputTupleDesc);
00275 
00285     bool nullFilter(const TupleProjection &compareProj, uint colno);
00286 
00293     void readDynamicParams();
00294 
00300     bool compareInput();
00301 
00306     void castOutput();
00307 
00308 public:
00309     // implement ExecStream
00310     virtual void prepare(ReshapeExecStreamParams const &params);
00311     virtual void open(bool restart);
00312     virtual ExecStreamResult execute(ExecStreamQuantum const &quantum);
00313     virtual void closeImpl();
00314 };
00315 
00316 FENNEL_END_NAMESPACE
00317 
00318 #endif
00319 
00320 // End ReshapeExecStream.h

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