• 沒有找到結果。

Query Result Update

Chapter 3 System Design and Implementation

3.3  Query Result Update

3.3.1 Overview

In this section, we present our method of query result update strategy which is a solution of the location update problem. In this distributed architecture, server allocates some queries to mobile host to relieve its load. We leverage the mobile host’s tiny computing power to share the load with the central server. We also observe that the mobile host’s position in resident domain will affect the number of location update.

3.3.2 The method of computing the Rectangle Area

We use and modify the resident domain concept and algorithms provided by MQM. In our system, the Rectangle Area is a rectangle that around the mobile host. It also includes n queries that can fit the mobile host’s capability. When the mobile host is just registered to our system or leaves its current rectangle area, it sends a request for rectangle area. The information contains its current location and current time by GPS on the mobile host. And its capability is also reported to the server. The server then computes the rectangle area based on the current location and capability of the

InsertList(Di, Qj)

19

mobile host. The rectangle area is extended from the current position of mobile host to include n queries.

After receiving its rectangle area and queries, the mobile host checks whether it is still in the rectangle area when it moves. It also checks if it is cross over any query boundary. If it is in the rectangle area and not crosses over query boundary, it does not need to report to the server for query results update. Thus, the location update is avoided. The server load and communication costs are saved. When the mobile host detects that it has cross over some query boundary, it contacts the server to updates the query results. Or when a mobile host leaves it rectangle area, it sends a request to the server to get the new rectangle area and queries. Figure 3-6 shows the concept of rectangle area, the mobile host in the figure is A with capability 2.

Figure 3-6 The rectangle area of mobile host A.

3.4 Query Assignment

3.4.1 Overview

The domain represents a rectangle area in geography. Query is also a rectangle

20

that overlaps the domain area. Their relationship is managed in the BP-Tree. The server searches the BP-Tree down to the data node to find the mobile host’s position in the query rectangle edges lists. Then it computes rectangle area for mobile hosts by extending its border to include n queries to fit mobile host’s capability. The detail design and algorithms are introduced below.

3.4.2 The method of Query Assignment

The AssignQuery algorithm input Domain Root Di and mobile host Oi to assign rectangle area and query for the mobile host. Initially, it calls FindDomain to find the leaf domain where the mobile host in it. LoadList loads the data node inside the leaf domain to retrieve the edge lists in it, and set two pointers point to the border of domain rectangle. Then it calls ComputeRECT to compute the rectangle area.

In ComputeRECT, it extends its rectangle area to enclose n queries to fit the mobile host’s capability. It starts from the mobile host’s position. For each query rectangle it reaches, we compute the minimum step from mobile host’s X-coordinate to reach the boarder of QiLeft or QiRight. And the minimum step from mobile host’s Y-coordinate to reach the boarder of QiTop or QiBottom, respectively. Then we choose the maximum of these two values as the step to extend to reach the query rectangle, stores the query id and this value to the priority queue. Then it checks that the steps of

AssignQuery(Di, Oj) {

y FindDomain(Di, Oj); //Find the leaf-domain Di where Oj is in.

y LoadList(Di); //Load the Di.X_list and Di.Y_list.

y FindList(Di, Oj); //Find Oj’s position on the Query List.

y Di.pX points to the first equivalent position or points to the first element that is higher than Oj on the Di.X_list.

y Di.pY points to the first equivalent position or points to the first element that is higher than Oj on the Di.Y_list.

y RECT = ComputeRECT(Di, Oj)

y Return RECT; //Return the Rectangle area and Queries for MH.

}

21

rectangle area extended are larger than the minimum step in the priority queue or not.

If it is true, it represents that the rectangle area has cross the query boundary. The extend process is to adjust the domain edge border pointer that point to edge lists of query rectangle in data node. We extend the rectangle from the position of mobile host.

If it reaches the border of current domain, it should load the edge lists in other data node. LoadDomain algorithm checks the subdomain covered by the rectangle area, calls MergeList to merge these ordered edge lists. If ComputeRECT has added n queries, it returns the queries and current position of extended rectangle as the mobile host’s rectangle area. Then the AssignQuery procedure completed.

LoadDomain(D, Di)

{ //PQ’s smallest item’s key < step; Query is bounded.

Oj.QList = Oj.PQ.pop(step); //Pop items from PQ whose key<step qcount++; //qcount is the total query added to Oj

}

Di.pXL <=NextElementInX_List;

Di.pXR <=NextElementInX_List;

Di.pYT <=NextElementInY_List;

Di.pYB <=NextElementInY_List;

if( ( Di.pXL.< Di.XL ) or ( Di.pXR.> Di.XR) or ( Di.pYT.> Di.YT) or (Di.pXB.< Di.YB) ) { LoadDomain(D, Di); }

}//End of for }

22

Figure 3-7 The edge lists and the rectangle area of mobile host A.

At the end of Chapter 3, we demonstrate the procedure of Query Assignment. In Figure 3-7, mobile host A’s position is (9,7) with capability 2. The grids do not exist in our system. It is just to help us to see the steps clearly. At first, we found A on the edge lists. In X_list of current data node, we start at Q3Left. In Y_list of current data node, we start at Q11Top and Q12Top. Table 3-1 shows the detail procedure of query assignment. The red colored words represent the data changed.

MergeList(Ds, Di) {

if( Di.pXL.< Di.XL ) Merge( Ds.X_list, Di.X_list );

if( Di.pXR.> Di.XR) Merge( Di.X_list, Ds.X_list );

if( Di.pYT.> Di.YT) Merge( Ds.Y_list, Di.Y_list );

if( Di.pXB.< Di.YB) Merge(Di.Y_list, Ds.Y_list );

MergeSort( (Di.XL, Di.pXL), (Di.pXR, Di.XR), Ds.X_list(>Di.pXL , <Di.pXR) );

MergeSort( (Di.YB, Di.pYB), (Di.pYT, Di.YT), Ds.Y_list(>Di.pYT , <Di.pYB) );

}

23

At Step 0, edges Q3Left, Q11Top, and Q12Top are processed and their minimum steps to the four edges are compared. The maximum of these two values and its id stored to priority queue. Step 1 to Step 3 is similar. In the ComputeRECT Procedure of step 3, the MAX(X,Y) and Priority Queue’s minimum key (P_MIN) is compared.

The AssignQuery procedure output query list contains Q6 and Q11 to the mobile host A whose capability is 2. After pop the priority queue, the P_MIN is 3. And the pointers which point to the position of next element in X_List and Y_List are also returned as the rectangle area’s boundary. We also adjust the rectangle to extend as large as possible until it is almost reach more than n queries.

Table 3-1 The Query Assignment Procedure

Step Query MIN

STEP MAX

(X,Y) Priority Queue P_MIN Query List X Y

24

相關文件