BTreeSearchUniqueExecStream.cpp

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/ftrs/BTreeSearchUniqueExecStream.cpp#10 $
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 #include "fennel/common/CommonPreamble.h"
00025 #include "fennel/ftrs/BTreeSearchUniqueExecStream.h"
00026 #include "fennel/btree/BTreeReader.h"
00027 #include "fennel/exec/ExecStreamBufAccessor.h"
00028 
00029 FENNEL_BEGIN_CPPFILE("$Id: //open/dev/fennel/ftrs/BTreeSearchUniqueExecStream.cpp#10 $");
00030 
00031 void BTreeSearchUniqueExecStream::prepare(
00032     BTreeSearchExecStreamParams const &params)
00033 {
00034     // We don't allow directives for unique searches:  every input key
00035     // must be interpreted as a point search.
00036     assert(params.inputDirectiveProj.size() == 0);
00037 
00038     BTreeSearchExecStream::prepare(params);
00039 }
00040 
00041 ExecStreamResult BTreeSearchUniqueExecStream::execute(
00042     ExecStreamQuantum const &quantum)
00043 {
00044     ExecStreamResult rc = precheckConduitBuffers();
00045     if (rc != EXECRC_YIELD) {
00046         return rc;
00047     }
00048 
00049     uint nTuples = 0;
00050     assert(quantum.nTuplesMax > 0);
00051 
00052     // outer loop
00053     for (;;) {
00054         if (!innerSearchLoop()) {
00055             return EXECRC_BUF_UNDERFLOW;
00056         }
00057 
00058         if (nTuples >= quantum.nTuplesMax) {
00059             return EXECRC_QUANTUM_EXPIRED;
00060         }
00061 
00062         if (pOutAccessor->produceTuple(tupleData)) {
00063             ++nTuples;
00064         } else {
00065             return EXECRC_BUF_OVERFLOW;
00066         }
00067 
00068         pReader->endSearch();
00069         pInAccessor->consumeTuple();
00070     }
00071 }
00072 
00073 FENNEL_END_CPPFILE("$Id: //open/dev/fennel/ftrs/BTreeSearchUniqueExecStream.cpp#10 $");
00074 
00075 // End BTreeSearchUniqueExecStream.cpp

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