FtrsTableWriter.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/ftrs/FtrsTableWriter.h#10 $
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_FtrsTableWriter_Included
00025 #define Fennel_FtrsTableWriter_Included
00026 
00027 #include "fennel/ftrs/BTreeInsertExecStream.h"
00028 #include "fennel/txn/LogicalTxnParticipant.h"
00029 #include <boost/scoped_array.hpp>
00030 
00031 FENNEL_BEGIN_NAMESPACE
00032 
00033 class SXMutex;
00034 
00035 struct FENNEL_FTRS_EXPORT FtrsTableIndexWriterParams
00036     : public BTreeInsertExecStreamParams
00037 {
00038     TupleProjection inputProj;
00039 
00040     bool updateInPlace;
00041 };
00042 
00046 struct FENNEL_FTRS_EXPORT FtrsTableWriterParams
00047     : public ConduitExecStreamParams
00048 {
00052     std::vector<FtrsTableIndexWriterParams> indexParams;
00053 
00057     PageOwnerId tableId;
00058 
00063     TupleProjection updateProj;
00064 };
00065 
00066 struct FENNEL_FTRS_EXPORT FtrsTableIndexWriter
00067 {
00068     SharedBTreeWriter pWriter;
00069     Distinctness distinctness;
00070     TupleProjection inputProj;
00071     TupleProjection inputKeyProj;
00072     TupleData tupleData;
00073     BTreeOwnerRootMap *pRootMap;
00074     bool updateInPlace;
00075 };
00076 
00081 class FENNEL_FTRS_EXPORT FtrsTableWriter
00082     : public LogicalTxnParticipant
00083 {
00084     friend class FtrsTableWriterFactory;
00085 
00086     typedef std::vector<FtrsTableIndexWriter> IndexWriterVector;
00087 
00088     uint nAttrs;
00089     TupleAccessor tupleAccessor;
00090     IndexWriterVector indexWriters;
00091     FtrsTableIndexWriter *pClusteredIndexWriter;
00092     TupleProjection updateProj;
00093     TupleData updateTupleData;
00094     TupleData *pTupleData;
00095     boost::scoped_array<FixedBuffer> logBuf;
00096 
00097     FtrsTableIndexWriter &createIndexWriter(
00098         FtrsTableIndexWriter &,
00099         FtrsTableIndexWriterParams const &);
00100     inline void insertIntoIndex(FtrsTableIndexWriter &);
00101     inline void deleteFromIndex(FtrsTableIndexWriter &);
00102     void describeIndex(FtrsTableIndexWriter &,ByteOutputStream *pLogStream);
00103     void executeUpdate(bool reverse);
00104     inline void modifyAllIndexes(LogicalActionType);
00105     inline void modifySomeIndexes(
00106         LogicalActionType,
00107         IndexWriterVector::iterator &,
00108         IndexWriterVector::iterator);
00109     inline void executeTuple(LogicalActionType);
00110     inline void copyNewValues();
00111     inline void copyOldValues();
00112     inline bool searchForIndexKey(FtrsTableIndexWriter &);
00113 
00114     explicit FtrsTableWriter(FtrsTableWriterParams const &params);
00115     PageOwnerId getTableId();
00116 
00117 public:
00121     static const LogicalActionType ACTION_INSERT;
00122 
00126     static const LogicalActionType ACTION_DELETE;
00127 
00131     static const LogicalActionType ACTION_UPDATE;
00132 
00136     static const LogicalActionType ACTION_REVERSE_UPDATE;
00137 
00154     RecordNum execute(
00155         ExecStreamQuantum const &quantum,
00156         ExecStreamBufAccessor &bufAccessor,
00157         LogicalActionType actionType,
00158         SXMutex &actionMutex);
00159 
00160     uint getIndexCount() const;
00161     void openIndexWriters();
00162     void closeIndexWriters();
00163 
00164     // implement LogicalTxnParticipant
00165     virtual LogicalTxnClassId getParticipantClassId() const;
00166     virtual void describeParticipant(
00167         ByteOutputStream &logStream);
00168     virtual void undoLogicalAction(
00169         LogicalActionType actionType,
00170         ByteInputStream &logStream);
00171     virtual void redoLogicalAction(
00172         LogicalActionType actionType,
00173         ByteInputStream &logStream);
00174 
00175 };
00176 
00177 FENNEL_END_NAMESPACE
00178 
00179 #endif
00180 
00181 // End FtrsTableWriter.h

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