Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2215 06/03/02 16:44:15 jonas@eel.(none) +17 -0
ndb dd
Make Dbtup::Extent_info use RWPool for dynamic memory
storage/ndb/src/kernel/vm/WOPool.hpp
1.3 06/03/02 16:44:09 jonas@eel.(none) +5 -0
Add #ifdef to WOPool
storage/ndb/src/kernel/vm/SimulatedBlock.hpp
1.23 06/03/02 16:44:09 jonas@eel.(none) +2 -0
Include pools
storage/ndb/src/kernel/vm/SLList.hpp
1.6 06/03/02 16:44:09 jonas@eel.(none) +99 -57
Add template arg (pool) to SLList
storage/ndb/src/kernel/vm/RWPool.hpp
1.2 06/03/02 16:44:09 jonas@eel.(none) +5 -0
Add #ifdef to WOPool
storage/ndb/src/kernel/vm/RWPool.cpp
1.2 06/03/02 16:44:09 jonas@eel.(none) +1 -0
Add debug printout
storage/ndb/src/kernel/vm/DLList.hpp
1.6 06/03/02 16:44:09 jonas@eel.(none) +104 -86
Add template arg (pool) to DLList
storage/ndb/src/kernel/vm/DLHashTable.hpp
1.7 06/03/02 16:44:09 jonas@eel.(none) +122 -111
Add template arg (pool) to DLHashTable
storage/ndb/src/kernel/blocks/lgman.cpp
1.16 06/03/02 16:44:09 jonas@eel.(none) +6 -4
Fix assertion when using multiple undo files...
storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp
1.11 06/03/02 16:44:09 jonas@eel.(none) +1 -2
Use RWPool for extent_info
storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp
1.24 06/03/02 16:44:09 jonas@eel.(none) +2 -2
Use RWPool for extent_info
storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp
1.27 06/03/02 16:44:09 jonas@eel.(none) +1 -1
Use RWPool for extent_info
storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp
1.14 06/03/02 16:44:09 jonas@eel.(none) +8 -10
Use RWPool for extent_info
storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp
1.42 06/03/02 16:44:09 jonas@eel.(none) +11 -6
Use RWPool for extent_info
storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
1.106 06/03/02 16:44:09 jonas@eel.(none) +2 -1
remove usage of DLHashTable::release(ptr, key)
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
1.96 06/03/02 16:44:09 jonas@eel.(none) +2 -1
remove usage of DLHashTable::release(ptr, key)
storage/ndb/src/kernel/blocks/backup/Backup.hpp
1.19 06/03/02 16:44:09 jonas@eel.(none) +2 -1
Use DLCFifoList as noOfElement() is _very_ slow
storage/ndb/src/kernel/blocks/backup/Backup.cpp
1.36 06/03/02 16:44:09 jonas@eel.(none) +1 -1
Use DLCFifoList as noOfElement() is _very_ slow
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jonas
# Host: eel.(none)
# Root: /home/jonas/src/51-ndb
--- 1.1/storage/ndb/src/kernel/vm/RWPool.cpp 2006-02-28 12:56:02 +01:00
+++ 1.2/storage/ndb/src/kernel/vm/RWPool.cpp 2006-03-02 16:44:09 +01:00
@@ -37,6 +37,7 @@
m_record_info.m_offset_magic = ((ri.m_offset_magic + 3) >> 2);
m_record_info.m_offset_next_pool = ((ri.m_offset_next_pool + 3) >> 2);
m_memroot = (RWPage*)m_ctx.get_memroot();
+ ndbout_c("RWPool::init(%x, %d)",ri.m_type_id, m_record_info.m_size);
}
bool
--- 1.1/storage/ndb/src/kernel/vm/RWPool.hpp 2006-02-28 12:56:02 +01:00
+++ 1.2/storage/ndb/src/kernel/vm/RWPool.hpp 2006-03-02 16:44:09 +01:00
@@ -14,6 +14,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#ifndef RWPOOL_HPP
+#define RWPOOL_HPP
+
#include "Pool.hpp"
struct RWPage
@@ -68,3 +71,5 @@
}
handle_invalid_get_ptr(i);
}
+
+#endif
--- 1.13/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp 2006-02-25 22:12:10 +01:00
+++ 1.14/storage/ndb/src/kernel/blocks/dbtup/DbtupDiskAlloc.cpp 2006-03-02 16:44:09 +01:00
@@ -103,7 +103,7 @@
{
printf(" %d : ", i);
Ptr<Extent_info> ptr;
- LocalDLList<Extent_info> list(c_extent_pool, alloc.m_free_extents[i]);
+ Local_extent_info_list list(c_extent_pool, alloc.m_free_extents[i]);
for(list.first(ptr); !ptr.isNull(); list.next(ptr))
{
ndbout << ptr << " ";
@@ -248,8 +248,8 @@
if (old != pos)
{
jam();
- Extent_list old_list(c_extent_pool, alloc.m_free_extents[old]);
- Extent_list new_list(c_extent_pool, alloc.m_free_extents[pos]);
+ Local_extent_info_list old_list(c_extent_pool, alloc.m_free_extents[old]);
+ Local_extent_info_list new_list(c_extent_pool, alloc.m_free_extents[pos]);
old_list.remove(extentPtr);
new_list.add(extentPtr);
extentPtr.p->m_free_matrix_pos= pos;
@@ -420,7 +420,7 @@
alloc.m_curr_extent_info_ptr_i = RNIL;
Uint32 pos= alloc.calc_extent_pos(ext.p);
ext.p->m_free_matrix_pos = pos;
- LocalDLList<Extent_info> list(c_extent_pool, alloc.m_free_extents[pos]);
+ Local_extent_info_list list(c_extent_pool, alloc.m_free_extents[pos]);
list.add(ext);
}
}
@@ -431,7 +431,7 @@
if ((pos= alloc.find_extent(sz)) != RNIL)
{
jam();
- LocalDLList<Extent_info> list(c_extent_pool, alloc.m_free_extents[pos]);
+ Local_extent_info_list list(c_extent_pool, alloc.m_free_extents[pos]);
list.first(ext);
list.remove(ext);
}
@@ -465,8 +465,7 @@
ext.p->m_free_page_count[0]= pages; // All pages are "free"-est
c_extent_hash.add(ext);
- LocalSLList<Extent_info, Extent_list_t>
- list1(c_extent_pool, alloc.m_extent_list);
+ Local_fragment_extent_list list1(c_extent_pool, alloc.m_extent_list);
list1.add(ext);
}
@@ -1520,7 +1519,7 @@
c_extent_pool.getPtr(old, alloc.m_curr_extent_info_ptr_i);
ndbassert(old.p->m_free_matrix_pos == RNIL);
Uint32 pos= alloc.calc_extent_pos(old.p);
- Extent_list new_list(c_extent_pool, alloc.m_free_extents[pos]);
+ Local_extent_info_list new_list(c_extent_pool, alloc.m_free_extents[pos]);
new_list.add(old);
old.p->m_free_matrix_pos= pos;
}
@@ -1529,8 +1528,7 @@
ext.p->m_free_matrix_pos = RNIL;
c_extent_hash.add(ext);
- LocalSLList<Extent_info, Extent_list_t>
- list1(c_extent_pool, alloc.m_extent_list);
+ Local_fragment_extent_list list1(c_extent_pool, alloc.m_extent_list);
list1.add(ext);
return 0;
}
--- 1.15/storage/ndb/src/kernel/blocks/lgman.cpp 2006-03-01 10:18:56 +01:00
+++ 1.16/storage/ndb/src/kernel/blocks/lgman.cpp 2006-03-02 16:44:09 +01:00
@@ -2631,11 +2631,13 @@
filePtr.p->m_state |= Undofile::FS_OUTSTANDING | Undofile::FS_MOVE_NEXT;
Ptr<Undofile> prev = filePtr;
- LocalDLFifoList<Undofile> files(m_file_pool, ptr.p->m_files);
- if(!files.prev(prev))
{
- jam();
- files.last(prev);
+ LocalDLFifoList<Undofile> files(m_file_pool, ptr.p->m_files);
+ if(!files.prev(prev))
+ {
+ jam();
+ files.last(prev);
+ }
}
if(DEBUG_UNDO_EXECUTION)
ndbout_c("changing file from %d to %d", filePtr.i, prev.i);
--- 1.2/storage/ndb/src/kernel/vm/WOPool.hpp 2006-02-28 12:56:02 +01:00
+++ 1.3/storage/ndb/src/kernel/vm/WOPool.hpp 2006-03-02 16:44:09 +01:00
@@ -14,6 +14,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#ifndef WOPOOL_HPP
+#define WOPOOL_HPP
+
#include "Pool.hpp"
struct WOPage
@@ -113,3 +116,5 @@
}
handle_invalid_get_ptr(i);
}
+
+#endif
--- 1.35/storage/ndb/src/kernel/blocks/backup/Backup.cpp 2006-01-31 11:42:33 +01:00
+++ 1.36/storage/ndb/src/kernel/blocks/backup/Backup.cpp 2006-03-02 16:44:09 +01:00
@@ -2675,7 +2675,7 @@
const Uint32 sz =
(sizeof(BackupFormat::CtlFile::TableList) >> 2) +
- ptr.p->tables.noOfElements() - 1;
+ ptr.p->tables.count() - 1;
Uint32 * dst;
ndbrequire(sz < buf.getMaxWrite());
--- 1.18/storage/ndb/src/kernel/blocks/backup/Backup.hpp 2006-02-21 13:50:11 +01:00
+++ 1.19/storage/ndb/src/kernel/blocks/backup/Backup.hpp 2006-03-02 16:44:09 +01:00
@@ -28,6 +28,7 @@
#include <SLList.hpp>
#include <DLFifoList.hpp>
+#include <DLCFifoList.hpp>
#include <SignalCounter.hpp>
#include <blocks/mutexes.hpp>
@@ -439,7 +440,7 @@
Uint32 startGCP;
Uint32 currGCP;
Uint32 stopGCP;
- DLList<Table> tables;
+ DLCFifoList<Table> tables;
SLList<TriggerRecord> triggers;
SLList<BackupFile> files;
--- 1.95/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2006-02-20 08:40:20 +01:00
+++ 1.96/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2006-03-02 16:44:09 +01:00
@@ -2366,8 +2366,9 @@
jamEntry();
CommitAckMarkerPtr removedPtr;
- m_commitAckMarkerHash.release(removedPtr, key);
+ m_commitAckMarkerHash.remove(removedPtr, key);
ndbrequire(removedPtr.i != RNIL);
+ m_commitAckMarkerPool.release(removedPtr);
#ifdef MARKER_TRACE
ndbout_c("Rem marker[%.8x %.8x]", key.transid1, key.transid2);
#endif
--- 1.105/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2006-02-25 22:12:09 +01:00
+++ 1.106/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp 2006-03-02 16:44:09 +01:00
@@ -4785,13 +4785,14 @@
key.transid2 = signal->theData[1];
CommitAckMarkerPtr removedMarker;
- m_commitAckMarkerHash.release(removedMarker, key);
+ m_commitAckMarkerHash.remove(removedMarker, key);
if (removedMarker.i == RNIL) {
jam();
warningHandlerLab(signal, __LINE__);
return;
}//if
sendRemoveMarkers(signal, removedMarker.p);
+ m_commitAckMarkerPool.release(removedMarker);
}
void
--- 1.41/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp 2006-02-25 22:12:10 +01:00
+++ 1.42/storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp 2006-03-02 16:44:09 +01:00
@@ -496,6 +496,7 @@
struct Extent_info : public Extent_list_t
{
+ Uint32 m_magic;
Uint32 m_first_page_no;
Local_key m_key;
Uint32 m_free_space;
@@ -517,9 +518,13 @@
m_key.m_page_idx == rec.m_key.m_page_idx;
}
}; // 40 bytes
-
- typedef LocalDLList<Extent_info> Extent_list;
+ typedef RecordPool<Extent_info, RWPool> Extent_info_pool;
+ typedef DLListImpl<Extent_info_pool, Extent_info> Extent_info_list;
+ typedef LocalDLListImpl<Extent_info_pool, Extent_info> Local_extent_info_list;
+ typedef DLHashTableImpl<Extent_info_pool, Extent_info> Extent_info_hash;
+ typedef SLListImpl<Extent_info_pool, Extent_info, Extent_list_t> Fragment_extent_list;
+ typedef LocalSLListImpl<Extent_info_pool, Extent_info, Extent_list_t> Local_fragment_extent_list;
struct Tablerec;
struct Disk_alloc_info
{
@@ -564,7 +569,7 @@
*
*/
STATIC_CONST( SZ = EXTENT_SEARCH_MATRIX_SIZE );
- DLList<Extent_info>::Head m_free_extents[SZ];
+ Extent_info_list::Head m_free_extents[SZ];
Uint32 m_total_extent_free_space_thresholds[EXTENT_SEARCH_MATRIX_ROWS];
Uint32 m_page_free_bits_map[EXTENT_SEARCH_MATRIX_COLS];
@@ -588,7 +593,7 @@
return EXTENT_SEARCH_MATRIX_COLS - 1;
}
- SLList<Extent_info, Extent_list_t>::Head m_extent_list;
+ Fragment_extent_list::Head m_extent_list;
};
void dump_disk_alloc(Disk_alloc_info&);
@@ -1009,9 +1014,9 @@
};
};
- ArrayPool<Extent_info> c_extent_pool;
+ Extent_info_pool c_extent_pool;
+ Extent_info_hash c_extent_hash;
Page_request_pool c_page_request_pool;
- DLHashTable<Extent_info> c_extent_hash;
typedef Ptr<Tablerec> TablerecPtr;
--- 1.26/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp 2006-02-25 22:12:10 +01:00
+++ 1.27/storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp 2006-03-02 16:44:09 +01:00
@@ -307,12 +307,12 @@
c_buildIndexPool.setSize(c_noOfBuildIndexRec);
c_triggerPool.setSize(noOfTriggers);
- c_extent_pool.setSize(8192);
c_extent_hash.setSize(1024); // 4k
Pool_context pc;
pc.m_block = this;
c_page_request_pool.wo_pool_init(RT_DBTUP_PAGE_REQUEST, pc);
+ c_extent_pool.init(RT_DBTUP_EXTENT_INFO, pc);
Uint32 nScanOp; // use TUX config for now
ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_TUX_SCAN_OP, &nScanOp));
--- 1.23/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp 2006-02-19 08:22:56 +01:00
+++ 1.24/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp 2006-03-02 16:44:09 +01:00
@@ -928,7 +928,7 @@
{
if(alloc_info.m_curr_extent_info_ptr_i != RNIL)
{
- LocalDLList<Extent_info>
+ Local_extent_info_list
list(c_extent_pool, alloc_info.m_free_extents[0]);
Ptr<Extent_info> ext_ptr;
c_extent_pool.getPtr(ext_ptr, alloc_info.m_curr_extent_info_ptr_i);
@@ -1015,7 +1015,7 @@
if(!alloc_info.m_free_extents[pos].isEmpty())
{
jam();
- LocalDLList<Extent_info>
+ Local_extent_info_list
list(c_extent_pool, alloc_info.m_free_extents[pos]);
Ptr<Extent_info> ext_ptr;
list.first(ext_ptr);
--- 1.6/storage/ndb/src/kernel/vm/DLHashTable.hpp 2006-02-13 13:12:43 +01:00
+++ 1.7/storage/ndb/src/kernel/vm/DLHashTable.hpp 2006-03-02 16:44:09 +01:00
@@ -30,11 +30,12 @@
* -# Uint32 hashValue() const;
* Which should return a 32 bit hashvalue
*/
-template <class T, class U = T>
-class DLHashTable {
+template <typename P, typename T, typename U = T>
+class DLHashTableImpl
+{
public:
- DLHashTable(ArrayPool<T> & thePool);
- ~DLHashTable();
+ DLHashTableImpl(P & thePool);
+ ~DLHashTableImpl();
/**
* Set the no of bucket in the hashtable
@@ -102,12 +103,6 @@
void removeAll();
/**
- * Remove element (and set Ptr to removed element)
- * And return element to pool
- */
- void release(Ptr<T> &, const T & key);
-
- /**
* Remove element and return to pool
*/
void release(Uint32 i);
@@ -153,40 +148,44 @@
private:
Uint32 mask;
Uint32 * hashValues;
- ArrayPool<T> & thePool;
+ P & thePool;
};
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
-DLHashTable<T,U>::DLHashTable(ArrayPool<T> & _pool)
+DLHashTableImpl<P, T, U>::DLHashTableImpl(P & _pool)
: thePool(_pool)
{
mask = 0;
hashValues = 0;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
-DLHashTable<T,U>::~DLHashTable(){
+DLHashTableImpl<P, T, U>::~DLHashTableImpl()
+{
if(hashValues != 0)
delete [] hashValues;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLHashTable<T,U>::setSize(Uint32 size){
+DLHashTableImpl<P, T, U>::setSize(Uint32 size)
+{
Uint32 i = 1;
while(i < size) i *= 2;
- if(mask == (i - 1)){
+ if(mask == (i - 1))
+ {
/**
* The size is already set to <b>size</b>
*/
return true;
}
- if(mask != 0){
+ if(mask != 0)
+ {
/**
* The mask is already set
*/
@@ -201,19 +200,22 @@
return true;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::add(Ptr<T> & obj){
+DLHashTableImpl<P, T, U>::add(Ptr<T> & obj)
+{
const Uint32 hv = obj.p->hashValue() & mask;
const Uint32 i = hashValues[hv];
- if(i == RNIL){
+ if(i == RNIL)
+ {
hashValues[hv] = obj.i;
obj.p->U::nextHash = RNIL;
obj.p->U::prevHash = RNIL;
- } else {
-
+ }
+ else
+ {
T * tmp = thePool.getPtr(i);
tmp->U::prevHash = obj.i;
obj.p->U::nextHash = i;
@@ -226,36 +228,45 @@
/**
* First element
*/
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLHashTable<T,U>::first(Iterator & iter) const {
+DLHashTableImpl<P, T, U>::first(Iterator & iter) const
+{
Uint32 i = 0;
while(i <= mask && hashValues[i] == RNIL) i++;
- if(i <= mask){
+ if(i <= mask)
+ {
iter.bucket = i;
iter.curr.i = hashValues[i];
iter.curr.p = thePool.getPtr(iter.curr.i);
return true;
- } else {
+ }
+ else
+ {
iter.curr.i = RNIL;
}
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLHashTable<T,U>::next(Iterator & iter) const {
- if(iter.curr.p->U::nextHash == RNIL){
+DLHashTableImpl<P, T, U>::next(Iterator & iter) const
+{
+ if(iter.curr.p->U::nextHash == RNIL)
+ {
Uint32 i = iter.bucket + 1;
while(i <= mask && hashValues[i] == RNIL) i++;
- if(i <= mask){
+ if(i <= mask)
+ {
iter.bucket = i;
iter.curr.i = hashValues[i];
iter.curr.p = thePool.getPtr(iter.curr.i);
return true;
- } else {
+ }
+ else
+ {
iter.curr.i = RNIL;
return false;
}
@@ -266,10 +277,11 @@
return true;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::remove(Ptr<T> & ptr, const T & key){
+DLHashTableImpl<P, T, U>::remove(Ptr<T> & ptr, const T & key)
+{
const Uint32 hv = key.hashValue() & mask;
Uint32 i;
@@ -278,60 +290,27 @@
prev.i = RNIL;
i = hashValues[hv];
- while(i != RNIL){
+ while(i != RNIL)
+ {
p = thePool.getPtr(i);
- if(key.equal(* p)){
+ if(key.equal(* p))
+ {
const Uint32 next = p->U::nextHash;
- if(prev.i == RNIL){
+ if(prev.i == RNIL)
+ {
hashValues[hv] = next;
- } else {
+ }
+ else
+ {
prev.p->U::nextHash = next;
}
- if(next != RNIL){
+ if(next != RNIL)
+ {
T * nextP = thePool.getPtr(next);
nextP->U::prevHash = prev.i;
}
-
- ptr.i = i;
- ptr.p = p;
- return;
- }
- prev.p = p;
- prev.i = i;
- i = p->U::nextHash;
- }
- ptr.i = RNIL;
-}
-
-template <class T, class U>
-inline
-void
-DLHashTable<T,U>::release(Ptr<T> & ptr, const T & key){
- const Uint32 hv = key.hashValue() & mask;
-
- Uint32 i;
- T * p;
- Ptr<T> prev;
- prev.i = RNIL;
-
- i = hashValues[hv];
- while(i != RNIL){
- p = thePool.getPtr(i);
- if(key.equal(* p)){
- const Uint32 next = p->U::nextHash;
- if(prev.i == RNIL){
- hashValues[hv] = next;
- } else {
- prev.p->U::nextHash = next;
- }
- if(next != RNIL){
- T * nextP = thePool.getPtr(next);
- nextP->U::prevHash = prev.i;
- }
-
- thePool.release(i);
ptr.i = i;
ptr.p = p;
return;
@@ -343,86 +322,101 @@
ptr.i = RNIL;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::remove(Uint32 i){
+DLHashTableImpl<P, T, U>::remove(Uint32 i)
+{
Ptr<T> tmp;
tmp.i = i;
tmp.p = thePool.getPtr(i);
remove(tmp);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::release(Uint32 i){
+DLHashTableImpl<P, T, U>::release(Uint32 i)
+{
Ptr<T> tmp;
tmp.i = i;
tmp.p = thePool.getPtr(i);
release(tmp);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::remove(Ptr<T> & ptr){
+DLHashTableImpl<P, T, U>::remove(Ptr<T> & ptr)
+{
const Uint32 next = ptr.p->U::nextHash;
const Uint32 prev = ptr.p->U::prevHash;
- if(prev != RNIL){
+ if(prev != RNIL)
+ {
T * prevP = thePool.getPtr(prev);
prevP->U::nextHash = next;
- } else {
+ }
+ else
+ {
const Uint32 hv = ptr.p->hashValue() & mask;
hashValues[hv] = next;
}
- if(next != RNIL){
+ if(next != RNIL)
+ {
T * nextP = thePool.getPtr(next);
nextP->U::prevHash = prev;
}
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::release(Ptr<T> & ptr){
+DLHashTableImpl<P, T, U>::release(Ptr<T> & ptr)
+{
const Uint32 next = ptr.p->U::nextHash;
const Uint32 prev = ptr.p->U::prevHash;
- if(prev != RNIL){
+ if(prev != RNIL)
+ {
T * prevP = thePool.getPtr(prev);
prevP->U::nextHash = next;
- } else {
+ }
+ else
+ {
const Uint32 hv = ptr.p->hashValue() & mask;
hashValues[hv] = next;
}
- if(next != RNIL){
+ if(next != RNIL)
+ {
T * nextP = thePool.getPtr(next);
nextP->U::prevHash = prev;
}
- thePool.release(ptr.i);
+ thePool.release(ptr);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::removeAll(){
+DLHashTableImpl<P, T, U>::removeAll()
+{
for(Uint32 i = 0; i<=mask; i++)
hashValues[i] = RNIL;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLHashTable<T,U>::next(Uint32 bucket, Iterator & iter) const {
+DLHashTableImpl<P, T, U>::next(Uint32 bucket, Iterator & iter) const
+{
while (bucket <= mask && hashValues[bucket] == RNIL)
bucket++;
- if (bucket > mask) {
+ if (bucket > mask)
+ {
iter.bucket = bucket;
iter.curr.i = RNIL;
return false;
@@ -434,10 +428,11 @@
return true;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLHashTable<T,U>::seize(Ptr<T> & ptr){
+DLHashTableImpl<P, T, U>::seize(Ptr<T> & ptr)
+{
if(thePool.seize(ptr)){
ptr.p->U::nextHash = ptr.p->U::prevHash = RNIL;
return true;
@@ -445,41 +440,47 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::getPtr(Ptr<T> & ptr, Uint32 i) const {
+DLHashTableImpl<P, T, U>::getPtr(Ptr<T> & ptr, Uint32 i) const
+{
ptr.i = i;
ptr.p = thePool.getPtr(i);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLHashTable<T,U>::getPtr(Ptr<T> & ptr) const {
+DLHashTableImpl<P, T, U>::getPtr(Ptr<T> & ptr) const
+{
thePool.getPtr(ptr);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
T *
-DLHashTable<T,U>::getPtr(Uint32 i) const {
+DLHashTableImpl<P, T, U>::getPtr(Uint32 i) const
+{
return thePool.getPtr(i);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLHashTable<T,U>::find(Ptr<T> & ptr, const T & key) const {
+DLHashTableImpl<P, T, U>::find(Ptr<T> & ptr, const T & key) const
+{
const Uint32 hv = key.hashValue() & mask;
Uint32 i;
T * p;
i = hashValues[hv];
- while(i != RNIL){
+ while(i != RNIL)
+ {
p = thePool.getPtr(i);
- if(key.equal(* p)){
+ if(key.equal(* p))
+ {
ptr.i = i;
ptr.p = p;
return true;
@@ -490,4 +491,14 @@
ptr.p = NULL;
return false;
}
+
+// Specializations
+
+template <typename T, typename U = T>
+class DLHashTable : public DLHashTableImpl<ArrayPool<T>, T, U>
+{
+public:
+ DLHashTable(ArrayPool<T> & p) : DLHashTableImpl<ArrayPool<T>, T, U>(p) {}
+};
+
#endif
--- 1.5/storage/ndb/src/kernel/vm/DLList.hpp 2006-01-11 09:26:03 +01:00
+++ 1.6/storage/ndb/src/kernel/vm/DLList.hpp 2006-03-02 16:44:09 +01:00
@@ -18,14 +18,14 @@
#define DLLIST_HPP
#include "ArrayPool.hpp"
-#include <NdbOut.hpp>
/**
* Template class used for implementing an
* list of object retreived from a pool
*/
-template <class T, class U = T>
-class DLList {
+template <typename P, typename T, typename U = T>
+class DLListImpl
+{
public:
/**
* List head
@@ -36,7 +36,8 @@
inline void init () { firstItem = RNIL; }
};
- struct Head : public HeadPOD {
+ struct Head : public HeadPOD
+ {
Head();
Head& operator=(const HeadPOD& src) {
this->firstItem = src.firstItem;
@@ -44,7 +45,7 @@
}
};
- DLList(ArrayPool<T> & thePool);
+ DLListImpl(P& thePool);
/**
* Allocate an object from pool - update Ptr
@@ -151,62 +152,41 @@
*/
bool hasNext(const Ptr<T> &) const;
- Uint32 noOfElements() const {
- Uint32 c = 0;
- Uint32 i = head.firstItem;
- while(i != RNIL){
- c++;
- const T * t = thePool.getPtr(i);
- i = t->U::nextList;
- }
- return c;
- }
-
- /**
- * Print
- * (Run operator NdbOut<< on every element)
- */
- void print(NdbOut & out) {
- Uint32 i = head.firstItem;
- while(i != RNIL){
- T * t = thePool.getPtr(i);
- t->print(out); out << " ";
- i = t->U::nextList;
- }
- }
-
inline bool isEmpty() const { return head.firstItem == RNIL;}
protected:
Head head;
- ArrayPool<T> & thePool;
+ P & thePool;
};
-template <class T, class U = T>
-class LocalDLList : public DLList<T,U> {
+template <typename P, typename T, typename U = T>
+class LocalDLListImpl : public DLListImpl<P,T,U>
+{
public:
- LocalDLList(ArrayPool<T> & thePool, typename DLList<T,U>::HeadPOD & _src)
- : DLList<T,U>(thePool), src(_src)
+ LocalDLListImpl(P & thePool, typename DLListImpl<P,T,U>::HeadPOD & _src)
+ : DLListImpl<P,T,U>(thePool), src(_src)
{
this->head = src;
}
- ~LocalDLList(){
+ ~LocalDLListImpl(){
src = this->head;
}
private:
- typename DLList<T,U>::HeadPOD & src;
+ typename DLListImpl<P,T,U>::HeadPOD & src;
};
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
-DLList<T,U>::DLList(ArrayPool<T> & _pool):
- thePool(_pool){
+DLListImpl<P,T,U>::DLListImpl(P & _pool)
+ : thePool(_pool)
+{
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
-DLList<T,U>::Head::Head(){
+DLListImpl<P,T,U>::Head::Head()
+{
this->init();
}
@@ -215,11 +195,13 @@
*
* Return i
*/
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLList<T,U>::seize(Ptr<T> & p){
- if(thePool.seize(p)){
+DLListImpl<P,T,U>::seize(Ptr<T> & p)
+{
+ if (likely(thePool.seize(p)))
+ {
add(p);
return true;
}
@@ -231,28 +213,32 @@
*
* Return i
*/
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLList<T,U>::seizeId(Ptr<T> & p, Uint32 ir){
- if(thePool.seizeId(p, ir)){
+DLListImpl<P,T,U>::seizeId(Ptr<T> & p, Uint32 ir)
+{
+ if (likely(thePool.seizeId(p, ir)))
+ {
add(p);
return true;
}
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLList<T,U>::findId(Uint32 i) const {
+DLListImpl<P,T,U>::findId(Uint32 i) const
+{
return thePool.findId(i);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::add(Ptr<T> & p){
+DLListImpl<P,T,U>::add(Ptr<T> & p)
+{
T * t = p.p;
Uint32 ff = head.firstItem;
@@ -260,39 +246,43 @@
t->U::prevList = RNIL;
head.firstItem = p.i;
- if(ff != RNIL){
+ if(ff != RNIL)
+ {
T * t2 = thePool.getPtr(ff);
t2->U::prevList = p.i;
}
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::add(Uint32 first, Ptr<T> & lastPtr)
+DLListImpl<P,T,U>::add(Uint32 first, Ptr<T> & lastPtr)
{
Uint32 ff = head.firstItem;
head.firstItem = first;
lastPtr.p->U::nextList = ff;
- if(ff != RNIL){
+ if(ff != RNIL)
+ {
T * t2 = thePool.getPtr(ff);
t2->U::prevList = lastPtr.i;
}
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::remove(Ptr<T> & p){
+DLListImpl<P,T,U>::remove(Ptr<T> & p)
+{
remove(p.p);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::remove(T * p){
+DLListImpl<P,T,U>::remove(T * p)
+{
T * t = p;
Uint32 ni = t->U::nextList;
Uint32 pi = t->U::prevList;
@@ -313,10 +303,11 @@
/**
* Return an object to pool
*/
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::release(Uint32 i){
+DLListImpl<P,T,U>::release(Uint32 i)
+{
Ptr<T> p;
p.i = i;
p.p = thePool.getPtr(i);
@@ -326,52 +317,59 @@
/**
* Return an object to pool
*/
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::release(Ptr<T> & p){
+DLListImpl<P,T,U>::release(Ptr<T> & p)
+{
remove(p);
- thePool.release(p.i);
+ thePool.release(p);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::release(){
- while(head.firstItem != RNIL){
- const T * t = thePool.getPtr(head.firstItem);
- const Uint32 i = head.firstItem;
- head.firstItem = t->U::nextList;
- thePool.release(i);
+DLListImpl<P,T,U>::release()
+{
+ Ptr<T> ptr;
+ while((ptr.i = head.firstItem) != RNIL)
+ {
+ thePool.getPtr(ptr);
+ head.firstItem = ptr.p->U::nextList;
+ thePool.release(ptr);
}
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::remove(){
+DLListImpl<P,T,U>::remove()
+{
head.firstItem = RNIL;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::getPtr(Ptr<T> & p, Uint32 i) const {
+DLListImpl<P,T,U>::getPtr(Ptr<T> & p, Uint32 i) const
+{
p.i = i;
p.p = thePool.getPtr(i);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-DLList<T,U>::getPtr(Ptr<T> & p) const {
+DLListImpl<P,T,U>::getPtr(Ptr<T> & p) const
+{
thePool.getPtr(p);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
T *
-DLList<T,U>::getPtr(Uint32 i) const {
+DLListImpl<P,T,U>::getPtr(Uint32 i) const
+{
return thePool.getPtr(i);
}
@@ -380,13 +378,15 @@
*
* Return i
*/
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLList<T,U>::first(Ptr<T> & p) const {
+DLListImpl<P,T,U>::first(Ptr<T> & p) const
+{
Uint32 i = head.firstItem;
p.i = i;
- if(i != RNIL){
+ if(i != RNIL)
+ {
p.p = thePool.getPtr(i);
return true;
}
@@ -394,10 +394,11 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLList<T,U>::next(Ptr<T> & p) const {
+DLListImpl<P,T,U>::next(Ptr<T> & p) const
+{
Uint32 i = p.p->U::nextList;
p.i = i;
if(i != RNIL){
@@ -408,11 +409,28 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-DLList<T,U>::hasNext(const Ptr<T> & p) const {
+DLListImpl<P,T,U>::hasNext(const Ptr<T> & p) const
+{
return p.p->U::nextList != RNIL;
}
+
+// Specializations
+
+template <typename T, typename U = T>
+class DLList : public DLListImpl<ArrayPool<T>, T, U>
+{
+public:
+ DLList(ArrayPool<T> & p) : DLListImpl<ArrayPool<T>, T, U>(p) {}
+};
+
+template <typename T, typename U = T>
+class LocalDLList : public LocalDLListImpl<ArrayPool<T>, T, U> {
+public:
+ LocalDLList(ArrayPool<T> & p, typename DLList<T,U>::HeadPOD & _src)
+ : LocalDLListImpl<ArrayPool<T>, T, U>(p, _src) {}
+};
#endif
--- 1.5/storage/ndb/src/kernel/vm/SLList.hpp 2006-01-11 09:26:03 +01:00
+++ 1.6/storage/ndb/src/kernel/vm/SLList.hpp 2006-03-02 16:44:09 +01:00
@@ -24,8 +24,9 @@
* Template class used for implementing an
* list of object retreived from a pool
*/
-template <class T, class U = T>
-class SLList {
+template <typename P, typename T, typename U = T>
+class SLListImpl
+{
public:
/**
* List head
@@ -43,7 +44,7 @@
}
};
- SLList(ArrayPool<T> & thePool);
+ SLListImpl(P & thePool);
/**
* Allocate an object from pool - update Ptr
@@ -162,45 +163,50 @@
protected:
Head head;
- ArrayPool<T> & thePool;
+ P & thePool;
};
-template <class T, class U = T>
-class LocalSLList : public SLList<T,U> {
+template <typename P, typename T, typename U = T>
+class LocalSLListImpl : public SLListImpl<P, T, U>
+{
public:
- LocalSLList(ArrayPool<T> & thePool, typename SLList<T,U>::HeadPOD & _src)
- : SLList<T,U>(thePool), src(_src)
+ LocalSLListImpl(P & thePool, typename SLListImpl<P, T, U>::HeadPOD & _src)
+ : SLListImpl<P, T, U>(thePool), src(_src)
{
this->head = src;
}
- ~LocalSLList(){
+ ~LocalSLListImpl(){
src = this->head;
}
private:
- typename SLList<T,U>::HeadPOD & src;
+ typename SLListImpl<P, T, U>::HeadPOD & src;
};
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
-SLList<T,U>::SLList(ArrayPool<T> & _pool):
- thePool(_pool){
+SLListImpl<P, T, U>::SLListImpl(P & _pool):
+ thePool(_pool)
+{
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
-SLList<T,U>::Head::Head(){
+SLListImpl<P, T, U>::Head::Head()
+{
this->init();
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-SLList<T,U>::seize(Ptr<T> & p){
+SLListImpl<P, T, U>::seize(Ptr<T> & p)
+{
thePool.seize(p);
T * t = p.p;
Uint32 ff = head.firstItem;
- if(p.i != RNIL){
+ if(p.i != RNIL)
+ {
t->U::nextList = ff;
head.firstItem = p.i;
return true;
@@ -208,14 +214,16 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-SLList<T,U>::seizeId(Ptr<T> & p, Uint32 ir){
+SLListImpl<P, T, U>::seizeId(Ptr<T> & p, Uint32 ir)
+{
thePool.seizeId(p, ir);
T * t = p.p;
Uint32 ff = head.firstItem;
- if(p.i != RNIL){
+ if(p.i != RNIL)
+ {
t->U::nextList = ff;
head.firstItem = p.i;
return true;
@@ -223,20 +231,24 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-SLList<T,U>::seizeN(Ptr<T> & p, Uint32 n){
- for(Uint32 i = 0; i < n; i++){
- if(seize(p) == RNIL){
+SLListImpl<P, T, U>::seizeN(Ptr<T> & p, Uint32 n)
+{
+ for(Uint32 i = 0; i < n; i++)
+ {
+ if(seize(p) == RNIL)
+ {
/**
* Failure
*/
- for(; i > 0; i--){
- const Uint32 tmp = head.firstItem;
- const T * t = thePool.getPtr(tmp);
- head.firstItem = t->U::nextList;
- thePool.release(tmp);
+ for(; i > 0; i--)
+ {
+ p.i = head.firstItem;
+ thePool.getPtr(p);
+ head.firstItem = p.p->U::nextList;
+ thePool.release(p);
}
return false;
}
@@ -252,17 +264,19 @@
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-SLList<T,U>::remove(){
+SLListImpl<P, T, U>::remove()
+{
head.firstItem = RNIL;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-SLList<T,U>::remove_front(Ptr<T> & p){
+SLListImpl<P, T, U>::remove_front(Ptr<T> & p)
+{
p.i = head.firstItem;
if (p.i != RNIL)
{
@@ -273,45 +287,51 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-SLList<T,U>::add(Uint32 first, Ptr<T> & last){
+SLListImpl<P, T, U>::add(Uint32 first, Ptr<T> & last)
+{
last.p->U::nextList = head.firstItem;
head.firstItem = first;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-SLList<T,U>::release(){
- while(head.firstItem != RNIL){
- const T * t = thePool.getPtr(head.firstItem);
- const Uint32 i = head.firstItem;
- head.firstItem = t->U::nextList;
- thePool.release(i);
+SLListImpl<P, T, U>::release()
+{
+ Ptr<T> ptr;
+ while((ptr.i = head.firstItem) != RNIL)
+ {
+ thePool.getPtr(ptr);
+ head.firstItem = ptr.p->U::nextList;
+ thePool.release(ptr);
}
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-SLList<T,U>::getPtr(Ptr<T> & p, Uint32 i) const {
+SLListImpl<P, T, U>::getPtr(Ptr<T> & p, Uint32 i) const
+{
p.i = i;
p.p = thePool.getPtr(i);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
void
-SLList<T,U>::getPtr(Ptr<T> & p) const {
+SLListImpl<P, T, U>::getPtr(Ptr<T> & p) const
+{
thePool.getPtr(p);
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
T *
-SLList<T,U>::getPtr(Uint32 i) const {
+SLListImpl<P, T, U>::getPtr(Uint32 i) const
+{
return thePool.getPtr(i);
}
@@ -320,13 +340,15 @@
*
* Return i
*/
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-SLList<T,U>::first(Ptr<T> & p) const {
+SLListImpl<P, T, U>::first(Ptr<T> & p) const
+{
Uint32 i = head.firstItem;
p.i = i;
- if(i != RNIL){
+ if(i != RNIL)
+ {
p.p = thePool.getPtr(i);
return true;
}
@@ -334,13 +356,15 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-SLList<T,U>::next(Ptr<T> & p) const {
+SLListImpl<P, T, U>::next(Ptr<T> & p) const
+{
Uint32 i = p.p->U::nextList;
p.i = i;
- if(i != RNIL){
+ if(i != RNIL)
+ {
p.p = thePool.getPtr(i);
return true;
}
@@ -348,11 +372,29 @@
return false;
}
-template <class T, class U>
+template <typename P, typename T, typename U>
inline
bool
-SLList<T,U>::hasNext(const Ptr<T> & p) const {
+SLListImpl<P, T, U>::hasNext(const Ptr<T> & p) const
+{
return p.p->U::nextList != RNIL;
}
+
+// Specializations
+
+template <typename T, typename U = T>
+class SLList : public SLListImpl<ArrayPool<T>, T, U>
+{
+public:
+ SLList(ArrayPool<T> & p) : SLListImpl<ArrayPool<T>, T, U>(p) {}
+};
+
+template <typename T, typename U = T>
+class LocalSLList : public LocalSLListImpl<ArrayPool<T>,T,U> {
+public:
+ LocalSLList(ArrayPool<T> & p, typename SLList<T,U>::Head & _src)
+ : LocalSLListImpl<ArrayPool<T>,T,U>(p, _src) {}
+};
+
#endif
--- 1.22/storage/ndb/src/kernel/vm/SimulatedBlock.hpp 2006-03-01 10:18:56 +01:00
+++ 1.23/storage/ndb/src/kernel/vm/SimulatedBlock.hpp 2006-03-02 16:44:09 +01:00
@@ -41,6 +41,8 @@
#include "DLList.hpp"
#include "ArrayPool.hpp"
#include "DLHashTable.hpp"
+#include "WOPool.hpp"
+#include "RWPool.hpp"
#include "Callback.hpp"
#include "SafeCounter.hpp"
--- 1.10/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp 2006-02-08 09:04:53 +01:00
+++ 1.11/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp 2006-03-02 16:44:09 +01:00
@@ -661,8 +661,7 @@
jam();
{
Disk_alloc_info& alloc = frag.m_disk_alloc_info;
- LocalSLList<Extent_info, Extent_list_t>
- list(c_extent_pool, alloc.m_extent_list);
+ Local_fragment_extent_list list(c_extent_pool, alloc.m_extent_list);
Ptr<Extent_info> ext_ptr;
c_extent_pool.getPtr(ext_ptr, pos.m_extent_info_ptr_i);
Extent_info* ext = ext_ptr.p;
| Thread |
|---|
| • bk commit into 5.1 tree (jonas:1.2215) | jonas | 2 Mar |