5.2. EDISON Algorithm
Algorithm 2 describes the EDISON algorithm based on shared execution to avoid redundant range queries while processing -distance join queries. For simplicity, we assume that , because . The EDISON algorithm examines , the number of outer segments adjacent to each intersection vertex , and applies the extended shared execution to outer segments adjacent to if . If , then no range query is issued at . If and , then a range query is issued and its result is saved to , where , assuming that outer segments are adjacent to and that is closer to than for (lines 8‒11).
Next, for each outer segment , we retrieve a set of object pairs within distance from each outer object . We assume that is close to for an outer segment . We consider the following four cases depending on the values of and , where is a vertex sequence containing an outer segment : (1) ; (2) and ; (3) and ; and (4) and . If and , then inner objects within distance from each outer object are retrieved among the candidate inner objects in (lines 13‒16). If and , then inner objects within distance from each outer object are retrieved among the candidate inner objects in (lines 17‒19). If and , then inner objects within distance from each outer object are retrieved among the candidate inner objects in (lines 20‒22). Finally, if and , then inner objects within distance from each outer object are retrieved among the candidate inner objects in (lines 23‒24). A partial join result for is added to the query result . Finally, the -distance join query result is returned after all outer segments have been processed (line 26), i.e., for each outer segment .
Algorithm 2: EDISON () |
Input: : set of outer objects, : set of inner objects |
Output: : set of object pairs such that |
1 | | // is the set of object pairs such that . |
2 | // Step 1: neighboring outer objects are grouped and neighboring inner objects are also grouped. |
3 | | // Outer objects in a vertex sequence are grouped into an outer segment. |
4 | | // Inner objects in a vertex sequence are grouped into an inner segment. |
5 | // For simplicity, we assume that . if , we simply evaluate . |
6 | // Step 2: is evaluated by extending shared execution processing to adjacent outer segments. |
7 | for each intersection vertex do | |
8 | | if then | // means that more than two outer segments are adjacent to . |
9 | | | | // assume that . |
10 | | | if then | // If , then no range query is evaluated at . |
11 | | | | | // Otherwise, a range query is evaluated at . |
12 | for each outer segment do | // Assume that () is close to (). |
13 | | if and then |
14 | | | | // A range query is evaluated at because no range query is issued at . |
15 | | | | // A range query is evaluated at because no range query is issued at . |
16 | | | |
17 | | else if and then |
18 | | | | // A range query is evaluated at because no range query is issued at . |
19 | | | | // is reused by outer segments adjacent to . |
20 | | else if and then |
21 | | | | // A range query is evaluated at because no range query is issued at . |
22 | | | | // is reused by outer segments adjacent to . |
23 | | else if and then |
24 | | | | // () is reused by outer segments adjacent to (). |
25 | | | // A partial join result for is added to . |
26 | return | // stores the result of . |
| | | | | | | |
Algorithm 3 retrieves a set
of object pairs
within distance
, where
and
. First,
is initialized to the empty set. According to the condition of an inner object
, the distance from
to
is computed (lines 4‒11). Note that
in Algorithm 3 may not necessarily be the length of the shortest path from
to
, as discussed in
Section 5.3. If
, then the object pair
is added to the partial join result
(lines 12‒14). Clearly,
is returned after all candidate object pairs
have been examined (line 15). In Lemma 3, we prove the correctness of the EDISON algorithm.
Algorithm 3: |
Input: : threshold distance, : outer segment, : set of candidate inner objects for outer objects in |
Output: : set of object pairs such that for and |
1 | | // is the set of object pairs within distance where . |
2 | for each outer object do |
3 | | for each inner object do |
4 | | | // is computed according to the condition of . |
5 | | | if then |
6 | | | else if then |
7 | | | else if then |
8 | | | else if then |
9 | | | else if then |
10 | | | else if then |
11 | | | else if then |
12 | | | // If then an object pair is involved in the query result. |
13 | | | if then |
14 | | | | |
15 | return | // A partial join result for is returned. |
Lemma 3. The EDISON algorithm is correct.
Proof. We prove the correctness of the EDISON algorithm by cases. As shown in Algorithm 2, the EDISON algorithm handles the following four cases differently depending on the values of and of a vertex sequence containing an outer segment , namely, (1) ; (2) and ; (3) and ; and (4) and . For , two range queries, and , are evaluated at and , respectively. According to Lemma 1, we can retrieve the inner objects within distance from every outer object among the candidate inner objects The EDISON algorithm computes the distance from an outer object to each candidate inner object Because is the length of the shortest path among three possible paths (i.e., , , and if ), it is determined simply depending on the conditions listed in Algorithm 3. Specifically, if , then otherwise, If , an object pair is included in the -distance join query result; otherwise, the object pair is not included. Therefore, the EDISON algorithm is correct for .
For and , two range queries, and , are evaluated at and , respectively, where , assuming that the outer segments are adjacent to , and that is closer to than for . Because and , set of the inner objects within distance from contains set of the inner objects within distance from , where , i.e., . According to Lemma 1, we can retrieve inner objects within distance from every outer object among the candidate inner objects because contains The EDISON algorithm computes the distance from an outer object to each candidate inner object . Because is the length of the shortest path among three possible paths (i.e., , , and if ), it is determined simply depending on the conditions listed in Algorithm 3. Specifically, if , then otherwise, . If , an object pair is included in the -distance join query result; otherwise, the object pair is not included. Therefore, the EDISON algorithm is correct for and . Without loss of generality, the proof of the correctness of the EDISON algorithm for and can be simply obtained by interchanging the roles of and , as well as the roles of and , in the proof for and , which is omitted.
Finally, for and , two range queries, and , are evaluated at and , respectively, where and It is assumed that the outer segments are adjacent to , and that is closer to than for . Because () and , set of the inner objects within distance from contains set of the inner objects within distance from , where , i.e., . According to Lemma 1, we can retrieve the inner objects within distance from every outer object among the candidate inner objects because contains The EDISON algorithm computes the distance from an outer object to each candidate inner object Because is the length of the shortest path among three possible paths (i.e., , , and if ), it is determined simply depending on the conditions listed in Algorithm 3. Specifically, if , then otherwise, . If , an object pair is included in the -distance join query result; otherwise, the object pair is not included. Therefore, the EDISON algorithm is correct for and Consequently, the EDISON algorithm is correct for , and , and , and and □
5.3. Evaluation of an Example -Distance Join Query Using the EDISON Algorithm
We discuss how to evaluate the
-distance join query in
Figure 3 using the EDISON algorithm. As shown in
Figure 4,
and
are grouped into
and
, respectively. Because
, we evaluate
. There are two intersection vertices,
and
, both of which are adjacent to
and
. Therefore, to determine whether range queries at
and
are evaluated, the EDISON algorithm computes the distances
and
for the range queries at
and
, respectively. Because
and
, the EDISON algorithm evaluates the range query
only. Clearly, the range query
returns the empty set.
Table 4 summarizes the computation of
for the EDISON algorithm.
We retrieve inner objects within distance
from each outer object
among the candidate inner objects, followed by inner objects within distance
from each outer object
. As shown in
Table 4,
is the set of candidate inner objects for
, and
is the set of candidate inner objects for
. The EDISON algorithm computes the distance between an outer object
and each candidate inner object
and finds all qualifying object pairs
such that
.
We compute the distance from
to each candidate inner object
. Because
according to
Table 4, the distance from
to
is
, as shown in
Figure 10a. Because
, the distance from
to
is
, as shown in
Figure 10b. Similarly, because
, the distance from
to
is
, as shown in
Figure 10c. Finally, because
according to
Table 4, the distance from
to
is
, as shown in
Figure 10d. Consequently,
given that
,
,
, and
, and the generated partial join result is
.
We compute the distance from
to each candidate inner object
. Because
according to
Table 4, the distance from
to
is
, as shown in
Figure 11a. Because
, the distance from
to
is
, as shown in
Figure 11b. In fact, the shortest path from
to
is
, whose length is
. However, this deviation from the shortest distance does not affect the query result. Similarly, because
, this distance from
to
is
, as shown in
Figure 11c. Finally, because
according to
Table 4, the distance from
to
is
, as shown in
Figure 11d. Consequently,
given that
,
,
, and
, and the generated partial join result is
.
We compute the distance from
to each candidate inner object
. Because
according to
Table 4, the distance from
to
is
, as shown in
Figure 12a. Similarly, because
, the distance from
to
is
, as shown in
Figure 12b. In fact, the shortest path from
to
is
, whose length is
. However, this deviation from the shortest distance does not affect the query result. Finally, because
, the distance from
to
is
, as shown in
Figure 12c. Consequently,
given that
,
, and
, and the generated partial join result is
.
We compute the distance from
to each candidate inner object
. Because
according to
Table 4, the distance from
to
is
, as shown in
Figure 13a. Similarly, because
, the distance from
to
is
, as shown in
Figure 13b. Finally, because
, the distance from
to
is
, as shown in
Figure 13c. In fact, the shortest path from
to
is
, whose length is
. However, this deviation from the shortest distance does not affect the query result. Consequently,
given that
,
, and
, and the generated partial join result is
.
We compute the distance from
to each candidate inner object
. Because
according to
Table 4, the distance from
to
is
, as shown in
Figure 14a. Similarly, because
, the distance from
to
is
, as shown in
Figure 14b. Finally, because
, the distance from
to
is
, as shown in
Figure 14c. Consequently,
given that
,
, and
, and the generated partial join result is
. Finally, we obtain the complete query result
.