Optimal program structure helps increase execution efficiency. During application programming, avoid shuffle operations and combine narrow-dependency operations.
This topic describes how to design the DAG using the following example:
This example can be implemented in two ways:
Logic of implementation 1:
vehicle license plate number 1, [(time, toll station 3), (time, toll station 2), (time, toll station 4), (time, toll station 5)]
(toll station 3, (vehicle license plate number 1, time, 1st toll station))
(toll station 2, (vehicle license plate number 1, time, 2nd toll station))
(toll station 4, (vehicle license plate number 1, time, 3rd toll station))
(toll station 5, (vehicle license plate number 1, time, 4th toll station))
toll station 1, [(vehicle license plate number 1, time, 1st toll station), (vehicle license plate number 2, time, 5th toll station), (vehicle license plate number 3, time, 2nd toll station)]
(vehicle license plate number 1, vehicle license plate number 2),(1st toll station, 5th toll station)
(vehicle license plate number 1, vehicle license plate number 3),(1st toll station, 2nd toll station)
(vehicle license plate number 1, vehicle license plate number 2), [(1st toll station, 5th toll station), (2nd toll station, 6th toll station), (1st toll station, 7th toll station), (3rd toll station, 8th toll station)]
The logic of implementation 1 has the following disadvantages:
Logic of implementation 2:
vehicle license plate number 1, [(time, toll station 3), (time, toll station 2), (time, toll station 4), (time, toll station 5)]
toll station 3->toll station 2->toll station 4, (vehicle license plate number 1, [time passing through toll station 3, time passing through toll station 2, time passing through toll station 4])
toll station 2->toll station 4->toll station 5, (vehicle license plate number 1, [time passing through toll station 2, time passing through toll station 4, time passing through toll station 5])
toll station 3->toll station 2->toll station 4, [(vehicle license plate number 1, [time passing through toll station 3, time passing through toll station 2, time passing through toll station 4]), (vehicle license plate number 2, [time passing through toll station, time passing through toll station 3,time passing through toll station, time passing through toll station 2, time passing through toll station 4]), (vehicle license plate number 3, [time passing through toll station 3, time passing through toll station 2, time passing through toll station 4])]
The logic of implementation 2 has the following advantages: