You are on page 1of 7

IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 6, NO.

2, APRIL 1994

34 1

paper we made an attempt to integrate them. First, we have illustrated the need for integration, and then outlined a procedure for integration. Future work should concentrate on optimizing the procedure. ACKNOWLEDGMENT The author thanks the anonymous referees for their careful reading of the manuscript and for their comments. REFERENCES A. El Abbadi and S . Toueg, Maintaining availability in partitioned replicated databases, ACM Trans. Database Syst., vol. 14, no. 2, pp. 264290, June 1989. D. Agrawal and A. El Abbadi, Integrating security with fault-tolerant distributed databases, Comput.J.,vol. 33, no. 1, pp. 71-78, Feb. 1990. -, Storage efficient replicated databases, IEEE Trans. Knowledge Data Eng., vol. 2, no. 3, pp. 342-352, Sept. 1990. S. Y.Cheung, M. Ahamad, and M. H. Ammar, Optimizing vote and quorum assignments for reading and writing replicated data, IEEE Trans. Knowledge Data Eng., vol. 1, no. 3, pp. 387-397, Sept. 1989, D. E. Denning, Cryptography and Data Security. Reading, MA: Addison-Wesley, 1982. H. Garcia-Molinaand D. Barbara, How to assign votes in a distributed system, J. ACM, vol. 32, no. 4, pp. 841-860, Oct. 1985. D. K. Gifford, Weighted voting for replicated data, in Proc. 7th Symp. Oper. Systems Principles, Dec. 1979, pp. 150-159. S . Jajodia and D. Mutchler, Dynamic voting algorithms for maintaining the consistency of a replicated database, ACM Trans. Database Syst., vol. 15, no. 2, pp. 230-280, June 1990. T. F. Lunt, D. E. Denning, R. R. Schell, M. Heckman, and W. R. Shockley, The SeaView security model, IEEE Trans. Sofiare Eng., vol. 16, pp. 593-607, June 1990. J.-F. PaTis, Voting with witnesses: A consistency scheme for replicated files, in Proc. 61h Conf. Dist. Comput. Syst., June 1986, pp. 606-612. J.-F. P a s and D. E. Long, Efficient dynamic voting algorithms, in Proc. 4th IEEE Intl. Con$ on Data Engineering, Feb. 1988, pp. 268-215. M. 0. Rabin, Efficient dispersal of information for security, load balancing, and fault tolerance, J. ACM, vol. 36, no. 2, pp. 335-348, Apr. 1989. B. Randell and J. Dobson, Reliability and security issues in distributed computing systems, in Proc. 5th Symp. Reliability in Distributed Software and Database Syst., 1986, pp. 113-118. R. H. Thomas, A majority consensus approach to concurrency control for multiple copy databases, ACM Trans. Database Syst., vol. 4, no. 2, pp. 180-209, June 1979. G. T. J. Wuu and A. J. Bemstein,Efficient solutions to the replicated log and dictionary problems, in Proc. 3rd Symp. Principles of Distributed Computing, 1984, pp. 233-242.

G-nee: A New Data Structure for Organizing Multidimensional Data


Akhil Kumar

Abshulcf-This paper describes an efficient data structure called the G-tree (or grid tree) for organizing multidimensional data. The data structure combines the features of grids and B-trees in a novel manner. It also exploits an ordering property that numbers the partitions in such a way that partitions that are spatially close to one another in a multidimensionalspace are also close in terms of their partition numbers. This structure adapts well to dynamic data spaces with a high frequency of insertions and deletions, and to nonuniform distributions of data. We demonstrate that it is possible to perform insertion, retrieval, and deletion operations, and to run various range queries efficiently using this structure. A comparision with the BD tree, zkdb tree and the KDB tree is carried out, and the advantages of the G-tree over the other structures are discussed. The simulated bucket utilization rates for the G-tree are also reported. Index Tenns4ata structure, multidimensionaldata, B-tree, KDB tree, BD tree, grid files, G-tree, bucket utilization, range queries.

I. INTRODUCTION

B-trees are an efficient data structure for indexing one-dimensional data. However, they are not suitable for indexing multidimensional data. A query such as, Find all employees who are between 30 and 35 years old and earn a salary between lOOK and 120K, is an example of a two-dimensional range query. One way of answering such a query is by maintaining one-dimensional indexes on age and salary, and using one or both indexes to narrow down the set of relevant employee records. Another way is to maintain a composite index on age and salary. None of these solutions is, however, efficient, and therefore specialized structures are required to handle multidimensional queries. One approach for organizing multidimensional data consists of having multidimensional binary trees [I] (see also [14] for an excellent coverage of various data structures described in this paper). However, this is a main memory resident structure, not suitable for storing on disk. Two useful disk-based data structures for organizing multidimensional data are KDB trees and grids. KDB trees [12] successively divide the entire k-dimensional data space into smaller k-dimensional regions or hyper-rectangles. The regions are organized into a tree similar to a B-tree. The nonleaf pages of the B-tree are called region pages, while the leaf pages are called point p a g e s because the entries in the leaf level of this tree point to the data tuples. Each point page corresponds to one disk page or a bucket. The entries in the nonleaf pages of the tree consist of nonintersecting k-dimensional regions, and pointers to lower level pages that contain subregions within that region. Gridfiles [8], [7]partition a data space into a grid structure by splitting each dimension into several nonuniformly spaced intervals. Such a grid may be viewed as an n-dimensional array where a block or element in the grid is defined by identifying its index along each dimension. Each grid element points to a disk bucket or disk page. More than one grid element can point to the same disk Manuscript received November 9, 1990; revised May 26, 1992. This work was supported in part by the NSF under Grant RI-91 10880. The author is with the GraduateSchool of Management, Come11 University, Ithaca, NY 14853. IEEE Log Number 9212684.

1041-4347/94$04.00 0 1994 IEEE

r-__

342

IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 6, NO. 2, APRIL 1994

