List:Commits« Previous MessageNext Message »
From:Pekka Nousiainen Date:July 31 2011 5:59pm
Subject:bzr push into mysql-5.1-telco-7.0-wl4124-new1 branch (pekka.nousiainen:4418
to 4419) WL#4124
View as plain text  
 4419 Pekka Nousiainen	2011-07-31
      wl#4124 x16_fix.diff
      small changes inspired by sol10

    modified:
      storage/ndb/include/ndbapi/NdbIndexStat.hpp
      storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp
      storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp
      storage/ndb/tools/ndb_index_stat.cpp
 4418 Pekka Nousiainen	2011-07-25
      wl#4124 x15_fix.diff
      bugfix: range where index cols not in order

    modified:
      mysql-test/suite/ndb/r/ndb_statistics1.result
      storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp
=== modified file 'storage/ndb/include/ndbapi/NdbIndexStat.hpp'
--- a/storage/ndb/include/ndbapi/NdbIndexStat.hpp	2011-07-04 13:37:56 +0000
+++ b/storage/ndb/include/ndbapi/NdbIndexStat.hpp	2011-07-31 17:40:01 +0000
@@ -327,15 +327,15 @@ public:
   static void get_rule(const Stat& stat, char* buffer);
 
   /*
-   * Memory allocator for the stats caches.  By default each instance
-   * uses its own malloc-based implementation.
+   * Memory allocator for stats cache data (key and value byte arrays).
+   * Implementation default uses malloc/free.  The memory in use is the
+   * sum of CacheInfo::m_totalBytes from all cache types.
    */
   struct Mem {
     Mem();
     virtual ~Mem();
     virtual void* mem_alloc(UintPtr size) = 0;
     virtual void mem_free(void* ptr) = 0;
-    virtual UintPtr mem_used() const = 0;
   };
 
   /*

=== modified file 'storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp	2011-07-25 17:11:41 +0000
+++ b/storage/ndb/src/ndbapi/NdbIndexStatImpl.cpp	2011-07-31 17:40:01 +0000
@@ -45,7 +45,7 @@ NdbIndexStatImpl::NdbIndexStatImpl(NdbIn
   init();
   m_query_mutex = NdbMutex_Create();
   assert(m_query_mutex != 0);
-  m_mem_handler = &g_mem_default_handler;
+  m_mem_handler = &c_mem_default_handler;
 }
 
 void
@@ -1183,13 +1183,12 @@ NdbIndexStatImpl::read_commit(Con& con)
 int
 NdbIndexStatImpl::save_start(Con& con)
 {
-  Mem* mem = m_mem_handler;
   if (m_cacheBuild != 0)
   {
     free_cache(m_cacheBuild);
     m_cacheBuild = 0;
   }
-  con.m_cacheBuild = (Cache*)mem->mem_alloc(sizeof(Cache));
+  con.m_cacheBuild = new Cache;
   if (con.m_cacheBuild == 0)
   {
     setError(NoMemError, __LINE__);
@@ -1725,7 +1724,7 @@ NdbIndexStatImpl::free_cache(Cache* c)
   mem->mem_free(c->m_addrArray);
   mem->mem_free(c->m_keyArray);
   mem->mem_free(c->m_valueArray);
-  mem->mem_free(c);
+  delete c;
 }
 
 void
@@ -2245,57 +2244,26 @@ NdbIndexStatImpl::query_keycmp(const Cac
 
 // mem alloc - default impl
 
-NdbIndexStatImpl::MemDefault
-NdbIndexStatImpl::g_mem_default_handler;
-
 NdbIndexStatImpl::MemDefault::MemDefault()
 {
-  m_used = 0;
 }
 
 NdbIndexStatImpl::MemDefault::~MemDefault()
 {
-  assert(m_used == 0);
 }
 
 void*
 NdbIndexStatImpl::MemDefault::mem_alloc(UintPtr size)
 {
-  if (size == 0 || size % 4 != 0)
-  {
-    size += 4 - size % 4;
-  }
-  Item* item = (Item*)malloc(sizeof(Item) + size);
-  if (item != 0)
-  {
-    item->m_magic = MemMagic;
-    item->m_size = size;
-    void* ptr = &item[1];
-    m_used += size;
-    return ptr;
-  }
-  return 0;
+  void* ptr = malloc(size);
+  return ptr;
 }
 
 void
 NdbIndexStatImpl::MemDefault::mem_free(void* ptr)
 {
   if (ptr != 0)
-  {
-    Item* item = (Item*)ptr - 1;
-    assert(item->m_magic == MemMagic);
-    size_t size = item->m_size;
-    item->m_magic = 0;
-    free(item);
-    assert(m_used >= size);
-    m_used -= size;
-  }
-}
-
-UintPtr
-NdbIndexStatImpl::MemDefault::mem_used() const
-{
-  return m_used;
+    free(ptr);
 }
 
 // error

=== modified file 'storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp	2011-07-04 13:37:56 +0000
+++ b/storage/ndb/src/ndbapi/NdbIndexStatImpl.hpp	2011-07-31 17:40:01 +0000
@@ -282,19 +282,11 @@ public:
   // default memory allocator
   struct MemDefault : public Mem {
     virtual void* mem_alloc(UintPtr bytes);
-    virtual void mem_free(void* p);
-    virtual UintPtr mem_used() const;
+    virtual void mem_free(void* ptr);
     MemDefault();
     virtual ~MemDefault();
-  private:
-    enum { MemMagic = 0xf1f2f3f4 };
-    struct Item {
-      Uint32 m_magic;
-      size_t m_size;
-    };
-    size_t m_used;
   };
-  static MemDefault g_mem_default_handler;
+  MemDefault c_mem_default_handler;
 
   // error
   const NdbIndexStat::Error& getNdbError() const;

=== modified file 'storage/ndb/tools/ndb_index_stat.cpp'
--- a/storage/ndb/tools/ndb_index_stat.cpp	2011-07-04 13:37:56 +0000
+++ b/storage/ndb/tools/ndb_index_stat.cpp	2011-07-31 17:40:01 +0000
@@ -88,11 +88,13 @@ doconnect()
     CHK2(g_ncc->connect(6, 5) == 0, getNdbError(g_ncc));
     CHK2(g_ncc->wait_until_ready(30, 10) == 0, getNdbError(g_ncc));
 
-    g_ndb = new Ndb(g_ncc, _dbname);
-    CHK2(g_ndb->init() == 0, g_ndb->getNdbError());
-    CHK2(g_ndb->waitUntilReady(30) == 0, g_ndb->getNdbError());
-
-    g_dic = g_ndb->getDictionary();
+    if (!_sys_any)
+    {
+      g_ndb = new Ndb(g_ncc, _dbname);
+      CHK2(g_ndb->init() == 0, g_ndb->getNdbError());
+      CHK2(g_ndb->waitUntilReady(30) == 0, g_ndb->getNdbError());
+      g_dic = g_ndb->getDictionary();
+    }
 
     g_ndb_sys = new Ndb(g_ncc, NDB_INDEX_STAT_DB);
     CHK2(g_ndb_sys->init() == 0, g_ndb_sys->getNdbError());
@@ -112,7 +114,7 @@ dodisconnect()
   delete g_ndb_sys;
   delete g_ndb;
   delete g_ncc;
-    g_info << "disconnected" << endl;
+  g_info << "disconnected" << endl;
 }
 
 static const char*

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0-wl4124-new1 branch (pekka.nousiainen:4418to 4419) WL#4124Pekka Nousiainen3 Aug