Пример #1
0
def main():


    ## MASTER -> WORKER ###
    print_int_coll([1,2,3,[41,42,43]]) #agent_3
    print_obj_coll([DummyObject(1),DummyObject(2),DummyObject(3),[DummyObject(41),DummyObject(42),DummyObject(43)]]) #agent_2

    ## WORKER -> WORKER ###
    print_worker_int_coll(compss_wait_on(create_int_collection_worker())) #agent_2 -->  #agent_3
    print_worker_obj_coll(compss_wait_on(create_object_collection_worker())) #agent_3 -->  #agent_2

    ## WORKER -> MASTER ###
    objCollection = create_object_collection() #agent_3
    intCollection = create_int_collection() #agent_2
    objCollection = compss_wait_on(objCollection)
    intCollection = compss_wait_on(intCollection)
    print("createObjCollectionResult:" + str(objCollection))
    print("createIntCollectionResult:" + str(intCollection))

    ### COLLECTION DEPENDENCY ###
    modify_dummy_obj(objCollection) #agent_3
    objCollection = compss_wait_on(objCollection)
    print(" modifiedObjColl:" + str(objCollection))

    print_mod_obj_coll(objCollection) #agent_2

    ### COLLECTION_OUT ###
    coll= [DummyObject(),DummyObject()]
    gen_coll_out(coll)
    coll = compss_wait_on(coll) #agent_2
    print_coll_out(coll) #agent_3

    coll = ["1","2","3","4","5","6"]
    for elem in coll:
        print_elem(elem) #agent_2
Пример #2
0
def create_object_collection():
    print("executing create_object_collection")
    return [
        DummyObject(1),
        DummyObject(2),
        DummyObject(3), [DummyObject(41),
                         DummyObject(42),
                         DummyObject(43)]
    ]
Пример #3
0
def main():
    time.sleep(6)
    print("executing main")
    time.sleep(6)
    ### MASTER -> WORKER ###
    print("createObjCollectionResult:" +
          str(compss_wait_on(create_object_collection())))
    print("createIntCollectionResult:" +
          str(compss_wait_on(create_int_collection())))
    print_int_coll([1, 2, 3, [41, 42, 43]])
    print_obj_coll([
        DummyObject(1),
        DummyObject(2),
        DummyObject(3), [DummyObject(41),
                         DummyObject(42),
                         DummyObject(43)]
    ])
Пример #4
0
def readInput(file):
    """
    +readInput() lees een inputfile en voert de commando's die daarin staan uit om: datatypes te creêren, .dot-files te creëren of om traverses te printen.
    :param file: Het bestand waarin de commando's zouden staan.
    Pre-condities: Het bestand moet commando's bevatten voor het maken van datatypes, het maken van .dot-files of het printen van traverses.
    Post-condities: De commando's in het bestand zullen uitgevoerd worden.
    """
    currentType = ""
    ADT = None
    printCount = 0
    index = None
    with open(file, 'r') as inputfile:
        lines = inputfile.read().splitlines()
        for line in lines:
            if line.startswith("type"):
                type_properties = line.split("=")
                currentType = type_properties[1]
                if currentType == "hlin" or currentType == "23" or currentType == "heap" or currentType == "rb" or currentType == "hsep" or currentType == "hquad":
                    continue
                if type_properties[1].find(",") != -1:
                    split_properties = type_properties[1].split(",")
                    currentType = split_properties[0]
                    size = int(split_properties[1])
                    if currentType == "queue":
                        print(f"TYPE: {currentType}")
                        ADT = QueueTableWrapper(size)
                        printCount = 1
                elif type_properties[1].find(",") == -1:
                    currentType = type_properties[1]
                    if currentType == "bst":
                        print(f"TYPE: {currentType}")
                        ADT = BSTTableWrapper()
                        printCount = 1
                    elif currentType == "234":
                        print(f"TYPE: {currentType}")
                        ADT = TwoThreeFourTreeTableWrapper()
                        printCount = 1
                    elif currentType == "stack":
                        print(f"TYPE: {currentType}")
                        ADT = StackTableWrapper()
                        printCount = 1
                    elif currentType == "ll":
                        print(f"TYPE: {currentType}")
                        ADT = ChainTableWrapper()
                        printCount = 1
                        index = 0
            elif line.startswith("insert"):
                if currentType == "hlin" or currentType == "23" or currentType == "heap" or currentType == "rb" or currentType == "hsep" or currentType == "hquad":
                    continue
                insert_properties = line.split(" ")
                key = int(insert_properties[1])
                print(f"TYPE: {currentType} | Insert: {key}")
                if currentType == "bst" or currentType == "234" or currentType == "stack" or currentType == "queue":
                    ADT.tableInsert(DummyObject(key))
                elif currentType == "ll":
                    ADT.tableInsert(index, DummyObject(key))
                    index += 1
            elif line.startswith("delete"):
                if currentType == "hlin" or currentType == "23" or currentType == "heap" or currentType == "rb" or currentType == "hsep" or currentType == "hquad":
                    continue
                delete_properties = line.split(" ")
                if len(delete_properties) > 1:
                    key = int(delete_properties[1])
                    print(f"TYPE: {currentType} | delete: {key}")
                    if currentType == "bst":
                        ADT.tableDelete(DummyObject(key))
                    elif currentType == "234" or currentType == "ll":
                        ADT.tableDelete(key)

                else:
                    print(f"TYPE: {currentType} | delete")
                    if currentType == "stack":
                        print(ADT.tableDelete())
                    elif currentType == "queue":
                        ADT.tableDelete()
            elif line.startswith(
                    "print") and line.startswith("printsorted") is False:
                if currentType == "hlin" or currentType == "23" or currentType == "heap" or currentType == "rb" or currentType == "hsep" or currentType == "hquad":
                    continue
                if currentType == "234" or currentType == "bst" or currentType == "ll" or currentType == "stack" or currentType == "queue":
                    filename = currentType + "-" + str(printCount) + ".dot"
                    print(f"TYPE: {currentType} | ToDot: {filename}")
                    ADT.tablePrint(filename)
                    os.system(
                        f"dot -Tps {filename} -o {currentType}-{str(printCount)}.ps"
                    )
                    printCount += 1
            elif line.startswith("printsorted"):
                if currentType == "hlin" or currentType == "23" or currentType == "heap" or currentType == "rb" or currentType == "hsep" or currentType == "hquad":
                    continue
                if currentType == "234" or currentType == "bst" or currentType == "ll":
                    print(f"TYPE: {currentType} | print sorted")
                    ADT.tableTraverse()
Пример #5
0
def gen_coll_out(c):
    c[0]=DummyObject(11)
    c[1]=DummyObject(12)
Пример #6
0
def create_object_collection_worker():
    return [DummyObject(1),DummyObject(2),DummyObject(3),[DummyObject(41),DummyObject(42),DummyObject(43)]]