Next: Performance Results
Up: Indexing Spatial Data using
Previous: Mapping Function
In this section, we discuss the algorithms devised for manipulation of the proposed access structure. The insertion algorithm is a crucial one, as it determines the shape of the structure and hence the efficiency of other algorithms. When a node overflows, it invokes the decision metric algorithm and chooses the most suitable expansion method. Each type of expansion is handled by a separate self contained procedure. These procedures are recursive. It is possible to have a lateral expansion during a longitudinal expansion or seed another lateral expansion during a lateral expansion.
We devise algorithms for three types of queries: exact match, range query and k-nearest neighbor queries. These are the basic queries encountered in spatial data retrieval. Other types of queries are easily deduced from them.
Algorithm insertion.
Given a structure whose root node T, insert new object O into corresponding leaf bucket.
- I1: [Search object]. Invoke Exact_match_query() to search
whether the object exists and to locate the corresponding leaf bucket to
insert new object.
- I2: [Object exists]. If object found, stop.
- I3: [Insert new object]. If leaf bucket is not full, insert new object. Otherwise, if overflow bucket is not full, insert object in overflow bucket.
- I4: [Expansion occurs]. If longitudinal expansion is possible, invoke longitudinal_expand(). Otherwise invoke lateral_expand() to expand the tree and insert new object.
Algorithm longitudinal_expand.
Expand child buckets of bparent into a new set of buckets and insert the new object, O.
- LG1: [Create new buckets]. Create a new set of buckets to accommodate existing objects and new object.
- LG2: [Reinsert objects]. For all the child buckets bchild of bparent; if bchild is a leaf bucket, compute new hash function for
each object in bchild.
If corresponding new bucket has room to accommodate it,
insert object
otherwise, invoke lateral_expand() for corresponding new bucket.
- LG3: [Recursively insert branches]. If bchild is a non-leaf bucket, invoke reinsert_objects().
- LG4: [Insert new object]. Compute new mapping function for new object, O and insert it in corresponding new bucket.
- LG5: [Dispose old buckets]. Dispose all child buckets of bparent and their branches.
- LG6: [Attach new buckets]. update bparent, to attach new buckets to the structure.
Algorithm lateral_expand.
Expand an overfilled bucket bold into a new set of buckets and insert the new object, O.
- LT1: [Create new buckets]. Create a new set of buckets to accommodate existing objects and new object.
- LT2: [Reinsert objects]. For all the objects in bucket bold, compute new hash function and insert in the corresponding new bucket.
- LT3: [Insert new object]. Compute new mapping function for new object O. If corresponding bucket has enough space to accommodate it, insert, otherwise invoke lateral_expand() for corresponding new bucket.
- LT4: [Attach new buckets]. Update bold to attach new buckets to the structure.
Algorithm reinsert_objects.
Reinsert objects in child buckets of bi by recursively traversing the branches.
- RE1: [Recursive call]. For all the child buckets bj of bi, if bj is not a leaf bucket, invoke Reinsert_objects().
- RE2: [Reinsert objects]. If bj is a leaf bucket, for all the objects in bj, compute new mapping function.
If corresponding new bucket has enough space to accommodate
insert it
otherwise, invoke lateral_expand() for the corresponding new bucket.
Algorithm exact_match_query.
Given a structure whose root node is T, search whether a given object Q exists.
- EQ1: [Search subtrees]. If T is not a leaf bucket, traverse the tree downwards, computing subsequent mapping functions found in branches until a leaf bucket is encountered.
- EQ2: [Search leaf bucket]. If leaf bucket is encountered, search objects to check whether query object Q already exists and return the result
accordingly.
Algorithm range_query.
Given a structure whose root node is T, search for all the objects intersecting with query rectangle
.
- RQ1: [Search subtrees]. If T is not a leaf bucket, for all the child buckets of T which intersects with query rectangle
, bchild, invoke search_range().
- RQ2: [Search leaf bucket]. If leaf bucket encountered, output all the qualifying objects.
Algorithm search_range.
Given a query rectangle
, search for qualifying objects by traversing the branches of bi, recursively.
- SR1: [Recursive call]. If bi is not a leaf bucket, for all the intersecting branches bj of bi, invoke search_range().
- SR2: [Search leaf bucket]. If bi is a leaf bucket, output all the qualifying objects.
Algorithm k_nearest_neighbor_query.
Given a query object Q, find k nearest neighbor objects in the structure rooted at T.
- KN1: [Traverse downwards]. If T is not a leaf bucket, traverse the tree downwards, computing subsequent hash functions found in branches, until a leaf bucket is encountered. Store the bucket addresses visited in traversal in the list visited.
- KN2: [Search leaf bucket]. If leaf bucket is encountered, and if it is not empty, find k most closest objects to Q (or if less objects exists, all of them) and store them in the list
. - KN3: [Traverse upwards]. Traverse the tree upwards, until root encountered, by retrieving bucket addresses in list, visited. For each bucket in list, visited; for all their child buckets, bchild, invoke search_neighbor(), if
1. bchild is not visited
AND EITHER
2. MAXDIST(bchild, Q ) < farthest nearest neighbor
OR
3. Not enough nearest neighbors (k objects) not found so far.
- KN4: [Return result]. Return the list
.
Algorithm search_neighbor.
Given a query object Q, an unvisited bucket bi and a list of nearest neighbors
, find more suitable candidate objects for k-nearest neighbors, by traversing the branches of unvisited buckets, recursively.
- SN1: [Recursively traverse downwards]. If bi is not a leaf bucket, for all the child buckets bchild of bi, invoke search_neighbor(), if
1. MAXDIST(bchild, Q ) < farthest nearest neighbor
OR
2. Not enough nearest neighbors (k objects) not found so far. )
- SN2: [Update
]. If leaf bucket encountered, update list of nearest neighbors,
, comparing objects in the leaf bucket with the farthest nearest neighbor found so far.
Next: Performance Results
Up: Indexing Spatial Data using
Previous: Mapping Function
Santha Sumanasekara
11/12/1997