LcsColumnReader.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/lucidera/colstore/LcsColumnReader.h#17 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 LucidEra, Inc.
00005 // Copyright (C) 2005-2009 The Eigenbase Project
00006 //
00007 // This program is free software; you can redistribute it and/or modify it
00008 // under the terms of the GNU General Public License as published by the Free
00009 // Software Foundation; either version 2 of the License, or (at your option)
00010 // any later version approved by The Eigenbase Project.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with this program; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 */
00021 
00022 #ifndef Fennel_LcsColumnReader_Included
00023 #define Fennel_LcsColumnReader_Included
00024 
00025 #include "fennel/lucidera/colstore/LcsClusterNode.h"
00026 #include "fennel/lucidera/colstore/LcsBitOps.h"
00027 #include "fennel/lucidera/colstore/LcsResidualColumnFilters.h"
00028 
00029 
00030 FENNEL_BEGIN_NAMESPACE
00031 
00035 class FENNEL_LCS_EXPORT LcsColumnReader
00036     : public boost::noncopyable
00037 {
00041     LcsClusterReader *pScan;
00042 
00046     uint colOrd;
00047 
00051     PLcsBatchDir pBatch;
00052 
00056     PBuffer pValues;
00057 
00061     PBuffer pBase;
00062 
00066     PtrVec origin;
00067 
00071     WidthVec width;
00072 
00073     /* Number of entries per vector
00074      */
00075     uint iV;
00076 
00080     PBitVecFuncPtr pFuncReadBitVec;
00081 
00086     const PBuffer (LcsColumnReader:: *pGetCurrentValueFunc) ();
00087 
00091     LcsResidualColumnFilters filters;
00092 
00096     TupleProjection allProj;
00097 
00101     const PBuffer getCompressedValue();
00102 
00106     const PBuffer getFixedValue();
00107 
00111     const PBuffer getVariableValue();
00112 
00128     uint findVal(
00129         uint filterPos,
00130         bool highBound,
00131         bool bStrict,
00132         TupleDataWithBuffer &readerKeyData);
00133 
00146     void findBounds(
00147         uint filterPos,
00148         uint &nLoVal,
00149         uint &nHiVal,
00150         TupleDataWithBuffer &readerKeyData);
00151 
00155     void buildContainsMap();
00156 
00157 public:
00165     void init(LcsClusterReader *pScanInit, uint colOrdInit)
00166     {
00167         pScan = pScanInit;
00168         colOrd = colOrdInit;
00169         filters.hasResidualFilters = false;
00170         filters.filterDataInitialized = false;
00171         allProj.push_back(0);
00172     }
00173 
00178     void sync();
00179 
00183     bool batchIsCompressed() const
00184     {
00185         return pBatch->mode == LCS_COMPRESSED;
00186     }
00187 
00191     bool batchIsFixed() const
00192     {
00193         return pBatch->mode == LCS_FIXED;
00194     }
00195 
00199     const PBuffer getCurrentValue()
00200     {
00201         return (this->*pGetCurrentValueFunc)();
00202     }
00203 
00208     uint16_t getCurrentValueCode() const;
00209 
00210     // The following functions access the distinct values in a compressed
00211     // batch.  The offsets table contains one offset for each distinct value.
00212     // GetBatchValue() finds the address of i-th distinct value by adding the
00213     // base pointer of the batch to the i-th entry in the offset table.
00217     uint getBatchValCount() const
00218     {
00219         return pBatch->nVal;
00220     }
00221 
00225     const PBuffer getBatchBase() const
00226     {
00227         return pBase;
00228     }
00229 
00233     const uint16_t *getBatchOffsets() const
00234     {
00235         return (const uint16_t *) pValues;
00236     }
00237 
00243     const PBuffer getBatchValue(uint iValCode) const
00244     {
00245         return (const PBuffer) (getBatchBase() + getBatchOffsets()[iValCode]);
00246     }
00247 
00265     void readCompressedBatch(uint count, uint16_t *pValCodes, uint *pActCount);
00266 
00270     struct LcsResidualColumnFilters& getFilters()
00271     {
00272         return filters;
00273     }
00274 
00284     bool applyFilters(
00285         TupleDescriptor &projDescriptor,
00286         TupleData &outputTupleData);
00287 };
00288 
00289 FENNEL_END_NAMESPACE
00290 
00291 #endif
00292 
00293 // End LcsColumnReader.h

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