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_dctnrycompress.h 4726 2013-08-07 03:38:36Z bwilkinson $ 19 20 21 /** @file */ 22 23 #ifndef _WE_DCTNRY_COMPRESS_H_ 24 #define _WE_DCTNRY_COMPRESS_H_ 25 26 #include <stdlib.h> 27 28 #include "../dictionary/we_dctnry.h" 29 #include "we_chunkmanager.h" 30 #if defined(_MSC_VER) && defined(WRITEENGINE_DLLEXPORT) 31 #define EXPORT __declspec(dllexport) 32 #else 33 #define EXPORT 34 #endif 35 36 /** Namespace WriteEngine */ 37 namespace WriteEngine 38 { 39 40 /** Class DctnryCompress */ 41 class DctnryCompress0 : public Dctnry 42 { 43 public: 44 /** 45 * @brief Constructor 46 */ 47 EXPORT DctnryCompress0(); 48 EXPORT DctnryCompress0(Log* logger); 49 50 /** 51 * @brief Default Destructor 52 */ 53 EXPORT virtual ~DctnryCompress0(); 54 }; 55 56 57 58 /** Class DctnryCompress1 */ 59 class DctnryCompress1 : public Dctnry 60 { 61 public: 62 /** 63 * @brief Constructor 64 */ 65 EXPORT DctnryCompress1(Log* logger = 0); 66 67 /** 68 * @brief Default Destructor 69 */ 70 EXPORT virtual ~DctnryCompress1(); 71 72 /** 73 * @brief virtual method in FileOp 74 */ 75 EXPORT int flushFile(int rc, std::map<FID, FID>& columnOids); 76 77 /** 78 * @brief virtual method in DBFileOp 79 */ 80 EXPORT int readDBFile(IDBDataFile* pFile, unsigned char* readBuf, const uint64_t lbid, 81 const bool isFbo = false ); 82 83 /** 84 * @brief virtual method in DBFileOp 85 */ 86 EXPORT int writeDBFile(IDBDataFile* pFile, const unsigned char* writeBuf, const uint64_t lbid, 87 const int numOfBlock = 1); 88 89 /** 90 * @brief virtual method in DBFileOp 91 */ 92 EXPORT int writeDBFileNoVBCache(IDBDataFile* pFile, 93 const unsigned char* writeBuf, const int fbo, 94 const int numOfBlock = 1); 95 96 97 /** 98 * @brief virtual method in Dctnry 99 */ 100 IDBDataFile* createDctnryFile(const char* name, int width, const char* mode, int ioBuffSize); 101 102 /** 103 * @brief virtual method in Dctnry 104 */ 105 IDBDataFile* openDctnryFile(bool useTmpSuffix); 106 107 /** 108 * @brief virtual method in Dctnry 109 */ 110 void closeDctnryFile(bool doFlush, std::map<FID, FID>& columnOids); 111 112 /** 113 * @brief virtual method in Dctnry 114 */ 115 int numOfBlocksInFile(); 116 117 /** 118 * @brief For bulkload to use 119 */ setMaxActiveChunkNum(unsigned int maxActiveChunkNum)120 void setMaxActiveChunkNum(unsigned int maxActiveChunkNum) 121 { 122 m_chunkManager->setMaxActiveChunkNum(maxActiveChunkNum); 123 }; setBulkFlag(bool isBulkLoad)124 void setBulkFlag(bool isBulkLoad) 125 { 126 m_chunkManager->setBulkFlag(isBulkLoad); 127 }; setFixFlag(bool isFix)128 void setFixFlag(bool isFix) 129 { 130 m_chunkManager->setFixFlag(isFix); 131 }; checkFixLastDictChunk()132 int checkFixLastDictChunk () 133 { 134 return m_chunkManager->checkFixLastDictChunk(m_dctnryOID, m_dbRoot, m_partition, m_segment); 135 }; 136 // void chunkManager(ChunkManager* cm); 137 138 /** 139 * @brief virtual method in FileOp 140 */ setTransId(const TxnID & transId)141 void setTransId(const TxnID& transId) 142 { 143 Dctnry::setTransId(transId); 144 145 if (m_chunkManager) m_chunkManager->setTransId(transId); 146 } 147 148 /** 149 * @brief Set the IsInsert flag in the ChunkManager. 150 * This forces flush at end of statement. Used only for bulk insert. 151 */ setIsInsert(bool isInsert)152 void setIsInsert(bool isInsert) 153 { 154 m_chunkManager->setIsInsert(isInsert); 155 } 156 157 protected: 158 159 /** 160 * @brief virtual method in FileOp 161 */ 162 int updateDctnryExtent(IDBDataFile* pFile, int nBlocks); 163 164 /** 165 * @brief convert lbid to fbo 166 */ 167 int lbidToFbo(const uint64_t lbid, int& fbo); 168 }; 169 170 171 } //end of namespace 172 173 #undef EXPORT 174 175 #endif // _WE_DCTNRY_COMPRESS_H_ 176