removed myVector from ndb restore

parent cc1d7aaf
......@@ -165,6 +165,7 @@ Parser<T>::Parser(const ParserRow<T> rows[], class InputStream & in,
template<class T>
inline
Parser<T>::~Parser(){
delete impl;
}
template<class T>
......
......@@ -82,14 +82,14 @@ RestoreMetaData::RestoreMetaData(const char* path, Uint32 nodeId, Uint32 bNo) {
}
RestoreMetaData::~RestoreMetaData(){
for(int i = 0; i<allTables.size(); i++)
for(Uint32 i= 0; i < allTables.size(); i++)
delete allTables[i];
allTables.clear();
}
const TableS *
RestoreMetaData::getTable(Uint32 tableId) const {
for(int i = 0; i<allTables.size(); i++)
for(Uint32 i= 0; i < allTables.size(); i++)
if(allTables[i]->getTableId() == 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; i<m_currentTable->m_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; i<m_currentTable->m_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() << "=";
......
......@@ -21,7 +21,6 @@
#include <NdbOut.hpp>
#include <BackupFormat.hpp>
#include <NdbApi.hpp>
#include "myVector.hpp"
#include <ndb_version.h>
#include <version.h>
......@@ -122,11 +121,11 @@ class TableS {
Uint32 schemaVersion;
Uint32 backupVersion;
myVector<AttributeDesc *> allAttributesDesc;
myVector<AttributeDesc *> m_fixedKeys;
//myVector<AttributeDesc *> m_variableKey;
myVector<AttributeDesc *> m_fixedAttribs;
myVector<AttributeDesc *> m_variableAttribs;
Vector<AttributeDesc *> allAttributesDesc;
Vector<AttributeDesc *> m_fixedKeys;
//Vector<AttributeDesc *> m_variableKey;
Vector<AttributeDesc *> m_fixedAttribs;
Vector<AttributeDesc *> m_variableAttribs;
Uint32 m_noOfNullable;
Uint32 m_nullBitmaskSize;
......@@ -225,7 +224,7 @@ public:
class RestoreMetaData : public BackupFile {
myVector<TableS *> allTables;
Vector<TableS *> allTables;
bool readMetaFileHeader();
bool readMetaTableDesc();
......@@ -280,13 +279,13 @@ public:
};
EntryType m_type;
const TableS * m_table;
myVector<AttributeS*> m_values;
myVector<AttributeS*> m_values_e;
Vector<AttributeS*> m_values;
Vector<AttributeS*> 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];}
};
......
......@@ -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;
......
......@@ -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<class BackupConsumer *> g_consumers;
static Vector<class BackupConsumer *> 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; i<g_consumers.size(); i++)
for(Uint32 i= 0; i<g_consumers.size(); i++)
delete g_consumers[i];
g_consumers.clear();
}
......@@ -199,7 +199,7 @@ checkSysTable(const char *tableName)
static void
free_data_callback()
{
for(int i = 0; i < g_consumers.size(); i++)
for(Uint32 i= 0; i < g_consumers.size(); i++)
g_consumers[i]->tuple_free();
}
......@@ -251,7 +251,7 @@ main(int argc, const char** argv)
}
for(int i = 0; i<g_consumers.size(); i++)
for(Uint32 i= 0; i < g_consumers.size(); i++)
{
if (!g_consumers[i]->init())
{
......@@ -265,7 +265,7 @@ main(int argc, const char** argv)
{
if (checkSysTable(metaData[i]->getTableName()))
{
for(int j = 0; j<g_consumers.size(); j++)
for(Uint32 j= 0; j < g_consumers.size(); j++)
if (!g_consumers[j]->table(* 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; i<g_consumers.size(); i++)
for (Uint32 i= 0; i < g_consumers.size(); i++)
g_consumers[i]->endOfTuples();
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; i<g_consumers.size(); i++)
for(Uint32 i= 0; i < g_consumers.size(); i++)
g_consumers[i]->logEntry(* logEntry);
}
if (res < 0)
......@@ -345,7 +345,7 @@ main(int argc, const char** argv)
return -1;
}
logIter.validateFooter(); //not implemented
for (int i = 0; i<g_consumers.size(); i++)
for (Uint32 i= 0; i < g_consumers.size(); i++)
g_consumers[i]->endOfLogEntrys();
}
}
......
/* 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 T>
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<T> & operator=(myVector<T> & 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment