Exemplo n.º 1
0
def WordCount2():
    from pycompss.api.api import compss_wait_on
    '''
    WordCount Test
        - Wordcount task receives a PSCO and returns a dictionary.
        - Reduce task receives a INOUT PSCO (result) where accumulates the partial results.
    '''
    words = [
        Words('This is a test'),
        Words('This is a test'),
        Words('This is a test'),
        Words('This is a test')
    ]
    for w in words:
        w.makePersistent()
    result = Result()
    result.makePersistent()

    localResults = []
    for w in words:
        partialResults = wordcountTask(w)
        reduceTaskPSCOs(result, partialResults)

    final = compss_wait_on(result)

    print(final.myd)
    result = final.get()

    if result['This'] == 4 and result['is'] == 4 and result[
            'a'] == 4 and result['test'] == 4:
        print("- Python Wordcount 2 with PSCOs: OK")
        return True
    else:
        print("- Python Wordcount 2 with PSCOs: ERROR")
        return False