[Assorted-commits] SF.net SVN: assorted: [387] hash-join/trunk/src/hashjoin.cc
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-12 17:23:41
|
Revision: 387 http://assorted.svn.sourceforge.net/assorted/?rev=387&view=rev Author: yangzhang Date: 2008-02-12 08:33:50 -0800 (Tue, 12 Feb 2008) Log Message: ----------- trying new allocator; fixed bucket_size type issues Modified Paths: -------------- hash-join/trunk/src/hashjoin.cc Modified: hash-join/trunk/src/hashjoin.cc =================================================================== --- hash-join/trunk/src/hashjoin.cc 2008-02-12 01:47:59 UTC (rev 386) +++ hash-join/trunk/src/hashjoin.cc 2008-02-12 16:33:50 UTC (rev 387) @@ -16,6 +16,7 @@ #include <commons/deque.h> #include <commons/files.h> #include <commons/hash.h> +#include <commons/region.h> #include <commons/strings.h> #include <commons/threads.h> #include <commons/time.h> @@ -31,7 +32,14 @@ using namespace commons; // TODO: using namespace boost; -typedef hash_map<const char*, const void*, hash<const char*>, eqstr> my_hash_map; +typedef hash_map< + const char*, + const void*, + hash<const char*>, + eqstr, + region_alloc<int> +> my_hash_map; + class hmap : public my_hash_map { public: @@ -216,7 +224,7 @@ buckets[i] = new bucket[ncpus]; for (unsigned int j = 0; j < ncpus; j++) { // TODO dependency injection - size_t bucket_size = max(1000000U,buflen / ncpus * 3); + size_t bucket_size = max((size_t) 1000000,buflen / ncpus * 3); // Each bucket should be twice as large as it would be given uniform // distribution. This is just an initial size; extending can happen. buckets[i][j].bufs.push_back(new char[bucket_size]); @@ -252,7 +260,7 @@ { size_t h = hash_djb2(s); unsigned int bucket = h % ncpus; - size_t bucket_size = max(1000000U, buflen * 3 / ncpus); + size_t bucket_size = max((size_t) 1000000, buflen * 3 / ncpus); if (heads[bucket] + nbytes < bs[bucket].bufs.back() + bucket_size) { memcpy(heads[bucket], p, nbytes); heads[bucket] += nbytes; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |