def map_func(atom): print "map sum",atom.contents jobid = atom.jobid total = 0L total+=atom.contents results = (total,0) atom = Data_Atom("", atom.hashkeyID, results) atom.jobid = jobid return atom
def map_func(atom): print "map sum", atom.contents jobid = atom.jobid total = 0L total += atom.contents results = (total, 0) atom = Data_Atom("", atom.hashkeyID, results) atom.jobid = jobid return atom
def reduce_func(atom1, atom2): print "reduce sum",atom1.contents,atom2.contents if atom1.jobid == atom2.jobid: jobid = atom2.jobid else: raise Exception("unmatched jobs in reduce") result = atom1.contents[0]+atom2.contents[0] results = [result,0] atom = Data_Atom("", atom1.hashkeyID, results) atom.jobid = atom1.jobid return atom
def reduce_func(atom1, atom2): print "reduce sum", atom1.contents, atom2.contents if atom2.jobid == atom2.jobid: jobid = atom2.jobid else: raise Exception("unmatched jobs in reduce") result = atom1.contents[0] + atom2.contents[0] results = [result, 0] atom = Data_Atom("", atom1.hashkeyID, results) atom.jobid = atom1.jobid return atom
def reduce_func(atom1, atom2): if atom2.jobid == atom2.jobid: jobid = atom2.jobid else: raise Exception("unmatched jobs in reduce") "the form of this is probably wrong" a1 = atom1.contents[0] a2 = atom2.contents[0] b1 = atom1.contents[1] b2 = atom2.contents[1] results = (a1+a2, b1+b2) atom = Data_Atom("", atom1.hashkeyID, results) atom.jobid = atom1.jobid return atom
def map_func(atom): jobid = atom.jobid results = {} print "running a map" line = atom.contents line = line.strip() words = line.split() for word in words: try: results[word] = results[word]+1 except KeyError: results[word] = 1 atom = Data_Atom("", atom.hashkeyID, results) atom.jobid = jobid return atom
def reduce_func(atom1, atom2): if atom1.jobid == atom2.jobid: jobid = atom2.jobid else: raise Exception("unmatched jobs in reduce") "the form of this is probably wrong" results = atom1.contents for word, count in atom2.contents.iteritems(): try: results[word] += count except KeyError: results[word] = count atom = Data_Atom("", atom1.hashkeyID, results) atom.jobid = atom1.jobid return atom
def map_func(atom): jobid = atom.jobid results = {} print "running a map" line = atom.contents line = line.strip() words = line.split() for word in words: try: results[word] = results[word] + 1 except KeyError: results[word] = 1 atom = Data_Atom("", atom.hashkeyID, results) atom.jobid = jobid return atom
def reduce_func(atom1, atom2): if atom2.jobid == atom2.jobid: jobid = atom2.jobid else: raise Exception("unmatched jobs in reduce") "the form of this is probably wrong" results = atom1.contents for word, count in atom2.contents.iteritems(): try: results[word] += count except KeyError: results[word] = count atom = Data_Atom("", atom1.hashkeyID, results) atom.jobid = atom1.jobid return atom
def map_func(atom): print "map pi" jobid = atom.jobid resultin = 0L total = 0L print "running a map" points = atom.contents random.seed(int(atom.hashkeyID.key,16)) for p in range(0,points): x = random.random() y = random.random() if (x**2.0)+(y**2.0) <= 1.0: resultin+=1 total+=1 results = (resultin, total) atom = Data_Atom("", atom.hashkeyID, results) atom.jobid = jobid return atom