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 // $Id: we_colopcompress.h 4726 2013-08-07 03:38:36Z bwilkinson $ 19 20 21 /** @file */ 22 23 #ifndef _WE_COLOP_COMPRESS_H_ 24 #define _WE_COLOP_COMPRESS_H_ 25 26 #include <stdlib.h> 27 28 #include "we_colop.h" 29 #include "we_chunkmanager.h" 30 31 #if defined(_MSC_VER) && defined(WRITEENGINE_DLLEXPORT) 32 #define EXPORT __declspec(dllexport) 33 #else 34 #define EXPORT 35 #endif 36 37 /** Namespace WriteEngine */ 38 namespace WriteEngine 39 { 40 41 /** Class ColumnOpCompress0 */ 42 class ColumnOpCompress0 : public ColumnOp 43 { 44 public: 45 /** 46 * @brief Constructor 47 */ 48 EXPORT ColumnOpCompress0(); 49 EXPORT ColumnOpCompress0(Log* logger); 50 51 /** 52 * @brief Default Destructor 53 */ 54 EXPORT virtual ~ColumnOpCompress0(); 55 56 /** 57 * @brief virtual method in ColumnOp 58 */ 59 IDBDataFile* openFile(const Column& column, uint16_t dbRoot, uint32_t partition, 60 uint16_t segment, std::string& segFile, bool useTmpSuffix, const char* mode = "r+b", 61 int ioBuffSize = DEFAULT_BUFSIZ) const; 62 63 /** 64 * @brief virtual method in ColumnOp 65 */ 66 bool abbreviatedExtent(IDBDataFile* pFile, int colWidth) const; 67 68 /** 69 * @brief virtual method in ColumnOp 70 */ 71 int blocksInFile(IDBDataFile* pFile) const; 72 73 74 protected: 75 76 /** 77 * @brief virtual method in ColumnOp 78 */ 79 int readBlock(IDBDataFile* pFile, unsigned char* readBuf, const uint64_t fbo); 80 81 /** 82 * @brief virtual method in ColumnOp 83 */ 84 int saveBlock(IDBDataFile* pFile, const unsigned char* writeBuf, const uint64_t fbo); 85 86 87 private: 88 }; 89 90 91 92 /** Class ColumnOpCompress1 */ 93 class ColumnOpCompress1 : public ColumnOp 94 { 95 public: 96 /** 97 * @brief Constructor 98 */ 99 EXPORT ColumnOpCompress1(Log* logger = 0); 100 101 /** 102 * @brief Default Destructor 103 */ 104 EXPORT virtual ~ColumnOpCompress1(); 105 106 /** 107 * @brief virtual method in FileOp 108 */ 109 EXPORT int flushFile(int rc, std::map<FID, FID>& columnOids); 110 111 /** 112 * @brief virtual method in FileOp 113 */ 114 int expandAbbrevColumnExtent(IDBDataFile* pFile, uint16_t dbRoot, uint64_t emptyVal, int width); 115 116 /** 117 * @brief virtual method in ColumnOp 118 */ 119 IDBDataFile* openFile(const Column& column, uint16_t dbRoot, uint32_t partition, 120 uint16_t segment, std::string& segFile, bool useTmpSuffix, const char* mode = "r+b", 121 int ioBuffSize = DEFAULT_BUFSIZ) const; 122 123 /** 124 * @brief virtual method in ColumnOp 125 */ 126 bool abbreviatedExtent(IDBDataFile* pFile, int colWidth) const; 127 128 /** 129 * @brief virtual method in ColumnOp 130 */ 131 int blocksInFile(IDBDataFile* pFile) const; 132 133 // void chunkManager(ChunkManager* cm); 134 135 /** 136 * @brief virtual method in FileOp 137 */ setTransId(const TxnID & transId)138 void setTransId(const TxnID& transId) 139 { 140 ColumnOp::setTransId(transId); 141 142 if (m_chunkManager) m_chunkManager->setTransId(transId); 143 } 144 setBulkFlag(bool isBulkLoad)145 void setBulkFlag(bool isBulkLoad) 146 { 147 m_chunkManager->setBulkFlag(isBulkLoad); 148 }; 149 setFixFlag(bool isFix)150 void setFixFlag(bool isFix) 151 { 152 m_chunkManager->setFixFlag(isFix); 153 }; 154 155 protected: 156 157 /** 158 * @brief virtual method in FileOp 159 */ 160 int updateColumnExtent(IDBDataFile* pFile, int nBlocks); 161 162 /** 163 * @brief virtual method in ColumnOp 164 */ 165 void closeColumnFile(Column& column) const; 166 167 /** 168 * @brief virtual method in ColumnOp 169 */ 170 int readBlock(IDBDataFile* pFile, unsigned char* readBuf, const uint64_t fbo); 171 172 /** 173 * @brief virtual method in ColumnOp 174 */ 175 int saveBlock(IDBDataFile* pFile, const unsigned char* writeBuf, const uint64_t fbo); 176 177 /** 178 * @brief Set the IsInsert flag in the ChunkManager. 179 * This forces flush at end of statement. Used only for bulk insert. 180 */ setIsInsert(bool isInsert)181 void setIsInsert(bool isInsert) 182 { 183 m_chunkManager->setIsInsert(isInsert); 184 } 185 186 private: 187 }; 188 189 190 } //end of namespace 191 192 #undef EXPORT 193 194 #endif // _WE_COLOP_COMPRESS_H_ 195