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: tablecolumn.h 9655 2013-06-25 23:08:13Z xlou $ 20 * 21 *****************************************************************************/ 22 23 /** @file */ 24 25 #ifndef _TABLECOLUMN_H_ 26 #define _TABLECOLUMN_H_ 27 28 #include <vector> 29 #include <boost/any.hpp> 30 31 #include "calpontsystemcatalog.h" 32 #include "bytestream.h" 33 #include "datalist.h" 34 #include "elementtype.h" 35 36 //#define TC_CHECK_RIDS 1 37 38 #if defined(_MSC_VER) && defined(JOBLIST_DLLEXPORT) 39 #define EXPORT __declspec(dllexport) 40 #else 41 #define EXPORT 42 #endif 43 44 namespace joblist 45 { 46 47 /** @brief create a JobList object from a CalpontExecutionPlan object 48 * 49 * Class TableColumn contains a column and it's values. TableColumn objects are contained in a 50 * TableBand object and used to deliver a band of rows from ExeMgr to the front end. 51 */ 52 class TableColumn 53 { 54 public: 55 56 /** @brief enum with the supported value types. 57 */ 58 enum supportedType 59 { 60 UINT8, 61 UINT16, 62 UINT32, 63 UINT64, 64 STRING, 65 UNDEFINED 66 }; 67 68 /** @brief constructor 69 */ 70 EXPORT TableColumn(const execplan::CalpontSystemCatalog::OID columnOID, const supportedType columnType); 71 72 EXPORT TableColumn(); 73 74 /** @brief getter for the column's OID. 75 */ getColumnOID()76 inline execplan::CalpontSystemCatalog::OID getColumnOID() const 77 { 78 return fColumnOID; 79 } 80 81 /** @brief getter for the column's values. 82 */ getIntValues()83 inline const boost::shared_ptr<std::vector<uint64_t> > getIntValues() 84 { 85 return fIntValues; 86 } 87 getStrValues()88 inline const boost::shared_ptr<std::vector<std::string> > getStrValues() 89 { 90 return fStrValues; 91 } 92 isNullColumn()93 inline bool isNullColumn() const 94 { 95 return fIsNullColumn; 96 } 97 98 // pre-build the bytestream to be returned 99 EXPORT void serialize(); 100 101 /** @brief serializes the object into the passed byte stream. 102 */ 103 EXPORT void serialize(messageqcpp::ByteStream& b); 104 105 /** @brief inflates the object from the passed byte stream. 106 */ 107 EXPORT void unserialize(messageqcpp::ByteStream& b); 108 109 /** @brief adds the column and it's values to the passed NJLSysDataList or appends the values if the column is already included in the NJLSysDataList. 110 */ 111 EXPORT void addToSysDataList(execplan::CalpontSystemCatalog::NJLSysDataList& sysDataList, const std::vector<uint64_t>& rids); 112 113 #if 0 114 EXPORT void addToSysDataRids(execplan::CalpontSystemCatalog::NJLSysDataList& sysDataList, const std::vector<uint64_t>& rids); 115 #endif setIntValues(boost::shared_ptr<std::vector<uint64_t>> sv)116 inline void setIntValues(boost::shared_ptr<std::vector<uint64_t> > sv) 117 { 118 fIntValues = sv; 119 fIsNullColumn = fIntValues->empty(); 120 } 121 setStrValues(boost::shared_ptr<std::vector<std::string>> sv)122 inline void setStrValues(boost::shared_ptr<std::vector<std::string> > sv) 123 { 124 fStrValues = sv; 125 fIsNullColumn = fStrValues->empty(); 126 } 127 getColumnType()128 inline supportedType getColumnType() 129 { 130 return fColumnType; 131 } 132 133 #ifdef TC_CHECK_RIDS rids()134 const std::vector<uint64_t>& rids() const 135 { 136 return fRids; 137 } 138 #endif 139 140 private: 141 execplan::CalpontSystemCatalog::OID fColumnOID; 142 boost::shared_ptr<std::vector <uint64_t> > fIntValues; 143 boost::shared_ptr<std::vector <std::string> > fStrValues; 144 bool fIsNullColumn; 145 supportedType fColumnType; 146 boost::shared_ptr<messageqcpp::ByteStream> preserialized; 147 #ifdef TC_CHECK_RIDS 148 std::vector<uint64_t> fRids; 149 #endif 150 151 // defaults okay 152 //TableColumn(const TableColumn& rhs); // no copies 153 //TableColumn& operator=(const TableColumn& rhs); // no assignments 154 }; 155 156 #undef EXPORT 157 158 } // namespace 159 160 #endif 161 162