NestedLoopJoinExecStream.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/exec/NestedLoopJoinExecStream.cpp#5 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2007-2009 The Eigenbase Project
00005 // Copyright (C) 2007-2009 SQLstream, Inc.
00006 // Copyright (C) 2007-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 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/exec/NestedLoopJoinExecStream.h"
00026 #include "fennel/exec/ExecStreamBufAccessor.h"
00027 
00028 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/exec/NestedLoopJoinExecStream.cpp#5 $");
00029 
00030 void NestedLoopJoinExecStream::prepare(
00031     NestedLoopJoinExecStreamParams const &params)
00032 {
00033     CartesianJoinExecStream::prepare(params);
00034 
00035     leftJoinKeys.assign(params.leftJoinKeys.begin(), params.leftJoinKeys.end());
00036     assert(leftJoinKeys.size() <= nLeftAttributes);
00037 }
00038 
00039 bool NestedLoopJoinExecStream::checkNumInputs()
00040 {
00041     return (inAccessors.size() >= 2 && inAccessors.size() <= 3);
00042 }
00043 
00044 void NestedLoopJoinExecStream::open(bool restart)
00045 {
00046     CartesianJoinExecStream::open(restart);
00047 
00048     if (!restart) {
00049         std::vector<NestedLoopJoinKey>::iterator it;
00050         for (it = leftJoinKeys.begin(); it != leftJoinKeys.end(); it++) {
00051             pDynamicParamManager->createParam(
00052                 it->dynamicParamId,
00053                 pLeftBufAccessor->getTupleDesc()[it->leftAttributeOrdinal]);
00054         }
00055 
00056         // Initialize this here and don't reset on restarts, since the
00057         // defined behavior is that the pre-processing is only done once
00058         // per stream graph execution, even if the stream is re-opened in
00059         // restart mode
00060         preProcessingDone = false;
00061     }
00062 }
00063 
00064 ExecStreamResult NestedLoopJoinExecStream::preProcessRightInput()
00065 {
00066     // Create the temporary index by requesting production on the 3rd input
00067     if (!preProcessingDone && inAccessors.size() == 3) {
00068         if (inAccessors[2]->getState() != EXECBUF_EOS) {
00069             inAccessors[2]->requestProduction();
00070             return EXECRC_BUF_UNDERFLOW;
00071         }
00072     }
00073     preProcessingDone = true;
00074     return EXECRC_YIELD;
00075 }
00076 
00077 void NestedLoopJoinExecStream::processLeftInput()
00078 {
00079     std::vector<NestedLoopJoinKey>::iterator it;
00080     for (it = leftJoinKeys.begin(); it != leftJoinKeys.end(); it++) {
00081         pDynamicParamManager->writeParam(
00082             it->dynamicParamId,
00083             outputData[it->leftAttributeOrdinal]);
00084     }
00085 }
00086 
00087 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/exec/NestedLoopJoinExecStream.cpp#5 $");
00088 
00089 // End NestedLoopJoinExecStream.cpp

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