1 /* Copyright (C) 2014 InfiniDB, Inc. 2 3 This program is free software; you can redistribute it and/or 4 modify it under the terms of the GNU General Public License 5 as published by the Free Software Foundation; version 2 of 6 the License. 7 8 This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License 14 along with this program; if not, write to the Free Software 15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 MA 02110-1301, USA. */ 17 18 // 19 // $Id: columncommand.h 2057 2013-02-13 17:00:10Z pleblanc $ 20 // C++ Interface: columncommand 21 // 22 // Description: 23 // 24 // 25 // Author: Patrick LeBlanc <pleblanc@calpont.com>, (C) 2008 26 // 27 // Copyright: See COPYING file that comes with this distribution 28 // 29 // 30 31 #ifndef COLUMNCOMMAND_H_ 32 #define COLUMNCOMMAND_H_ 33 34 #include "command.h" 35 #include "calpontsystemcatalog.h" 36 37 namespace primitiveprocessor 38 { 39 40 // #warning got the ColumnCommand definition 41 class ColumnCommand : public Command 42 { 43 public: 44 ColumnCommand(); 45 virtual ~ColumnCommand(); 46 getLBID()47 inline uint64_t getLBID() 48 { 49 return lbid; 50 } getWidth()51 inline uint8_t getWidth() 52 { 53 return colType.colWidth; 54 } getScale()55 inline uint8_t getScale() 56 { 57 return colType.scale; 58 } getFilterCount()59 uint16_t getFilterCount() 60 { 61 return filterCount; 62 } getColType()63 const execplan::CalpontSystemCatalog::ColType& getColType() 64 { 65 return colType; 66 } 67 68 void execute(); 69 void execute(int64_t* vals); //used by RTSCommand to redirect values 70 void prep(int8_t outputType, bool makeAbsRids); 71 void project(); 72 void projectIntoRowGroup(rowgroup::RowGroup& rg, uint32_t pos); 73 void nextLBID(); isScan()74 bool isScan() 75 { 76 return _isScan; 77 } 78 void createCommand(messageqcpp::ByteStream&); 79 void resetCommand(messageqcpp::ByteStream&); setMakeAbsRids(bool m)80 void setMakeAbsRids(bool m) 81 { 82 makeAbsRids = m; 83 } 84 bool willPrefetch(); 85 uint64_t getEmptyRowValue( const execplan::CalpontSystemCatalog::ColDataType dataType, const int width ) const; 86 int64_t getLastLbid(); 87 void getLBIDList(uint32_t loopCount, std::vector<int64_t>* lbids); 88 89 virtual SCommand duplicate(); 90 bool operator==(const ColumnCommand&) const; 91 bool operator!=(const ColumnCommand&) const; 92 93 /* OR hacks */ setScan(bool b)94 void setScan(bool b) 95 { 96 _isScan = b; 97 } 98 void disableFilters(); 99 void enableFilters(); 100 getCompType()101 int getCompType() const 102 { 103 return colType.compressionType; 104 } 105 106 protected: 107 virtual void loadData(); 108 void duplicate(ColumnCommand*); 109 110 // we only care about the width and type fields. 111 //On the PM the rest is uninitialized 112 execplan::CalpontSystemCatalog::ColType colType; 113 114 private: 115 ColumnCommand(const ColumnCommand&); 116 ColumnCommand& operator=(const ColumnCommand&); 117 118 void _execute(); 119 void issuePrimitive(); 120 void processResult(); 121 void process_OT_BOTH(); 122 void process_OT_RID(); 123 void process_OT_DATAVALUE(); 124 void process_OT_ROWGROUP(); 125 void projectResult(); 126 void projectResultRG(rowgroup::RowGroup& rg, uint32_t pos); 127 void removeRowsFromRowGroup(rowgroup::RowGroup&); 128 void makeScanMsg(); 129 void makeStepMsg(); 130 void setLBID(uint64_t rid); 131 132 bool _isScan; 133 134 boost::scoped_array<uint8_t> inputMsg; 135 NewColRequestHeader* primMsg; 136 NewColResultHeader* outMsg; 137 138 // the length of base prim msg, which is everything up to the 139 // rid array for the pCol message 140 uint32_t baseMsgLength; 141 142 uint64_t lbid; 143 uint32_t traceFlags; // probably move this to Command 144 uint8_t BOP; 145 messageqcpp::ByteStream filterString; 146 uint16_t filterCount; 147 bool makeAbsRids; 148 int64_t* values; // this is usually bpp->values; RTSCommand needs to use a different container 149 150 uint8_t mask, shift; // vars for the selective block loader 151 152 // counters to decide whether to prefetch or not 153 uint32_t blockCount, loadCount; 154 155 boost::shared_ptr<primitives::ParsedColumnFilter> parsedColumnFilter; 156 157 /* OR hacks */ 158 boost::shared_ptr<primitives::ParsedColumnFilter> emptyFilter; 159 bool suppressFilter; 160 161 std::vector<uint64_t> lastLbid; 162 163 /* speculative optimizations for projectintorowgroup() */ 164 rowgroup::Row r; 165 uint32_t rowSize; 166 167 bool wasVersioned; 168 169 friend class RTSCommand; 170 }; 171 172 } 173 174 #endif 175 // vim:ts=4 sw=4: 176 177