LhxHashGenerator.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/hashexe/LhxHashGenerator.h#3 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2006-2009 The Eigenbase Project
00005 // Copyright (C) 2009-2009 SQLstream, Inc.
00006 // Copyright (C) 2006-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef Fennel_LhxHashGenerator_Included
00024 #define Fennel_LhxHashGenerator_Included
00025 
00026 #include "fennel/tuple/TupleData.h"
00027 #include "fennel/tuple/TupleDescriptor.h"
00028 
00029 #include "fennel/hashexe/LhxHashBase.h"
00030 
00031 using namespace std;
00032 
00033 FENNEL_BEGIN_NAMESPACE
00034 
00043 class FENNEL_HASHEXE_EXPORT LhxHashGenerator
00044 {
00045 private:
00046     /*
00047      * Level at which the hash value seed is generated.
00048      */
00049     uint level;
00050 
00051     /*
00052      * The seed value.
00053      */
00054     uint hashValueSeed;
00055 
00056     // REVIEW jvs 25-Aug-2006: Let's unify the magic tables.  Result can
00057     // probably go to common/HashUtil.h since there's nothing LucidDB-specific
00058     // about it.
00059     /*
00060      * The magic table(same as the one used in LcsHash.cpp).
00061      */
00062     uint8_t *magicTable;
00063 
00064     // REVIEW jvs 25-Aug-2006: hashValues below are actually inout, right?
00065 
00073     void hashOneBuffer(uint &hashValue, PConstBuffer pBuf, uint bufSize);
00074 
00083     void hashOneColumn(
00084         uint &hashValue,
00085         TupleDatum const &inputCol,
00086         LhxHashTrim isVarChar);
00087 
00088 public:
00092     void init(uint levelInit);
00093 
00097     uint getLevel();
00098 
00111     uint hash(
00112         TupleData const &inputTuple,
00113         TupleProjection const &keyProjection,
00114         vector<LhxHashTrim> const &isKeyColVarChar);
00115 
00125     uint hash(TupleDatum const &inputCol, LhxHashTrim isVarChar);
00126 
00135     uint hash(PConstBuffer pBuf, uint bufSize);
00136 };
00137 
00138 inline uint LhxHashGenerator::getLevel()
00139 {
00140     return level;
00141 }
00142 
00143 inline uint LhxHashGenerator::hash(
00144     TupleDatum const &inputCol, LhxHashTrim isVarChar)
00145 {
00146     uint hashValue = hashValueSeed;
00147     hashOneColumn(hashValue, inputCol, isVarChar);
00148     return hashValue;
00149 }
00150 
00151 inline uint LhxHashGenerator::hash(PConstBuffer pBuf, uint bufSize)
00152 {
00153     uint hashValue = hashValueSeed;
00154     hashOneBuffer(hashValue, pBuf, bufSize);
00155     return hashValue;
00156 }
00157 
00158 FENNEL_END_NAMESPACE
00159 
00160 #endif
00161 
00162 // End LhxHashGenerator.h

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