[Assorted-commits] SF.net SVN: assorted: [335] hash-join/trunk/src
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-02-07 01:37:32
|
Revision: 335 http://assorted.svn.sourceforge.net/assorted/?rev=335&view=rev Author: yangzhang Date: 2008-02-06 17:37:32 -0800 (Wed, 06 Feb 2008) Log Message: ----------- fixed int overflow (to a limited degree) Modified Paths: -------------- hash-join/trunk/src/Makefile hash-join/trunk/src/hashjoin.cc Modified: hash-join/trunk/src/Makefile =================================================================== --- hash-join/trunk/src/Makefile 2008-02-07 01:35:37 UTC (rev 334) +++ hash-join/trunk/src/Makefile 2008-02-07 01:37:32 UTC (rev 335) @@ -1,7 +1,8 @@ all: hashjoin hashjoin: hashjoin.cc - g++ -g3 -Wall -o hashjoin hashjoin.cc -lprofiler -lpthread + # g++ -g3 -Wall -o hashjoin hashjoin.cc -lprofiler -lpthread + g++ -O3 -Wall -o hashjoin hashjoin.cc -lprofiler -lpthread clean: rm -f hashjoin Modified: hash-join/trunk/src/hashjoin.cc =================================================================== --- hash-join/trunk/src/hashjoin.cc 2008-02-07 01:35:37 UTC (rev 334) +++ hash-join/trunk/src/hashjoin.cc 2008-02-07 01:37:32 UTC (rev 335) @@ -321,7 +321,8 @@ for (unsigned int i = 0; i < ncpus; i++) { buckets[i] = new bucket[ncpus]; for (unsigned int j = 0; j < ncpus; j++) { - int bucket_size = max(1000000UL,buflen / ncpus * 3); + // TODO dependency injection + size_t bucket_size = max(1000000UL,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]); @@ -362,7 +363,7 @@ { size_t h = __stl_hash_string(s); unsigned int bucket = h % (map_size * ncpus) / map_size; - int bucket_size = max(1000000UL,buflen / ncpus * 3); + size_t bucket_size = max(1000000UL,buflen / ncpus * 3); 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. |