bucket if the total number of points contained in them together is less than the capacity of the disk page. A directory is maintained in order to determine the physical location of each grid element. The problem with this structure is that directory maintenance can be very expensive, and if the data is nonuniform, the size of the directory can be very large. Another technique for organizing multidimensional data is multiattribute hashing [13]. The basic idea is to concatenate several attribute values in the construction of a hash key, and to store the data points in a hash table. This technique works well for exact match queries but is not suitable for range queries. Other hashing-based methods, such as those presented in [2] and [ 111, have similar shortcomings. This paper describes a new data structure called G-tree that combines features of both grids and B-trees in a novel manner. It is called a G-tree (or grid tree) because the multidimensional space is divided into a grid of variable size partitions, and the partitions are organized into a B-tree. The data structure that comes closest to our proposed structure is the BD tree [4], [5]. (The BANG file [6] is a variant of the BD tree.). Both methods employ a variable-length partition numbering scheme. The partitions in the G-tree correspond to disk pages or buckets, and points are assigned to a partition until it is full. A full partition is split into two equal subpartitions, and the points in the original partition are distributed among the new partitions. Since the partitions are completely ordered, they can be stored in a B-tree. On the other hand, the BD tree proposal organizes the partitions in a binary search tree such that an intemal node of this tree acts like a decision node. It contains a partition number and the two branches, the in and out branches, emerging from the node represent altemative search paths, depending upon whether a point belongs to that partition or not. The leaf-level nodes point to disk buckets that contain the data. Therefore, while the G-tree maps a partition directly into a bucket, the BD tree allows buckets to be defined by including some and excluding other subpartitions from a partition. A more detailed comparison between the two schemes is given in Section IV. The zkdb tree [9],[lo] also uses a similar numbering scheme, called zorder, to organize multidimensional data into a B-tree. However, the z-order fields are of fixed length. This paper is organized as follows. Section I1 explains our data structure and gives detailed algorithms for performing insertions and deletions. Section I11 discusses our query processing algorithm. Then, Section IV tums to perform a comparison with the BD tree, zkdb tree, and KDB tree. Section V presents results of simulation experiments performed to study utilization figures for this structure, and Section VI concludes the paper.

00
I
I

+I:,
010

011

(c)

Fig. 1. Partitioning scheme. The data space is divided into nonoverlapping partitions of variable size. Each partition is assigned a unique partition number. A total ordering is defined on the partition numbers, and they are stored in a B-tree. Empty partitions are not stored in the tree to save space. We first describe our partition-numbering scheme and partition arithmetic, and then tum to the other details of our structure. This numbering scheme has also been discussed in [4] and [5]. Partition Numbering and Splitting: A partition is numbered as a binary string of 0s and 1s. Successive parts of Fig. 1 show how partitions are split and new partitions created. In this example, there are only two dimensions, 1 and 2 (or dimensions X and Y , respectively). Initially, the entire data space is divided into two partitions by splitting its range along dimension 1 (or X axis) into two equal subpartitions, numbered 0 and 1 (see Fig. l(a)). As more points are added to a partition and it becomes full, it is subdivided to create two new partitions of equal size. (In Fig. 1, we assume that max-entries is 2, i.e., each partition can accommodate only two entries.) When partition 0 of Fig. l(a) is full, its range along the Y-axis is split to create two new partitions, 00 and 01, of equal size (see Fig. l(b)). In this case, the Y-axis is called the splitting dimension. Now, if more points are added, and partition 01 also becomes full, then its range along the X-axis is split to create two new partitions 010 and 011 (see Fig. l(c)). Finally, when partition 011 becomes full, it is split into partitions 01 10 and 01 1 1 (see Fig. l(d)).l We shall refer to the partition that is split as the p a r e n t partition and the two new partitions resulting from the split as its child partitions. With only two dimensions, the splitting dimension altemates; in general, with n dimensions, the splitting dimension recycles with a periodicity of n such that each dimension appears once in a cycle. Partition Number Arithmetic: The nonempty partitions that span the data space are maintained in a B-tree-like structure, called the Gtree. A leaf-level page in the G-tree points to a disk page containing all the points that lie in a partition, while higher level pages point to pages at the next lower level. In this subsection, we first define various operations on partitions (such as <, >, etc.), and then show that the partition numbers in a G-tree are totally ordered. Assume two partitions P 1 and P 2 - b l and b2 bits long, respectively-and also assume that b = min(b1, b2). Our definitions below are based on comparing the b most significant bits of
I It should be evident that leading zeros in the partition number string are significant. Clearly, partition 1 is different from partition 01. Although the partition numbers should strictly be viewed as strings, the quotation marks are omitted for brevity.

II. G-TREE Section 11-A describes the details of our data structure, while Sections 11-B and 11-C give algorithms for performing insertions and deletions. Finally, Section 11-D gives an example that illustrates the algorithms.
A . Data Structure We assume that each data point (or tuple) lies in an n-dimensional space, and the dimensions are numbered 1 , 2 , . . . , n. It is also assumed that the range within which the points lie along dimension i is [II, h , ] . A multidimensional data space is divided into several partitions, each containing not more than a maximum number of entries, denoted by the parameter max-entries. Each partition corresponds to one disk page or bucket and, upon becoming full, is split into two. The main features of our scheme are:

IEEE TRANSACIlONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 6, NO. 2, APRIL 1994

343

P 1 , MSB(P1,b), and the b most significant bits of P 2 , MSB(P2, b), as binary numbers. Definition I : P1 > P 2 if MSB(P1,b) > MSB(P2,b). Definition 2: P1 < P 2 if MSB(P1, b) < MSB(P2, b). Definition 3: P1 C P 2 if MSB(P1, b) = MSB(P2, b) and b l < b2. Definition 4 : P1 P 2 , if P1 C P 2 or P1 = P 2 . For example, consider that P1 = 01101 and P 2 = 0111; here, since b l = 5 and b2 = 4, b = min(5,4) = 4. Since the first 4 bits of P1 are smaller than those of P 2 , we say that P1 < P 2 or P 2 > P1. For another example, consider that P1 = 0110 and P 2 = 011011. Here, P1 is a subpartition of P 2 (i.e., P1 C P2). Similarly, we define the superpartition (3) relation as follows: Definition 5: P1 3 P 2 , if P 2 C P1. Definition 6: P1 1 P 2 , if P1 I ) P 2 or P1 = P 2 . Two other operations on partitions are defined as follows: Definition 7: The parent partition of P , parent(P), is determined by removing the last (or the least significant) bit from P. For example, parent(01110) = 0111. Definition 8: The complement of partition P , compl(P), is determined by inverting its last (or the least significant) bit. For example, compl(01110) = 01111. Lemma I :The partitions in a G-tree do not overlap and are totally ordered by the > relation. Proofi Initially, the G-tree contains two nonoverlapping partitions, and any subsequent partition split results in a larger partition being replaced by two nonoverlapping smaller partitions. On the other hand, the two smaller partitions can also be merged (after deletions occur) and replaced by the larger partition. Nevertheless, no two partitions in the G-tree overlap. Consequently, there does not exist any pair of partitions P1 and P 2 such that P1 2 P 2 or P 2 C_ P1. Hence, either P1 > P2 or P1 < P 2 . Moreover, since no two partitions overlap, it follows that each point lies in exactly one 0 and only one partition.
B . Insertion Algorithm This section describes our algorithm for inserting multidimensional points into the G-tree. The main algorithm, along with two functions it calls, assign and search, is listed below, and a detailed description follows. Algorithm Insert(z1, 1 2 , - . ., zn) /*coordinates of point to be inserted */
{

Pin = assign (a, 52,


Pact = search(P;,);

e.,

xn, size(P0));

1 1
Function assign(s1, 5 2 , e,

z , , b) /*computes an initial partition number *I

p= , , /* null string */ for (k = 1; k Sb; k +) /* repeat b times */


7).

