[Assorted-commits] SF.net SVN: assorted:[1290] ydb/trunk/src
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-03-12 19:54:53
|
Revision: 1290 http://assorted.svn.sourceforge.net/assorted/?rev=1290&view=rev Author: yangzhang Date: 2009-03-12 19:54:39 +0000 (Thu, 12 Mar 2009) Log Message: ----------- using ASSERT instead of assert; using snap_map instead of fast_map Modified Paths: -------------- ydb/trunk/src/main.lzz.clamp ydb/trunk/src/tpcc/clock.cc ydb/trunk/src/tpcc/randomgenerator.cc ydb/trunk/src/tpcc/tpccclient.cc ydb/trunk/src/tpcc/tpcctables.cc Removed Paths: ------------- ydb/trunk/src/tpcc/assert.h Modified: ydb/trunk/src/main.lzz.clamp =================================================================== --- ydb/trunk/src/main.lzz.clamp 2009-03-12 19:54:31 UTC (rev 1289) +++ ydb/trunk/src/main.lzz.clamp 2009-03-12 19:54:39 UTC (rev 1290) @@ -8,10 +8,11 @@ #include <boost/scoped_array.hpp> #include <boost/shared_ptr.hpp> #include <boost/tuple/tuple.hpp> -#include <commons/fast_map.h> +#include <commons/assert.h> #include <commons/memory.h> #include <commons/nullptr.h> #include <commons/rand.h> +#include <commons/snap_map.h> #include <commons/st/st.h> #include <commons/time.h> #include <commons/unique_ptr.h> @@ -40,7 +41,6 @@ #define ref boost::ref #define tuple boost::tuple #define make_tuple boost::make_tuple -#define unused __attribute__((unused)) using namespace boost; using namespace boost::archive; @@ -57,7 +57,7 @@ //#define map_t unordered_map //#define map_t map //#define map_t dense_hash_map -#define map_t fast_map +#define map_t snap_map typedef map_t<int, int> mii; typedef mii::value_type entry; @@ -71,7 +71,7 @@ map.set_empty_key(-1); map.set_deleted_key(-2); } -template<> void init_map(fast_map<int, int> &map) { +template<> void init_map(snap_map<int, int> &map) { map.set_empty_key(-1); map.set_deleted_key(-2); } @@ -758,6 +758,16 @@ } } +#if 0 +template<typename Types, typename RTypes> +void +process_txn_ext(mii &map, const typename Types::Txn &txn, int &seqno, + typename RTypes::Response *res, ext_map ext) +{ + response +} +#endif + /** * Process a transaction: update DB state (incl. seqno) and send response to * leader. @@ -947,7 +957,7 @@ ResponseBatch &resbatch = *presbatch; ser_t serbuf; char *first_start = reader.start(); - assert(first_start == rbuf.get()); + ASSERT(first_start == rbuf.get()); const size_t headerlen = sizeof(uint32_t) + sizeof(short) + sizeof(int); while (true) { uint32_t prefix = 0; @@ -1019,16 +1029,16 @@ // Swap the buffers. swap(tmp, reader.buf()); reader.reset_range(reader.buf().get() + headerlen, reader.buf().get() + headerlen + reader.unread()); - assert(tmp.get() <= first_start && first_start < tmp.end()); - assert(tmp.get() < start && start < tmp.end()); - assert(first_start < start); + ASSERT(tmp.get() <= first_start && first_start < tmp.end()); + ASSERT(tmp.get() < start && start < tmp.end()); + ASSERT(first_start < start); backlog.push(make_tuple(tmp, first_start, start)); first_start = reader.buf().get(); first_seqno = first_txn.seqno(); } // Fill up rest of the message - assert(reader.unread() + reader.rem() >= prefix + sizeof(uint32_t) - headerlen); + ASSERT(reader.unread() + reader.rem() >= prefix + sizeof(uint32_t) - headerlen); check0x(reader.accum(prefix + sizeof(uint32_t) - headerlen)); } else { // Regular transaction batch. @@ -1047,6 +1057,13 @@ const Txn &txn = t == 0 ? first_txn : batch.txn(t); Response *res = resbatch.add_res(); process_txn<Types, RTypes>(map, txn, seqno, res); +#if 0 + if (!sending_recovery) { + process_txn<Types, RTypes>(map, txn, seqno, res); + } else { + process_txn_ext(map, txn, seqno, res, ext); + } +#endif if (fake_exec && !Types::is_pb()) { reader.skip(txn.op_size() * Op_Size); } @@ -1132,12 +1149,12 @@ template<> recovery_t -make_recovery(const fast_map<int, int> &map, int mypos, int nnodes, int &seqno) +make_recovery(const snap_map<int, int> &map, int mypos, int nnodes, int &seqno) { const commons::array<entry> &src = map.get_table(); pair<size_t, size_t> range = recovery_range(src.size(), mypos, nnodes); size_t begin = range.first, end = range.second; - assert(end > begin); + ASSERT(end > begin); recovery_header hdr = { seqno, end - begin, src.size(), map.size() }; size_t bodylen = sizeof(entry) * hdr.count; cout << "generating recovery of " << hdr.size << " records in " @@ -1637,7 +1654,7 @@ long long before_recv = current_time_millis(); vector<st_thread_t> recovery_builders; - assert(seqno == -1); + ASSERT(seqno == -1); bool first = true; for (int i = 0; i < (multirecover ? init.node_size() : 1); ++i) { recovery_builders.push_back(my_spawn(lambda() { @@ -1744,16 +1761,16 @@ while (!backlog.empty()) { chunk chunk = backlog.take(); sized_array<char> &buf = chunk.get<0>(); - assert(buf.get() <= chunk.get<1>() && chunk.get<1>() < buf.end()); - assert(buf.get() < chunk.get<2>() && chunk.get<2>() < buf.end()); - assert(chunk.get<1>() < chunk.get<2>()); + ASSERT(buf.get() <= chunk.get<1>() && chunk.get<1>() < buf.end()); + ASSERT(buf.get() < chunk.get<2>() && chunk.get<2>() < buf.end()); + ASSERT(chunk.get<1>() < chunk.get<2>()); swap(buf, reader.buf()); reader.reset_range(chunk.get<1>(), chunk.get<2>()); while (reader.start() < reader.end()) { - unused char *start = reader.start(); - unused uint32_t prefix = reader.read<uint32_t>(); - assert(prefix < 10000); - assert(start + sizeof(uint32_t) + prefix <= reader.end()); + char *start = reader.start(); + uint32_t prefix = reader.read<uint32_t>(); + ASSERT(prefix < 10000); + ASSERT(start + sizeof(uint32_t) + prefix <= reader.end()); batch.Clear(); for (int t = 0; t < batch.txn_size(); ++t) { const Txn &txn = batch.txn(t); @@ -1771,7 +1788,7 @@ << "; backlog.size = " << backlog.queue().size() << endl; } } - assert(start + sizeof(uint32_t) + prefix == reader.start()); + ASSERT(start + sizeof(uint32_t) + prefix == reader.start()); } } g_caught_up = true; Deleted: ydb/trunk/src/tpcc/assert.h =================================================================== --- ydb/trunk/src/tpcc/assert.h 2009-03-12 19:54:31 UTC (rev 1289) +++ ydb/trunk/src/tpcc/assert.h 2009-03-12 19:54:39 UTC (rev 1290) @@ -1,16 +0,0 @@ -#ifndef ASSERT_H__ -#define ASSERT_H__ - -#include <cassert> - -// Wraps the standard assert macro to avoids "unused variable" warnings when compiled away. -// Inspired by: http://powerof2games.com/node/10 -// This is not the "default" because it does not conform to the requirements of the C standard, -// which requires that the NDEBUG version be ((void) 0). -#ifdef NDEBUG -#define ASSERT(x) do { (void)sizeof(x); } while(0) -#else -#define ASSERT(x) assert(x) -#endif - -#endif Modified: ydb/trunk/src/tpcc/clock.cc =================================================================== --- ydb/trunk/src/tpcc/clock.cc 2009-03-12 19:54:31 UTC (rev 1289) +++ ydb/trunk/src/tpcc/clock.cc 2009-03-12 19:54:39 UTC (rev 1290) @@ -5,7 +5,7 @@ #include <cstdio> #include <ctime> -#include "assert.h" +#include <commons/assert.h> // Fills output with the base-10 ASCII representation of value, using digits digits. static char* makeInt(char* output, int value, int digits) { Modified: ydb/trunk/src/tpcc/randomgenerator.cc =================================================================== --- ydb/trunk/src/tpcc/randomgenerator.cc 2009-03-12 19:54:31 UTC (rev 1289) +++ ydb/trunk/src/tpcc/randomgenerator.cc 2009-03-12 19:54:39 UTC (rev 1290) @@ -6,7 +6,7 @@ #include <cstring> #include <ctime> -#include "assert.h" +#include <commons/assert.h> NURandC NURandC::makeRandom(RandomGenerator* generator) { NURandC c; Modified: ydb/trunk/src/tpcc/tpccclient.cc =================================================================== --- ydb/trunk/src/tpcc/tpccclient.cc 2009-03-12 19:54:31 UTC (rev 1289) +++ ydb/trunk/src/tpcc/tpccclient.cc 2009-03-12 19:54:39 UTC (rev 1290) @@ -3,7 +3,7 @@ #include <cstdio> #include <vector> -#include "assert.h" +#include <commons/assert.h> #include "clock.h" #include "randomgenerator.h" #include "tpccdb.h" Modified: ydb/trunk/src/tpcc/tpcctables.cc =================================================================== --- ydb/trunk/src/tpcc/tpcctables.cc 2009-03-12 19:54:31 UTC (rev 1289) +++ ydb/trunk/src/tpcc/tpcctables.cc 2009-03-12 19:54:39 UTC (rev 1290) @@ -4,7 +4,7 @@ #include <limits> #include <vector> -#include "assert.h" +#include <commons/assert.h> #include "stlutil.h" using std::vector; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |