Пример #1
0
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
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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
Пример #6
0
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
Пример #7
0
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
Пример #8
0
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
Пример #9
0
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
Пример #10
0
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
Пример #11
0
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
Пример #12
0
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
Пример #13
0
def stage():
    samples = 10000 #midsize run
    jobs = 500
    atoms = []
    last = 0
    for i in range(0,jobs):
        atoms.append(Data_Atom("pi",None,samples/jobs))
    print "DONE STAGE"
    return atoms
Пример #14
0
def stage():
    data = open("ulysses.txt")
    num_jobs = 100
    atoms = []
    lines = data.read().split("\n")
    lines_per_job = len(lines) / num_jobs
    for i in range(0, num_jobs):
        jobstr = ""
        for j in range(0, lines_per_job):
            jobstr += lines[i * lines_per_job + j]
        atoms.append(Data_Atom("job", None, jobstr))
    data.close()
    return atoms