[rhmessaging-commits] rhmessaging commits: r1901 - in store/trunk/cpp: lib/jrnl and 1 other directories.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Apr 11 08:58:31 EDT 2008


Author: kpvdr
Date: 2008-04-11 08:58:31 -0400 (Fri, 11 Apr 2008)
New Revision: 1901

Modified:
   store/trunk/cpp/lib/JournalImpl.cpp
   store/trunk/cpp/lib/jrnl/enq_map.hpp
   store/trunk/cpp/lib/jrnl/txn_map.hpp
   store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp
   store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp
Log:
Bugfix for emap/tmap size() function: return type overflow

Modified: store/trunk/cpp/lib/JournalImpl.cpp
===================================================================
--- store/trunk/cpp/lib/JournalImpl.cpp	2008-04-10 19:11:00 UTC (rev 1900)
+++ store/trunk/cpp/lib/JournalImpl.cpp	2008-04-11 12:58:31 UTC (rev 1901)
@@ -181,7 +181,8 @@
         }
     }
     std::ostringstream oss2;
-    oss2 << "Recover complete; highest rid found = 0x" << std::hex << highest_rid;
+    oss2 << "Recover complete; highest rid found = 0x" << std::hex << highest_rid << std::dec;
+    oss2 << "; emap.size=" << _emap.size() << "; tmap.size=" << _tmap.size();
     log(LOG_DEBUG, oss2.str());
 
     if (_mgmtObject.get() != 0)
@@ -189,6 +190,9 @@
         _mgmtObject->set_initialFileCount(_num_jfiles);
         _mgmtObject->set_dataFileSize(_jfsize_sblks * JRNL_SBLK_SIZE * JRNL_DBLK_SIZE);
         _mgmtObject->set_journalCurrentFileCount(_num_jfiles);
+
+        //TODO - swap this with a set method as soon as it becomes available in the generated code.
+        _mgmtObject->inc_journalRecordDepth(_emap.size());
     }
 }
 
@@ -461,6 +465,7 @@
         _mgmtObject->set_initialFileCount(_num_jfiles);
         _mgmtObject->set_dataFileSize(_jfsize_sblks * JRNL_SBLK_SIZE * JRNL_DBLK_SIZE);
         _mgmtObject->set_journalCurrentFileCount(_num_jfiles);
+        //TODO - set record depth to 0 when set function becomes available.
     }
 }
 

Modified: store/trunk/cpp/lib/jrnl/enq_map.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.hpp	2008-04-10 19:11:00 UTC (rev 1900)
+++ store/trunk/cpp/lib/jrnl/enq_map.hpp	2008-04-11 12:58:31 UTC (rev 1901)
@@ -96,7 +96,7 @@
         bool is_locked(const u_int64_t rid);
         inline void clear() { _map.clear(); }
         inline bool empty() const { return _map.empty(); }
-        inline u_int16_t size() const { return (u_int16_t)_map.size(); }
+        inline u_int32_t size() const { return u_int32_t(_map.size()); }
         void rid_list(std::vector<u_int64_t>& rv);
         void fid_list(std::vector<u_int16_t>& fv);
     };

Modified: store/trunk/cpp/lib/jrnl/txn_map.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_map.hpp	2008-04-10 19:11:00 UTC (rev 1900)
+++ store/trunk/cpp/lib/jrnl/txn_map.hpp	2008-04-11 12:58:31 UTC (rev 1901)
@@ -130,7 +130,7 @@
         const txn_data& get_data(const std::string& xid, const u_int64_t rid);
         inline void clear() { _map.clear(); }
         inline bool empty() const { return _map.empty(); }
-        inline u_int16_t size() const { return (u_int16_t)_map.size(); }
+        inline u_int32_t size() const { return u_int32_t(_map.size()); }
         void xid_list(std::vector<std::string>& xv);
     private:
         static std::string xid_format(const std::string& xid);

Modified: store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp	2008-04-10 19:11:00 UTC (rev 1900)
+++ store/trunk/cpp/tests/jrnl/_ut_enq_map.cpp	2008-04-11 12:58:31 UTC (rev 1901)
@@ -46,7 +46,7 @@
     cout << test_filename << ".constructor: " << flush;
     enq_map e1;
     BOOST_CHECK(e1.empty());
