
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Christian Henning Sent: 22 August 2009 17:19 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [mapreduce] Prim Calculator
Hi Craig,
I also have rewritten the prime_calculator. I never like that the fact that the reduce key type was std::size_t. It should be bool. is_prime is now returning a boolean. I also have changed map value type from std::pairstd::size_t,std::size_t to just std::size_t. I hope this is correct in terms of the mapreduce methodologies.
To adopt the mapreduce problem description notation this is what I want:
map: ( number, number ) -----> list( boolean, number ) reduce: ( boolean, list( number ) ---------> list( number )
Well, it all compiles and runs but the results is empty. I have intercepted the reduce function and the supplied list is correct. Meaning all primes are in there. Weird. Dunno what's wrong here.
Did you try defining the job to write the results to file? This will work until I fix the iterator issue. A small optimization in the is_prime is to check for %2 - this avoids expensive sqrt & loops for even numbers that are always not prime bool const is_prime(long const number) { if (number == 0 || number == 1) return false; else if (number == 2) return true; else if (number%2 == 0) return false; ... } Regards -- Craig