I
i = k mod n; if (z, < (1, + h,
(

1/21

concatenate 0 to P ; h, = (1, + h, )/2; else 1 concatenate 1 to P ; 1, = (I, + h, )E;

1 1
retum ( P )

1
function search(P,,) /* search G-tree and find exact partition to which point belongs, given an initial partition P,,*/ ( P = smallest partition number in G-tree; while ( P < Pc,) /* search for P,, in G-tree */ P=Pneit P = P ; /* partition to which point belongs exists */ if (Pzn E PI) Pact = PI; /* partition to which point belongs does not exist */ else { /*find the new partition to insert */ Pact = Rn; while (P,,,, < parent(Pact) < Pnezt)/*find largest missing partition*/ Pact = parent(Pact); insert Pact into G-tree;

1
retum(Pa,t );

P,, = assign(z1, Z Z ,
Pact =

.e,

I,,

6);

I
The first step in inserting a point is to compute its partition number. Since it is not possible to exactly determine the partition to which a point belongs, an approximate, initial partition number is computed by assuming that the point will be inserted into a partition with dimensions equal to those of the smallest partition created so far. The smallest partition is the one with the most number of bits in its number. The function assign is called with the coordinates of the point (XI,5 2 , ..., 2 , ) and the number of bits b in the desired partition number as parameters (assuming that the number of bits in the smallest partition is b). It retums an initial partition number P,,, which is b bits long and contains the point. The next step is to use the initial partition number P,, as a handle to search the G-tree and retum Pact, the actual partition to which the new point belongs. This is performed by function search. The G-tree is searched for a partition P such that En P. If such a P is found, the point belongs to this partition, and Pact is set equal to P. As already shown in Lemma 1, such a P,if one exists, will be unique. On the other hand, if partition P is not found, the

search(P,,);

flag = 0; while (flag #1) if (nzlm-points(P,,t)< insert ( a , PZ, . flag = 1;


{
e.,

mas-entries)

xn) into partition Pact; into partition Pact */

/*insert point

1
else( /*split a partition*/ P O = concatenate(P,,t, 0); /*PO and P1 are child partitions of Pact*/

P1 = concatenate(Pa,.., I); delete Pact from G-tree; reallocate all points in Part to P O and P 1 ; if (numqoints(P0) > 0) /*if P O is a nonempty partition*/ insert P O into G-tree; if (num-points(P1) > 0) /*if P1 is a nonemptypartition*/ insert P1 into G-tree;

search terminates as soon as either the last partition in the G-tree is encountered, or the first partition number higher than P,, is located. In both cases, this means that a new partition must be inserted. This new partition is P,, itself or its largest ancestor that does not overlap with an existing partition in the G-tree. In order to determine the largest ancestor, successive ancestors of P,, must be compared with P,,,, and PneZt (the next lower and the next higher entries than P,, in the G-tree, respectively). This is performed within the while loop in function search. Once the correct partition number is found, a check is performed to see if this partition can accommodate one more entry. If so, the new entry is added to this partition; otherwise, the partition must be split. This means that two new child partitions of Pact must be created by appending a 0 and a 1 to it. The two new partitions created by splitting Pact are denoted P O and PI. Partition Pact is deleted from the G-tree, and all the points that belong to it are reallocated to P O and P1. The two new partitions, if nonempty', are inserted into the G-tree. On the other hand, if a partition is empty, then our algorithm does not require that it should be inserted into the G-tree. This helps in reducing the size of the tree. Unless all the points go into only one of P O or P1, the split will O and result in the creation of space for an additional point in both P P1. In this case, function assign is called again to determine the partition to which the point belongs, and the point is inserted into the partiti~n.~ On the other hand, if all the points upon splitting go into only one of P O or P1, then clearly that partition would still remain full. This means that if the newly inserted point also belongs to this partition, which is already full, then another split is necessary. The splitting must be repeated until the total number of points in Pact are distributed across more than one partition, and space is made for the new point.

1I
I
0
32

0.000000 1-000001 2 - wool0 3-oooO11 4-0001

a - 0010

12- 001100 13-001101 14- 001110 15- 001111 16- 0100 20-010100
21-010101 72-010110

23-010111 24- 01IO


28-01110 30-01111 32- 10 48-11

Fig. 2

An example of partitioning for several data points.

C . Deletion Algorithm The detetion algorithm is listed below, and then a description follows.
Algorithm Delete(z1, 2 2 ,
{

In deleting a point, the first step is to determine the partition in which it lies. As in the case of insertions, an approximate, initial partition Pin is computed by function assign. Next, a search is carried out in the G-tree for an actual partition Pact such that Pact 2 PZ,. If such a Pact is found, the given point is searched in Pact and deleted from it. On the other hand, if no Pact such that Pact 2 Pt, is found, it means that the given point does not exist. Once partition Pact is located, the next step is to check if Pact and compl(Pact) (if one exists) can be merged into a single partition. If the total number of points in partitions Pact and compl(PaCt) together is less than or equal to max-entries4, then it is possible to merge the two partitions and replace them by their parent partition. In this case, all the points belonging to Pact and compl(PaCr)are assigned to parent(P,,t), partitions Pact and compl(PaCt)are deleted from the G-tree and parent(Pact) is inserted into it.

..., 2,)

D.An

Example

P,, = assign(i1, ZZ, ..., z , , b); P = smallest partition in G-tree; while (Pz, < P) /*search for Pz, in G-tree */ P = Pnezt if (pzn P ) /*partition containing the point exists in the tree*/

1
Pact = P ; delete point (21,X Z , ..., 2,) from Pact; while (numqoints(Pa,t) + num_points(compl(P,,t)) max-entries )
(

reassign points in Pactand compl(Pact) to parent(Pact); delete Pact and compl(Pa,t) from G-tree; insert parent(Pah,t) into G-tree; Pact = gment(Pact);

I
I
else /*partition containing the point does not exist */ print("error - point does not exist");

'If all the points of P are reassigned to only one partition, say P O , then

This section gives an example to illustrate our data structure, and the insertion and deletion algorithms. Fig. 2 shows the partitioning of a two-dimensional space resulting from the addition and deletion of several points. Each dot represents a data point, and it is assumed that the maximum number of points in a partition is two. Since the data distribution is nonuniform, the partition sizes vary considerably. The legend alongside Fig. 2 shows the equivalent binary representations of the partition numbers appearing on the grid itself in decimal form. The conversion of partition numbers from binary to decimal needs some explanation. Notice that the smallest partition (in terms of area) in this figure is 6 bits long; however, some larger partition numbers are fewer than 6 bits long. These ones are padded with trailing zeros before making the conversion to decimal form. Thus, a 4-bit partition number such as OOO1 is padded with two trailing zeros and translated into decimal 4. Similarly, a 2-bit partition number such as 10 is padded with 4 trailing zeros and translated into decimal 32. It is important to note that this conversion to decimal form is done only to facilitate understanding; however, internally the partition numbers are stored as binary strings. The partition numbers are organized into a G-tree as shown in Fig. 3, and the entries in the leaf-level pages of this tree correspond to disk buckets that contain the data tuples. Further, note that partitions 24 and 32 are missing from the G-tree because they are empty partitions.
41f the complement of Pact does not exist, the number of points in it is obviously 0.

P 1 remains empty, and in that case it is not inserted into the tree.
3The function size, which appears as an argument in the call to assign,
returns the number of bits in P O .

IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 6, NO. 2. APRIL 1994

345

Algorithm range-query ( PI, = assign(qi, q;, . . ., q k , b); phz = assign(qlh, qi?, . . ., d , b); P = smallest partition in G-tree; while (P < Pl0) /* search for P i o in G-tree */ P=Pne zt while (8, 5 P' 5 Phz)
Fig. 3. G-tree for the partitions of Fig. 2.
{

To illustrate our insertion algorithm, we assume that the range of points along both X and Y dimensions is [0,1] and consider how a point with coordinates (0.9, 0.1) is inserted. Since the smallest partition in the G-tree is 6 bits long, we first compute the 6-bit partition number, 101010 (decimal 42), of the partition to which the point belongs. Next, a search is carried out in the G-tree to find 101010, or an ancestor of it. This search fails, and terminates when the next higher partition number-1 1 4 s encountered. This means that partition 101010, or an ancestor of it must be inserted. The largest ancestor of 101010 that does not overlap with any existing partition in the tree is IO (decimal 32), and therefore partition 10 would be inserted into the tree. The new point belongs to this partition. For another case of insertion, consider the addition of a point with coordinates (0.1, 0.6). This point belongs to partition 0100 (decimal 16). However, since partition 0100 is already full, it must be split into partitions 01OOO and 01001. The existing two points must be reassigned, one to each new partition, and the new point assigned to 01OOo. To understand the deletion algorithm, consider that the point with coordinates (0.4, 0.9) lying in partition 01111 (decimal 30) is to be deleted. The coordinates of this point are first converted into a 6-bit partition number, 011111 (decimal 31). Then a search for this partition is conducted in the G-tree by function search, and as a result its parent partition 01 111 is found. Next, the point is deleted from this partition. At this stage, partition 01111 can be merged with its complementary partition 01 110 to form partition 01 11, which would contain two points. Moreover, partition 0111 and its complement 01 10 (an empty partition) can also be merged to form 01 1. Therefore, as a result of deleting the point (0.4,0.9), partitions 01 111 and 01 110 would be removed from the G-tree, replaced by partition 01 1, and the points contained in them reassigned to partition 011.
111. PROCESSING RANGE QUERIES

if (overlap(P) == 1) /* P is contained in query region */ output(al1 points in P); else /* P overlaps query region */ if (overlap(P) == 2) examine each point in P and output it if it satisfies query; /* next partition in G-tree */; P = P*d

1 1
function overlap (P)
{

overlap = 0; b = size(P); /*i.e., number of bits in P */ for (i = i ; i 5 [ ; l ; i +) for 0' = 1;j 5 n ; j +)

+ +

p = n x ( i - 1) +j; if ((p 5 b) and (bit in position p == 0)) z : + z ; . 2 ; ' =

j = 1; while 0' 5 n and x y 1 2, and 1 : ' 5 h3) j if (j == n 1) overlap=l; /*partition P is contained in query region */ else{ j = 1; x 5 h, and I : ~ >_ I,) while 0' 5 n and : j +; if ( j == n 1) overlap = 2; /*partition P overlaps the query region */

+ +;

I
return(over1ap);

This section describes how range queries and partial match queries are processed using the G-tree. Partial match queries are treated as a special case of general range queries of the form: qi I X I 5 q: and and ... and 4; I X, 5 q; q i 5 .r2 5 where [ q : , q p ] : range of query along dimension i Our basic strategy consists of first identifying the smallest and largest partition numbers that could overlap with the query region. All partitions that lie within this range potentially contain points that overlap the query region. Next, the G-tree is searched and the partitions lying in this range are tested to determine whether they are fully contained in the query region, overlap the query region (but are not fully contained), or are outside the query region. If a partition is fully contained, then all points in it satisfy the query. On the other hand, if it overlaps, then each point in it must be examined and checked individually. Finally, a partition that lies outside the query region does not have to be considered any further. The algorithm is listed below, followed by a description.

1
First, the function assign is called to transform the leftmost and rightmost points of the query region into b-bit long partition numbers, 8, and Pht, respectively. Next, the G-tree is searched for partition PlO.All partitions in the range P i o through Phz are checked, by invoking function overlap, to determine if they lie wholly within the query region or overlap it. Function overlap transfork the partition number into the coordinates of its leftmost and rightmost points ( x : , xt', respectively) and then conducts two sets of tests. The first test checks if both the leftmost and rightmost points lie within the query region for a22 dimensions; if so, the partition is fully contained within the region and a value of 1 is retumed. If this test fails, then the second test checks for an overlap between the partition arrd the query region, and returns a value of 2, if successful. We illustrate the above algorithm with an example that relates to Fig. 2. Say the query region is defined by: 0.3 < x < 0.4, and 0.3 <

1 __ -

y < 0.6 (shown by the dotted rectangle in Fig. 2). The coordinates of the leftmost point in the query region are (0.3, 0.3), while the rightmost point has coordinates (0.4, 0.6). These two points lie in the 6-bit partitions 001100 (decimal 12) and 011010 (decimal 26), respectively. Next, the G-tree is searched for all partitions in this range (i.e., decimal 12 through 26), and each partition is tested for whether it overlaps or is wholly contained in the query region. The partitions that overlap the query region are denoted by decimal 12, 13, 14, and 15, while the other partitions are disjoint from the query region and can be ignored. Hence, partitions 12, 13, 14, and 15 must be examined for all points that satisfy the query.
WITHRELATED STRUCTURES IV. COMPARISON In this section, the G-tree is compared with the BD tree [4], [5],

zkdb tree [9], [lo] and KDB tree [12], and the important differences between them are highlighted.

A. BD Tree The G-tree comes closest to the BD tree because it uses the same partition numbering scheme. The main difference lies in how partitions are mapped into buckets, and how they are indexed. In the G-tree, a partition maps directly into a bucket, while in the BD tree, buckets can exclude some subpartitions from a given partition, and hence they can be defined in a more complex manner. Therefore, the BD tree guarantees a utilization of at least 50%, while the G-tree makes no such guarantees and its absolute worst-case performance can be very p r . The advantage of the G-tree over the BD tree lies in its ability to better index the partitions for efficient access. The G-tree index is similar to a B-tree, which is a balanced structure. On the other hand, the BD tree index consists of a binary search tree that can get highly unbalanced unless special methods are applied. Moreover, a binary search tree is a main memory structure, while the B-tree is more suitable for storage on disk.
B . zkdb Tree In the zkdb tree, each data point is transformed into afued-length z-order (similar to a partition number), and the z-orders are organized in a B-tree. The shortcoming of this structure lies in the fixed length of the z-order which means that the correct length of each z-order value must be predetermined. Since two different points must not have the same z-order, the exact length of this field would depend upon the total number of points in a data space and also their distribution pattem. This can be a problem in a dynamic structure. The G-tree does not suffer from this drawback because it permits variable-length partition numbers and each partition number is only as long as is necessary. The long z-order values also affect the efficiency of the query processing algorithm presented in [9], [ 101. The algorithm decomposes each query region into small boxes, each defined by a z-order as many bits long as the z-order for a data point. An ordered list is formed consisting of all the boxes in the query region and is merged with the data points stored in the tree. The performance of this algorithm is O(Q+ D), where D is the number of data points in the query region and Q is the number of boxes in it. In our algorithm, partitions that do not overlap with the query region can be eliminated from consideration as explained in the previous section. Moreover, if a partition is wholly contained within the query region then the points in it do not have to be checked individually. C. KDB Tree In the KDB tree, an entry in a higher level page defines a larger region and points to a page containing smaller, nonoverlapping

regions that lie within the larger region. On the other hand, the Gtree is a single dimension structure like the B-tree. We discuss next issues related to fanout, utilization, and ease of performing various operations in the context of these two structures. First, we shall compare the fanout' of a region page (i.e., a nonleaf page) in a KDB tree with the fanout of a nonleaf page in the G-tree. An entry in a nonleaf page of the G-tree is a (partition #, page #) pair, 8 bytes long (assuming 4 bytes per field). On the other hand, a region page entry in the KDB tree is a (region id., page #) pair. Since 2n values must be stored to define an n-dimensional hyperrectangular region, each KDB entry would occupy 20 bytes in the two-dimensional case. Therefore, the fanout for a G-tree page is 2.5 times as large as the fanout for a KDB tree page in the twodimensional case. This relative advantage increases even further for higher dimensional data. The two structures also differ in the manner that page splits are handled. In the G-tree, when a partition becomes full, it is split into two equal subpartitions. In the KDB tree when a point page (i.e., at the leaf level of the KDB tree) is full, it is split into two (usually) unequal point pages because the splitting is done so as to assign an equal number of points to each new page. This is good from a utilization point of view, but it creates problems when region pages (at the next level above the point pages) become full and are split into two new region pages. In this case, there are often point pages that span two region pages, and they must also be split in order to ensure that a point page lies entirely within one region page. The way in which point pages are split also affects the algorithm for handling deletions in the KDB tree. When points are deleted from the KDB tree, point pages can be merged together. In order to ensure that the new point page is rectangular, often a reorganization must be performed in a somewhat arbitrary manner. This means that handling deletions is hard, and moreover, if the structure is very dynamic, then the utilization can deteriorate over time. On the other hand, the G-tree has the nice property that the partitioning scheme is identical for a given set of points regardless of the order of insertions and deletions.

V. UTILIZATION The G-tree structure was simulated and tested. The purpose of these tests was to measure the average utilization of partitions (or buckets) in the G-tree and compare it with the utilization of buckets in other structures. The maximum number of points in a disk bucket is denoted by max-entries, and utilization = m Of a l entr*rs --entrzcs zn We ran several experiments in which a large number of points were inserted into the G-tree. The points were pseudo-randomly generated and drawn from two-dimensional uniform, exponential, and normal distributions. For each distribution, 50000 points were inserted into the G-tree, and the experiments were repeated several times with various seed values. The average values are reported here. The parameter max-entries was also varied to see how it affects the utilization. The results are given in Table I. Table I shows the percentage utilization as a function of the number of points inserted for different values of max-entries. The average utilization is around 69% and depends only very slightly upon the nature of the distribution from which the data is drawn. These utilization values are very close to those for both BD trees [5] and grid files [8], and better than those for KDB trees since the results reported in [12] show that the utilization of KDB trees lies in the range of 60 f 10%.

'The fanout is defined as the number of entries in a page of the index.

IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING, VOL. 6, NO. 2, APRIL 1994

347

TABLE I G-TREE BUCKET UTILIZATION FOR VARIOUS V A L U E S OF mar-entries AND DATA DISTRIBUTIONS max-entries
25

REFERENCES
J. L. Bentley, Multi-dimensional binary search trees used for associative searching, Commun. ACM, vol. 18, no. 9, pp. 509-517, Sept.

uniform 69.38 69.78 70.57

exponential 69.40 69.21 69.43

normal 68.80 68.61 68.17

50
100

VI. CONCLUSION A.new data structure called the G-tree was proposed for indexing multidimensional data. It is based on organizing variable-sized grids or partitions into a B-tree. Algorithms for searching, inserting and deleting points from this structure were given and illustrated with examples. An algorithm for processing multidimensional range queries was also given. The G-tree was compared with other related structures, such as the BD tree, zkdb tree, and the KDB tree, and the strengths and weaknesses of each approach were discussed. Finally, simulation experiments were run to determine the utilization of buckets in the G-tree. The average utilization in these experiments for various data distributions was approximately 69%. This is better than the utilization for KDB trees and compares favorably with the utilization for BD trees and grid files. The results show that even a relatively simple partitioning scheme like the one employed performs well and produces average bucket utilization similar to or better than the utilization achieved from more complex partitioning schemes.

1975. W. Burkhard, Interpolation-based index maintenance, BIT, vol. 23, no. 3, pp. 274-294, 1983. D. Comer, The ubiquitous B-tree, ACM Comput. Surveys, vol. 11, no. 2, pp. 121-137, June 1979. S. Dandamundi and P. Sorenson, An empirical performance comparison of some variations of the k-d tree and BD tree, Inr. J . Comput. Inform. Sci., vol. 14, no. 3, pp. 135-159, June 1985. S . Dandamundi and P. Sorenson, Algorithms for BD-trees, Software Practice and Experience, vol. 16, no. 12, pp. 1077-1096, Dec. 1986. M. Freeston, The bang file: A new kind of grid file, in Proc. ACM SIGMOD Conf., San Francisco, May 1987, pp. 260-269. K. Hinrichs, Implementation of the grid file: Design concepts and experience, BIT, vol. 25, no. 4, K., pp. 569-592, 1985. J. Nievergelt, H. Hinterberger, and K. Sevcik, The grid file: An adaptable, symmetric multikey file structure, ACM Trans. Database Sysr., vol. 9, no. 1, pp. 38-71, Mar. 1984. J. Orenstein and T. Merrett, A class of data structures for associative searching, in Proc. 3rd ACM SIGACT-SIGMOD Symp. Principles of Database Systems, Waterloo, Apr. 1984, pp. 181-190. Orenstein, J., Spatial query processing in an object-oriented database system, in Proc. ACM SIGMOD Conf., Washington, DC, May 1986, pp. 326-336. M. Ouksel and P. Scheuermann, Storage mappings for multidimensional linear dynamic hashing, in P roc. 2nd ACM SIGACT-SIGMOD Symp. Principles of Darabase Systems, Atlanta, Mar. 1983, pp. 90-105. J. T. Robinson, The KDB tree: A search structure for large multidimensional dynamic indexes, in Proc. ACM SIGMOD Conf., AM Arbor, MI, Apr. 1981, pp. 10-18. J. B. Rothnie and T. Lozano, Attribute based file organization in a paged memory environment, Commun. ACM, vol. 17, no. 2, Feb. 1974. H. Samet, The Design and Analysis of Spatial Data Structures. Reading, MA: Addison Wesley, 1991.

1----

You might also like