-    BOOST_CHECK_EQUAL(e1.size(), 0);
+    BOOST_CHECK_EQUAL(e1.size(), u_int32_t(0));
     cout << "ok" << endl;
 }
 
@@ -65,7 +65,7 @@
     for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
         e2.insert_fid(rid, fid);
     BOOST_CHECK(!e2.empty());
-    BOOST_CHECK_EQUAL(e2.size(), 128);
+    BOOST_CHECK_EQUAL(e2.size(), u_int32_t(128));
     
     // get
     u_int64_t rid_incr_2 = 6ULL;
@@ -102,10 +102,10 @@
             BOOST_CHECK(rid%rid_incr_1 == 0);
         }
     }
-    BOOST_CHECK_EQUAL(e2.size(), 171ULL);
+    BOOST_CHECK_EQUAL(e2.size(), u_int32_t(171));
     e2.clear();
     BOOST_CHECK(e2.empty());
-    BOOST_CHECK_EQUAL(e2.size(), 0);
+    BOOST_CHECK_EQUAL(e2.size(), u_int32_t(0));
     cout << "ok" << endl;
 }
 
@@ -141,7 +141,7 @@
             BOOST_CHECK(rid%rid_incr_1);
         }
     }
-    BOOST_CHECK_EQUAL(e3.size(), 85ULL);
+    BOOST_CHECK_EQUAL(e3.size(), u_int32_t(85));
     cout << "ok" << endl;
 }
 
@@ -250,4 +250,31 @@
     cout << "ok" << endl;
 }
 
+QPID_AUTO_TEST_CASE(stress)
+{
+    cout << test_filename << ".stress: " << flush;
+    u_int64_t rid;
+    u_int64_t rid_cnt;
+    u_int64_t rid_begin = 0xffffffff00000000ULL;
+    u_int64_t num_rid = 0x800000ULL;
+
+    enq_map e6;
+
+    // insert even rids with no dups
+    for (rid = rid_begin, rid_cnt = u_int64_t(0); rid_cnt < num_rid; rid += 2ULL, rid_cnt++)
+        e6.insert_fid(rid, u_int16_t(0));
+    BOOST_CHECK_EQUAL(e6.size(), num_rid);
+
+    // insert odd rids with no dups
+    for (rid = rid_begin + 1, rid_cnt = u_int64_t(0); rid_cnt < num_rid; rid += 2ULL, rid_cnt++)
+        e6.insert_fid(rid, u_int16_t(0));
+    BOOST_CHECK_EQUAL(e6.size(), num_rid * 2);
+    cout << "ok" << endl;
+
+    // remove even rids
+    for (rid = rid_begin, rid_cnt = u_int64_t(0); rid_cnt < num_rid; rid += 2ULL, rid_cnt++)
+        e6.get_remove_fid(rid);
+    BOOST_CHECK_EQUAL(e6.size(), num_rid);
+}
+
 QPID_AUTO_TEST_SUITE_END()

Modified: store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp	2008-04-10 19:11:00 UTC (rev 1900)
+++ store/trunk/cpp/tests/jrnl/_ut_txn_map.cpp	2008-04-11 12:58:31 UTC (rev 1901)
@@ -79,7 +79,7 @@
     
     txn_map t1;
     BOOST_CHECK(t1.empty());
-    BOOST_CHECK_EQUAL(t1.size(), 0);
+    BOOST_CHECK_EQUAL(t1.size(), u_int32_t(0));
     cout << "ok" << endl;
 }
 
@@ -98,7 +98,7 @@
     for (rid = rid_begin, fid = fid_start; rid < rid_end; rid += rid_incr_1, fid++)
         t2.insert_txn_data(make_xid(rid), txn_data(rid, ~rid, fid, false));
     BOOST_CHECK(!t2.empty());
-    BOOST_CHECK_EQUAL(t2.size(), 128);
+    BOOST_CHECK_EQUAL(t2.size(), u_int32_t(128));
     
     // get
     u_int64_t rid_incr_2 = 6ULL;




More information about the rhmessaging-commits mailing list