From dd6023e729ff14469a134946b17d972744dc19c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jun 2004 12:01:47 +0000 Subject: [PATCH] removed myVector from ndb restore BitKeeper/deleted/.del-myVector.hpp~4ecd4d6d4c8fa2f6: Delete: ndb/src/kernel/blocks/backup/restore/myVector.hpp ndb/include/util/Parser.hpp: bug-fix missing delete ndb/src/kernel/blocks/backup/restore/Restore.cpp: removed myVector ndb/src/kernel/blocks/backup/restore/Restore.hpp: removed myVector ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp: removed myVector ndb/src/kernel/blocks/backup/restore/main.cpp: removed myVector --- ndb/include/util/Parser.hpp | 1 + .../kernel/blocks/backup/restore/Restore.cpp | 14 +- .../kernel/blocks/backup/restore/Restore.hpp | 27 ++-- .../backup/restore/consumer_restore.cpp | 4 +- ndb/src/kernel/blocks/backup/restore/main.cpp | 18 +-- .../kernel/blocks/backup/restore/myVector.hpp | 128 ------------------ 6 files changed, 32 insertions(+), 160 deletions(-) delete mode 100644 ndb/src/kernel/blocks/backup/restore/myVector.hpp diff --git a/ndb/include/util/Parser.hpp b/ndb/include/util/Parser.hpp index 9c2f02b6024..65cf24db633 100644 --- a/ndb/include/util/Parser.hpp +++ b/ndb/include/util/Parser.hpp @@ -165,6 +165,7 @@ Parser::Parser(const ParserRow rows[], class InputStream & in, template inline Parser::~Parser(){ + delete impl; } template diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.cpp b/ndb/src/kernel/blocks/backup/restore/Restore.cpp index 6df06276b1b..24d2cfbfe35 100644 --- a/ndb/src/kernel/blocks/backup/restore/Restore.cpp +++ b/ndb/src/kernel/blocks/backup/restore/Restore.cpp @@ -82,14 +82,14 @@ RestoreMetaData::RestoreMetaData(const char* path, Uint32 nodeId, Uint32 bNo) { } RestoreMetaData::~RestoreMetaData(){ - for(int i = 0; igetTableId() == tableId) return allTables[i]; return NULL; @@ -207,7 +207,7 @@ TableS::TableS(NdbTableImpl* tableImpl) TableS::~TableS() { - for (int i = 0; i < allAttributesDesc.size(); i++) + for (Uint32 i= 0; i < allAttributesDesc.size(); i++) delete allAttributesDesc[i]; } @@ -334,7 +334,7 @@ RestoreDataIterator::getNextTuple(int & res) Uint32 *buf_ptr = (Uint32*)_buf_ptr, *ptr = buf_ptr; ptr += m_currentTable->m_nullBitmaskSize; - for(int i = 0; i < m_currentTable->m_fixedKeys.size(); i++){ + for(Uint32 i= 0; i < m_currentTable->m_fixedKeys.size(); i++){ assert(ptr < buf_ptr + dataLength); const Uint32 attrId = m_currentTable->m_fixedKeys[i]->attrId; @@ -355,7 +355,7 @@ RestoreDataIterator::getNextTuple(int & res) ptr += sz; } - for(int i = 0; im_fixedAttribs.size(); i++){ + for(Uint32 i = 0; i < m_currentTable->m_fixedAttribs.size(); i++){ assert(ptr < buf_ptr + dataLength); const Uint32 attrId = m_currentTable->m_fixedAttribs[i]->attrId; @@ -377,7 +377,7 @@ RestoreDataIterator::getNextTuple(int & res) ptr += sz; } - for(int i = 0; im_variableAttribs.size(); i++){ + for(Uint32 i = 0; i < m_currentTable->m_variableAttribs.size(); i++){ const Uint32 attrId = m_currentTable->m_variableAttribs[i]->attrId; AttributeData * attr_data = m_tuple.getData(attrId); @@ -911,7 +911,7 @@ operator<<(NdbOut& ndbout, const LogEntry& logE) ndbout << "Unknown log entry type (not insert, delete or update)" ; } - for (int i = 0; i < logE.size();i++) + for (Uint32 i= 0; i < logE.size();i++) { const AttributeS * attr = logE[i]; ndbout << attr->Desc->m_column->getName() << "="; diff --git a/ndb/src/kernel/blocks/backup/restore/Restore.hpp b/ndb/src/kernel/blocks/backup/restore/Restore.hpp index 5bdfb93ee83..e9149e38e44 100644 --- a/ndb/src/kernel/blocks/backup/restore/Restore.hpp +++ b/ndb/src/kernel/blocks/backup/restore/Restore.hpp @@ -21,7 +21,6 @@ #include #include #include -#include "myVector.hpp" #include #include @@ -122,11 +121,11 @@ class TableS { Uint32 schemaVersion; Uint32 backupVersion; - myVector allAttributesDesc; - myVector m_fixedKeys; - //myVector m_variableKey; - myVector m_fixedAttribs; - myVector m_variableAttribs; + Vector allAttributesDesc; + Vector m_fixedKeys; + //Vector m_variableKey; + Vector m_fixedAttribs; + Vector m_variableAttribs; Uint32 m_noOfNullable; Uint32 m_nullBitmaskSize; @@ -225,7 +224,7 @@ public: class RestoreMetaData : public BackupFile { - myVector allTables; + Vector allTables; bool readMetaFileHeader(); bool readMetaTableDesc(); @@ -280,13 +279,13 @@ public: }; EntryType m_type; const TableS * m_table; - myVector m_values; - myVector m_values_e; + Vector m_values; + Vector m_values_e; AttributeS *add_attr() { AttributeS * attr; if (m_values_e.size() > 0) { attr = m_values_e[m_values_e.size()-1]; - m_values_e.pop_back(); + m_values_e.erase(m_values_e.size()-1); } else { @@ -296,18 +295,18 @@ public: return attr; } void clear() { - for(int i= 0; i < m_values.size(); i++) + for(Uint32 i= 0; i < m_values.size(); i++) m_values_e.push_back(m_values[i]); m_values.clear(); } ~LogEntry() { - for(int i= 0; i< m_values.size(); i++) + for(Uint32 i= 0; i< m_values.size(); i++) delete m_values[i]; - for(int i= 0; i< m_values_e.size(); i++) + for(Uint32 i= 0; i< m_values_e.size(); i++) delete m_values_e[i]; } - int size() const { return m_values.size(); } + Uint32 size() const { return m_values.size(); } const AttributeS * operator[](int i) const { return m_values[i];} }; diff --git a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp b/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp index 9f53ad573d7..5731a9a3883 100644 --- a/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp +++ b/ndb/src/kernel/blocks/backup/restore/consumer_restore.cpp @@ -244,7 +244,7 @@ void BackupRestore::cback(int result, restore_callback_t *cb) exitHandler(); } } - else + else { /** * OK! close transaction @@ -375,7 +375,7 @@ BackupRestore::logEntry(const LogEntry & tup) exit(-1); } - for (int i = 0; i < tup.size(); i++) + for (Uint32 i= 0; i < tup.size(); i++) { const AttributeS * attr = tup[i]; int size = attr->Desc->size; diff --git a/ndb/src/kernel/blocks/backup/restore/main.cpp b/ndb/src/kernel/blocks/backup/restore/main.cpp index d1c6e064e62..99deeb3115c 100644 --- a/ndb/src/kernel/blocks/backup/restore/main.cpp +++ b/ndb/src/kernel/blocks/backup/restore/main.cpp @@ -31,7 +31,7 @@ static int ga_nodeId = 0; static int ga_nParallelism = 128; static int ga_backupId = 0; static bool ga_dont_ignore_systab_0 = false; -static myVector g_consumers; +static Vector g_consumers; static const char* ga_backupPath = "." DIR_SEPARATOR; @@ -181,7 +181,7 @@ readArguments(const int argc, const char** argv) void clearConsumers() { - for(int i = 0; ituple_free(); } @@ -251,7 +251,7 @@ main(int argc, const char** argv) } - for(int i = 0; iinit()) { @@ -265,7 +265,7 @@ main(int argc, const char** argv) { if (checkSysTable(metaData[i]->getTableName())) { - for(int j = 0; jtable(* metaData[i])) { ndbout_c("Restore: Failed to restore table: %s. " @@ -296,7 +296,7 @@ main(int argc, const char** argv) while ((tuple = dataIter.getNextTuple(res= 1)) != 0) { if (checkSysTable(tuple->getTable()->getTableName())) - for(int i = 0; i < g_consumers.size(); i++) + for(Uint32 i= 0; i < g_consumers.size(); i++) g_consumers[i]->tuple(* tuple); } // while (tuple != NULL); @@ -322,7 +322,7 @@ main(int argc, const char** argv) dataIter.validateFooter(); //not implemented - for (int i = 0; iendOfTuples(); RestoreLogIterator logIter(metaData); @@ -336,7 +336,7 @@ main(int argc, const char** argv) while ((logEntry = logIter.getNextLogEntry(res= 0)) != 0) { if (checkSysTable(logEntry->m_table->getTableName())) - for(int i = 0; ilogEntry(* logEntry); } if (res < 0) @@ -345,7 +345,7 @@ main(int argc, const char** argv) return -1; } logIter.validateFooter(); //not implemented - for (int i = 0; iendOfLogEntrys(); } } diff --git a/ndb/src/kernel/blocks/backup/restore/myVector.hpp b/ndb/src/kernel/blocks/backup/restore/myVector.hpp deleted file mode 100644 index c858999d2be..00000000000 --- a/ndb/src/kernel/blocks/backup/restore/myVector.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright (C) 2003 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -#ifndef MY_VECTOR_HPP -#define MY_VECTOR_HPP - -// Template class for std::vector-like class (hopefully works in OSE) -template -class myVector -{ - - // Note that last element in array is used for end() and is always empty - int sizeIncrement; - int thisSize; - int used; - T *storage; - -public: - - // Assignment of whole vector - myVector & operator=(myVector & org) { - - // Don't copy if they point to the same address - if (!(this == &org)) { - // Check memory space - if (thisSize < org.thisSize) { - // We have to increase memory for destination - T* tmpStorage = new T[org.thisSize]; - delete[] storage; - storage = tmpStorage; - } // if - thisSize = org.thisSize; - sizeIncrement = org.sizeIncrement; - used = org.used; - for (int i = 0; i < thisSize; i++) { - storage[i] = org.storage[i]; - } // for - } // if - return *this; - } // operator= - - // Construct with size s+1 - myVector(int s = 1) : sizeIncrement(5), // sizeIncrement(s), - thisSize(s + 1), - used(0), - storage(new T[s + 1]) { } - - ~myVector() { delete[] storage; } // Destructor: deallocate memory - - T& operator[](int i) { // Return by index - if ((i < 0) || (i >= used)) { - // Index error - ndbout << "vector index out of range" << endl; - abort(); - return storage[used - 1]; - } // if - else { - return storage[i]; - } // else - } // operator[] - - const T& operator[](int i) const { // Return by index - if ((i < 0) || (i >= used)) { - // Index error - ndbout << "vector index out of range" << endl; - abort(); - return storage[used - 1]; - } // if - else { - return storage[i]; - } // else - } // operator[] - - int getSize() const { return used; } - - void push_back (T& item) { - if (used >= thisSize - 1) { - // We have to allocate new storage - int newSize = thisSize + sizeIncrement; - T* tmpStorage = new T[newSize]; - if (tmpStorage == NULL) { - // Memory allocation error! break - ndbout << "PANIC: Memory allocation error in vector" << endl; - return; - } // if - thisSize = newSize; - for (int i = 0; i < used; i++) { - tmpStorage[i] = storage[i]; - } // for - delete[] storage; - storage = tmpStorage; - } // if - - // Now push - storage[used] = item; - used++; - }; // myVector<> push_back() - - // Remove item at back - void pop_back() { - if (used > 0) { - used--; - } // if - } // pop_back() - - int size() const { return used; }; - - bool empty() const { return(used == 0); } - - void clear() { - used = 0; - } -}; - -#endif