Class ThreadEquivalence


  • public class ThreadEquivalence
    extends Object
    The purpose of this class is to determine whether two pattern matching threads are equivalent. Based on the thread equivalence, threads which are duplicates of some other thread can be pruned.

    It is assumed that the two compared threads: - have already matched the same portion of input. This also means that their corresponding arrays of matched labels are of equal lengths. - have reached the same instruction in the program.

    It takes the following steps to determine if two threads are equivalent:

    1. get the set of labels reachable by the program from the current instruction until the end of the program (`reachableLabels`)

    2. for all those labels, get all navigating operations for accessing input values which need to be performed during label evaluation (`positionsToCompare`). For all those navigating operations, check if they return the same result (i.e. navigate to the same input row) for both threads. NOTE: the computations can be simplified by stripping the physical offsets and skipping navigations which refer to the universal pattern variable.

    3. for all those labels, get all navigating operations for `CLASSIFIER` calls which need to be performed during label evaluation (`labelsToCompare`). For all those navigating operations, check if they navigate to rows tagged with the same label (but not necessarily the same position in input) for both threads.

    NOTE: the navigating operations for `MATCH_NUMBER` calls can be skipped altogether, since the match number is constant in this context.

    4. for all those labels, get all aggregations which need to be computed during label evaluation.

    4a. for aggregations whose arguments do not depend on the actual matched labels, check if the aggregated positions are the same for both threads.

    4b. for aggregations whose arguments depend on the actual matched labels, check if the aggregated positions, and the assigned labels are the same for both threads.