List:Commits« Previous MessageNext Message »
From:jonas Date:April 20 2007 9:51am
Subject:bk commit into 5.1 tree (jonas:1.2274)
View as plain text  
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@stripped, 2007-04-20 09:51:32+02:00, jonas@stripped +2 -0
  ndb - dynarr256
    Fix so that release also returns all values

  storage/ndb/src/kernel/vm/DynArr256.cpp@stripped, 2007-04-20 09:51:28+02:00,
jonas@stripped +55 -46
    Fix so that release also returns all values

  storage/ndb/src/kernel/vm/DynArr256.hpp@stripped, 2007-04-20 09:51:28+02:00,
jonas@stripped +7 -3
    Fix so that release also returns all values

# 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.hemma.oreland.se
# Root:	/home/jonas/src/51-dynarr

--- 1.1/storage/ndb/src/kernel/vm/DynArr256.cpp	2006-07-07 10:00:45 +02:00
+++ 1.2/storage/ndb/src/kernel/vm/DynArr256.cpp	2007-04-20 09:51:28 +02:00
@@ -346,18 +346,28 @@
 void
 DynArr256::init(ReleaseIterator &iter)
 {
-  iter.m_sz = 0;
+  iter.m_sz = 1;
   iter.m_pos = 0;
-  iter.m_ptr_i[0] = m_head.m_ptr_i;
-  iter.m_ptr_i[1] = RNIL;
+  iter.m_ptr_i[0] = RNIL;
+  iter.m_ptr_i[1] = m_head.m_ptr_i;
   iter.m_ptr_i[2] = RNIL;
   iter.m_ptr_i[3] = RNIL;
+  iter.m_ptr_i[4] = RNIL;
 }
 
-bool
-DynArr256::release(ReleaseIterator &iter)
+/**
+ * Iter is in next pos
+ *
+ * 0 - done
+ * 1 - data
+ * 2 - no data
+ */
+Uint32
+DynArr256::release(ReleaseIterator &iter, Uint32 * retptr)
 {
-  Uint32 ptrI = iter.m_ptr_i[iter.m_sz];
+  Uint32 sz = iter.m_sz;
+  Uint32 pos = iter.m_pos;
+  Uint32 ptrI = iter.m_ptr_i[sz];
   Uint32 page_no = ptrI >> DA256_BITS;
   Uint32 page_idx = ptrI & DA256_MASK;
   Uint32 type_id = (~m_pool.m_type_id) & 0xFFFF;
@@ -366,9 +376,8 @@
 
   if (ptrI != RNIL)
   {
-    Uint32 tmp = iter.m_pos & 255;
-    Uint32 p0 = tmp;
-    for (; p0<256 && p0 < tmp + 16; p0++)
+    Uint32 p0 = iter.m_pos & 255;
+    for (; p0<256; p0++)
     {
       Uint32 *retVal, *magic_ptr, p;
       if (p0 != 255)
@@ -391,55 +400,53 @@
       }
       
       Uint32 magic = *magic_ptr;
+      Uint32 val = *retVal;
       if (unlikely(! ((magic & (1 << p)) && (magic >> 16) ==
type_id)))
 	goto err;
       
-      Uint32 val = * retVal;
-      if (val != RNIL)
+      if (sz == m_head.m_sz)
       {
-	if (iter.m_sz + 2 == m_head.m_sz)
+	* retptr = val;
+	p0++;
+	if (p0 != 256)
 	{
-	  * retVal = RNIL;
-	  m_pool.release(val);
-	  iter.m_pos = (iter.m_pos & ~255) + p0;
-	  return false;
+	  /**
+	   * Move next
+	   */
+	  iter.m_pos &= ~(Uint32)255;
+	  iter.m_pos |= p0;
 	}
 	else
 	{
-	  * retVal = RNIL;
-	  iter.m_sz++;
-	  iter.m_ptr_i[iter.m_sz] = val;
-	  iter.m_pos = (p0 << 8);
-	  return false;
+	  /**
+	   * Move up
+	   */
+	  m_pool.release(ptrI);
+	  iter.m_sz --;
+	  iter.m_pos >>= 8;
 	}
+	return 1;
+      }
+      else if (val != RNIL)
+      {
+	iter.m_sz++;
+	iter.m_ptr_i[iter.m_sz] = val;
+	iter.m_pos = (p0 << 8);
+	* retVal = RNIL;
+	return 2;
       }
     }
     
-    if (p0 == 256)
-    {
-      if (iter.m_sz == 0)
-	goto done;
-      iter.m_sz--;
-      iter.m_pos >>= 8;
-            
-      m_pool.release(ptrI);
-      return false;
-    }
-    else
-    {
-      iter.m_pos = (iter.m_pos & ~255) + p0;
-      return false;
-    }
+    assert(p0 == 256);
+    m_pool.release(ptrI);
+    iter.m_sz --;
+    iter.m_pos >>= 8;
+    return 2;
   }
   
 done:  
-  if (m_head.m_ptr_i != RNIL)
-  {
-    m_pool.release(m_head.m_ptr_i);
-  }
-  
   new (&m_head) Head();
-  return true;
+  return 0;
   
 err:
   require(false);
@@ -640,6 +647,7 @@
 void
 simple(DynArr256 & arr, int argc, char* argv[])
 {
+  ndbout_c("argc: %d", argc);
   for (Uint32 i = 1; i<(Uint32)argc; i++)
   {
     Uint32 * s = arr.set(atoi(argv[i]));
@@ -867,7 +875,8 @@
     ndbout_c("Elapsed %lldus -> %f us/set", start, uspg);
     DynArr256::ReleaseIterator iter;
     arr.init(iter);
-    while(!arr.release(iter));
+    Uint32 val;
+    while(arr.release(iter, &val));
   }
 }
 
@@ -904,7 +913,7 @@
   DynArr256::Head head;
   DynArr256 arr(pool, head);
 
-  if (strcmp(argv[1], "--args") == 0)
+  if (strcmp(argv[1], "--simple") == 0)
     simple(arr, argc, argv);
   else if (strcmp(argv[1], "--basic") == 0)
     basic(arr, argc, argv);
@@ -915,8 +924,8 @@
 
   DynArr256::ReleaseIterator iter;
   arr.init(iter);
-  Uint32 cnt = 0;
-  while (!arr.release(iter)) cnt++;
+  Uint32 cnt = 0, val;
+  while (arr.release(iter, &val)) cnt++;
   
   ndbout_c("allocatedpages: %d allocatednodes: %d releasednodes: %d"
 	   " releasecnt: %d",

--- 1.1/storage/ndb/src/kernel/vm/DynArr256.hpp	2006-07-07 10:00:45 +02:00
+++ 1.2/storage/ndb/src/kernel/vm/DynArr256.hpp	2007-04-20 09:51:28 +02:00
@@ -62,12 +62,16 @@
   {
     Uint32 m_sz;
     Uint32 m_pos;
-    Uint32 m_ptr_i[4];
+    Uint32 m_ptr_i[5];
   };
   
   void init(ReleaseIterator&);
-  bool release(ReleaseIterator&);
-  
+  /**
+   * return 0 - done
+   *        1 - data (in retptr)
+   *        2 - nodata
+   */
+  Uint32 release(ReleaseIterator&, Uint32* retptr);
 protected:
   Head & m_head;
   DynArr256Pool & m_pool;
Thread
bk commit into 5.1 tree (jonas:1.2274)jonas20 Apr