-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBPTree.java
More file actions
1263 lines (1155 loc) · 42.1 KB
/
BPTree.java
File metadata and controls
1263 lines (1155 loc) · 42.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*****************************************************************************************
* @file BPTree.java
*
* @author Farhan Jiva
*/
import static java.lang.System.out;
import java.util.*;
/*****************************************************************************************
* This class implements a B+ Tree index structure.
*/
public class BPTree implements Map
{
/** The root node of the B+ Tree.
*/
public BPNode root;
/** Init variable */
int init;
/*************************************************************************************
* Construct an empty B+ Tree. Note that the first node is a leaf and an interal node.
*/
public BPTree()
{
init = 1;
root = new BPNode();
root.isleaf = true;
}
/*************************************************************************************
* Associates the specified value with the specified key in this map
* @param key key with which the specified value is to be associated.
* @param value value to be associated with the specified key.
*/
public void put(KeyType key, Comparable [] value)
{
BPEntry entry = new BPEntry(key, value);
BPEntry nully = new BPEntry();
BPNodePointer rootPtr = new BPNodePointer(this.root);
insert(rootPtr, entry, nully);
}
/*************************************************************************************
* The procedure for insertion in a B+Tree. Insert entry *newe into subtree with root
* page *subtree (newe and subtree are pointers to nodes). The maximum number of
* separators in a page is 2, pushup is null initially and upon return unless the node
* pointed to by subtree is split. In the latter case it contains a pointer to the
* entry that must be pushed up the tree. If the number of levels in the tree increases,
* *subtree is the new root page when the outer level of recursion returns.
* @param subtree pointer to the root of a subtree.
* @param newe to insert into nodepointer.
* @param pushup is null initially, null upon return unless child is split.
*/
private void insert(BPNodePointer subtree, BPEntry newe, BPEntry pushup)
{
/* Manually create the initial stages of the tree */
/* The algorithm only works on a partially implemented B+ tree */
if(init <= 3)
{
if(root.hasroom())
{
insertSortedLeafHasRoom(root, newe);
init++;
}
else
{
/* Insert */
insertSortedLeafHasNoRoom(root, newe);
/* Split root */
BPNode L2 = new BPNode();
L2.isleaf = true;
/* Move the splitting entry into L2 */
L2.e[0] = new BPEntry(root.e[2].k, root.e[2].v);
/* Remove third entry from root */
root.e[2].k = null;
root.e[2].v = null;
root.e[2].setnull();
/* Create new parent node, this will also be the new root */
BPNode Nroot = new BPNode();
Nroot.p0 = root;
Nroot.e[0] = new BPEntry(L2.e[0].k, L2);
/* Set sibling pointers */
root.rs = L2;
L2.ls = root;
/* Repoint root */
root = Nroot;
init++;
}
return;
}
if(!subtree.ptr.isleaf)
{
BPNode N = subtree.ptr;
int i = -1;
if(newe.k.compareTo(N.e[0].k) < 0)
{
i = 0;
}
else if(N.e[1].isnull)
{
i = 1;
}
else if(N.e[0].k.compareTo(newe.k) <= 0 && newe.k.compareTo(N.e[1].k) < 0)
{
i = 1;
}
else
{
i = 2;
}
switch(i)
{
case 0: insert(new BPNodePointer(N.p0), newe, pushup); break;
case 1: insert(new BPNodePointer(N.e[0].p), newe, pushup); break;
case 2: insert(new BPNodePointer(N.e[1].p), newe, pushup); break;
default: out.println("ERROR2: Control should not reach this point"); break;
}
if(pushup.isnull) return;
else
{
if(N.hasroom()) // recall: N = *subtree
{
insertSortedNodeHasRoom(N, pushup);
pushup.setnull();
return;
}
else // N is full; it has 2 entries
{
insertSortedNodeHasNoRoom(N, pushup);
/* Split N */
BPNode N2 = new BPNode();
/* Move the splitting entry to N2 */
N2.e[0].k = N.e[2].k;
N2.e[0].p = N.e[2].p;
N2.e[0].unsetnull();
/* Remove third entry from N */
N.e[2].k = null;
N.e[2].p = null;
N.e[2].setnull();
/* Modify pushup for the recursion */
pushup.k = N2.e[0].k;
pushup.p = N2;
pushup.unsetnull();
/* Check if N was root, if so, create another root */
if(N == root)
{
BPNode Nroot = new BPNode();
/* Not entirely sure if this is what I'm suppose to do here */
Nroot.p0 = N;
Nroot.e[0] = new BPEntry(pushup.k, pushup.p);
root = Nroot;
/* Point subtree to Nroot */
subtree.ptr = Nroot;
}
}
}
}
if(subtree.ptr.isleaf)
{
BPNode L = subtree.ptr;
if(L.hasroom())
{
insertSortedLeafHasRoom(L, newe);
pushup.setnull();
return;
}
else // L is full; it has 2 entries
{
insertSortedLeafHasNoRoom(L, newe);
/* Split L */
BPNode L2 = new BPNode();
L2.isleaf = true;
/* Move the splitting entry into L2 */
L2.e[0] = new BPEntry(L.e[2].k, L.e[2].v);
/* Remove third entry from L */
L.e[2].k = null;
L.e[2].v = null;
L.e[2].setnull();
/* Modify pushup for the recursion */
pushup.k = L2.e[0].k;
pushup.p = L2;
pushup.unsetnull();
/* Set sibling pointers */
L2.rs = L.rs;
L.rs = L2;
L2.ls = L;
if(L2.rs != null) L2.rs.ls = L2;
}
}
}
/*************************************************************************************
* Insert the entry e (<k,v>) into leaf node L in sorted order.
* @param L the node to insert in.
* @param e the entry to insert.
*/
private void insertSortedLeafHasRoom(BPNode L, BPEntry e)
{
if(L.e[0].isnull && L.e[1].isnull) // trying to do the first insert
{
L.e[0] = new BPEntry(e.k, e.v);
}
else if(e.k.compareTo(L.e[0].k) > 0)
{
L.e[1] = new BPEntry(e.k, e.v);
}
else
{
L.e[1] = L.e[0];
L.e[0] = new BPEntry(e.k, e.v);
}
}
/*************************************************************************************
* Insert the entry e (<k,v>) into leaf node L in sorted order. Note that the max
* entries for a node is 2. This insertion will overflow the node (making it 3). This
* assumes that this node will be split shortly after this call.
* @param L the node to insert in.
* @param e the entry to insert.
*/
private void insertSortedLeafHasNoRoom(BPNode L, BPEntry e)
{
BPEntry tmp1 = new BPEntry(L.e[0].k, L.e[0].v);
BPEntry tmp2 = new BPEntry(L.e[1].k, L.e[1].v);
BPEntry tmp3 = new BPEntry(e.k, e.v);
BPEntry min = null, mid = null, max = null;
if(tmp1.k.compareTo(tmp2.k) < 0 && tmp1.k.compareTo(tmp3.k) < 0) //tmp1 is smallest
{
min = tmp1;
if(tmp2.k.compareTo(tmp3.k) < 0) //tmp2.k < tmp3.k
{
mid = tmp2;
max = tmp3;
}
else //tmp3.k < tmp2.k
{
mid = tmp3;
max = tmp2;
}
}
else if(tmp2.k.compareTo(tmp1.k) < 0 && tmp2.k.compareTo(tmp3.k) < 0) //tmp2 is smallest
{
min = tmp2;
if(tmp1.k.compareTo(tmp3.k) < 0) //tmp1.k < tmp3.k
{
mid = tmp1;
max = tmp3;
}
else //tmp3.k < tmp1.k
{
mid = tmp3;
max = tmp1;
}
}
else if(tmp3.k.compareTo(tmp1.k) < 0 && tmp3.k.compareTo(tmp2.k) < 0) //tmp3 is smallest
{
min = tmp3;
if(tmp1.k.compareTo(tmp2.k) < 0) //tmp1.k < tmp2.k
{
mid = tmp1;
max = tmp2;
}
else //tmp2.k < tmp1.k
{
mid = tmp2;
max = tmp1;
}
}
else
{
//Some of the keys might have been equal, this should not have happened
out.println("ERROR4: Control should not reach this point");
}
/* Insert back into L, in sorted order */
L.e[0] = min; //This entry will stay with L after the split
L.e[1] = mid; //This entry will stay with L after the split
L.e[2] = max; //This entry will split away from L
}
/*************************************************************************************
* Insert the entry e (<k,p>) into internal node N in sorted order.
* @param N the node to insert in.
* @param e the entry to insert.
*/
private void insertSortedNodeHasRoom(BPNode N, BPEntry e)
{
if(e.k.compareTo(N.e[0].k) > 0)
{
N.e[1] = new BPEntry(e.k, e.p);
}
else
{
N.e[1] = N.e[0]; //might cause issues, probably not
N.e[0] = new BPEntry(e.k, e.p);
}
}
/*************************************************************************************
* Insert the entry e (<k,p>) into internal node N in sorted order. Note that the max
* entries for a node is 2. This insertion will overflow the node (making it 3). This
* assumes that this node will be split shortly after this call.
* @param N the node to insert in.
* @param e the entry to insert.
*/
private void insertSortedNodeHasNoRoom(BPNode N, BPEntry e)
{
BPEntry tmp1 = new BPEntry(N.e[0].k, N.e[0].p);
BPEntry tmp2 = new BPEntry(N.e[1].k, N.e[1].p);
BPEntry tmp3 = new BPEntry(e.k, e.p);
BPEntry min = null, mid = null, max = null;
if(tmp1.k.compareTo(tmp2.k) < 0 && tmp1.k.compareTo(tmp3.k) < 0) //tmp1 is smallest
{
min = tmp1;
if(tmp2.k.compareTo(tmp3.k) < 0) //tmp2.k < tmp3.k
{
mid = tmp2;
max = tmp3;
}
else //tmp3.k < tmp2.k
{
mid = tmp3;
max = tmp2;
}
}
else if(tmp2.k.compareTo(tmp1.k) < 0 && tmp2.k.compareTo(tmp3.k) < 0) //tmp2 is smallest
{
min = tmp2;
if(tmp1.k.compareTo(tmp3.k) < 0) //tmp1.k < tmp3.k
{
mid = tmp1;
max = tmp3;
}
else //tmp3.k < tmp1.k
{
mid = tmp3;
max = tmp1;
}
}
else if(tmp3.k.compareTo(tmp1.k) < 0 && tmp3.k.compareTo(tmp2.k) < 0) //tmp3 is smallest
{
min = tmp3;
if(tmp1.k.compareTo(tmp2.k) < 0) //tmp1.k < tmp2.k
{
mid = tmp1;
max = tmp2;
}
else //tmp2.k < tmp1.k
{
mid = tmp2;
max = tmp1;
}
}
else
{
//Some of the keys might have been equal, this should not have happened
out.println("ERROR3: Control should not reach this point");
}
/* Insert back into N, in sorted order */
N.e[0] = min; //This entry will stay with N after the split
N.e[1] = mid; //This entry will stay with N after the split
N.e[2] = max; //This entry will split away from N
}
/*************************************************************************************
* Returns the value to which this map maps the specified key.
* Returns null if the map contains no mapping for this key.
* @param key key whose associated value is to be returned.
* @return the value to which this map maps the specified key, or null if the map
* contains no mapping for this key.
*/
public Comparable [] get(KeyType key)
{
int c = 0;
/* Start from root, iter down to leaves */
BPNode iter = root;
while(true)
{
if(iter.isleaf) // should be this this node
{
if(!iter.e[0].isnull)
{
if(iter.e[0].k.equals(key)) return iter.e[0].v;
}
if(!iter.e[1].isnull)
{
if(iter.e[1].k.equals(key)) return iter.e[1].v;
}
/* Not found, return null */
return null;
}
if(key.compareTo(iter.e[0].k) < 0)
{
iter = iter.p0;
}
else if(iter.e[1].isnull)
{
iter = iter.e[0].p;
}
else if(key.compareTo(iter.e[1].k) < 0)
{
iter = iter.e[0].p;
}
else
{
iter = iter.e[1].p;
}
}
}
/*************************************************************************************
* Returns the (leaf) BPNode which contains the key.
* Returns null if the map contains no mapping for this key.
* @param key key whose associated BPNode is to be returned.
* @return the BPNode to which this map maps the specified key, or null if the map
* contains no mapping for this key.
*/
public BPNode getnode(KeyType key)
{
int c = 0;
/* Start from root, iter down to leaves */
BPNode iter = root;
while(true)
{
if(iter.isleaf) // should be this this node
{
if(!iter.e[0].isnull)
{
if(iter.e[0].k.equals(key)) return iter;
}
if(!iter.e[1].isnull)
{
if(iter.e[1].k.equals(key)) return iter;
}
/* Not found, return null */
return null;
}
if(key.compareTo(iter.e[0].k) < 0)
{
iter = iter.p0;
}
else if(iter.e[1].isnull)
{
iter = iter.e[0].p;
}
else if(key.compareTo(iter.e[1].k) < 0)
{
iter = iter.e[0].p;
}
else
{
iter = iter.e[1].p;
}
}
}
/*****************************************************************************************
* This class implements a node object for the B+ Tree. An internal node has the form
* (p0, <k1,p1>, <k2,p2>), where <k,p> is a BPEntry object. A leaf node has the form
* (<k1,v1>, <k2,v2>) where <k,v> is a BPEntry object.
*/
class BPNode
{
/** True if this node is a leaf, false otherwise. */
public boolean isleaf;
/** The leftmost child pointer */
public BPNode p0;
/** An array of BPEntry objects */
public BPEntry [] e;
/** The siblings of the node. */
public BPNode ls, rs;
/*************************************************************************************
* Construct an empty node and initialize variables.
*/
public BPNode()
{
isleaf = false;
p0 = null;
e = new BPEntry[3];
e[0] = new BPEntry(); //Associated with k1
e[1] = new BPEntry(); //Associated with k2
e[2] = new BPEntry(); //Used during a split, not normally part of this node
ls = null;
rs = null;
}
/*************************************************************************************
* Checks if this node has room for a key
* @return whether or not this node has room for a key.
*/
public boolean hasroom()
{
if(e[0].isnull || e[1].isnull) return true;
return false;
}
/*************************************************************************************
* Returns the value associated with this node's key (either at position 1 or 2).
* This method can only be applied to leaf nodes.
* @param keypos the position of the key.
* @return the Comparable [] tuple pointed to by the key, or null.
*/
public Comparable [] getdirectvalue(int keypos)
{
if(!isleaf)
{
return null;
}
if(keypos == 1 || keypos == 2)
{
if(e[keypos-1].isnull)
{
return null;
}
else
{
return e[keypos-1].v;
}
}
return null; //keypos was invalid
}
/*************************************************************************************
* Returns the right sibling of the current node.
* This method can only be applied to leaf nodes.
* @return the BPNode pointed to by rs.
*/
public BPNode next()
{
return rs;
}
/*************************************************************************************
* Returns the left sibling of the current node.
* This method can only be applied to leaf nodes.
* @return the BPNode pointed to by ls.
*/
public BPNode prev()
{
return ls;
}
}
/*****************************************************************************************
* Because Java is not pass-by-referece (does not allow the address of a method
* variable to be modified), I have to perform this little hack to imitate passing-by
* -reference.
*/
class BPNodePointer
{
/** The BPNode object being pointed to */
public BPNode ptr;
/*************************************************************************************
* Construct a BPNodePointer object.
* @param _ptr the BPNode you want a pointer for.
*/
public BPNodePointer(BPNode _ptr)
{
this.ptr = _ptr;
}
}
/*************************************************************************************
* This class implements a BPEntry object. An entry in the index has the form <k,p> or
* <k,v>, where k is a search-key value, p is a pointer, and v is a value.
*/
class BPEntry
{
/** Used because Java is pass-by-value and not reference */
public boolean isnull;
/** The key being carried */
public KeyType k;
/** The value being carried */
public Comparable [] v;
/** The BPNode pointer being carried */
public BPNode p;
/*************************************************************************************
* Construct an empty BPEntry object.
* @param _key the key to carry.
* @param _value the value to carry.
*/
public BPEntry(KeyType _key, Comparable [] _value)
{
isnull = false;
k = _key;
v = _value;
p = null;
}
/*************************************************************************************
* Construct an empty BPEntry object.
* @param _key the key to carry.
* @param _pointer the pointer to carry.
*/
public BPEntry(KeyType _key, BPNode _pointer)
{
isnull = false;
k = _key;
v = null;
p = _pointer;
}
/*************************************************************************************
* Construct an empty BPEntry object.
*/
public BPEntry()
{
isnull = true;
k = null;
v = null;
p = null;
}
/** Set the null variable to true */
public void setnull()
{
isnull = true;
}
/** Set the null variable to false */
public void unsetnull()
{
isnull = false;
}
}
/** Extended from Map, not implemented */
public void clear()
{
//
}
/** Extended from Map, not implemented */
public boolean containsKey(Object key)
{
return false;
}
/** Extended from Map, not implemented */
public boolean containsValue(Object value)
{
return false;
}
/** Extended from Map, not implemented */
public boolean equals(Object o)
{
return false;
}
/** Extended from Map, not implemented */
public int hashCode()
{
return 0;
}
/** Extended from Map, not implemented */
public boolean isEmpty()
{
return false;
}
/** Extended from Map, not implemented */
public Set keySet()
{
return null;
}
/** Extended from Map, not implemented */
public void putAll(Map t)
{
//
}
/** Extended from Map, not implemented */
public Object remove(Object key)
{
return null;
}
/** Extended from Map, not implemented */
public int size()
{
return 0;
}
/** Extended from Map, not implemented */
public Collection values()
{
return null;
}
/** Extended from Map, not implemented */
public Set entrySet()
{
return null;
}
/** Extended from Map, not implemented */
public Object put(Object key, Object value)
{
return null;
}
/** Extended from Map, not implemented */
public Object get(Object key)
{
return null;
}
/*************************************************************************************
* The main method is used for testing purposes only.
* @param args the command-line arguments
*/
public static void main(String [] args)
{
/* Create tuples to use with keytype, using only primary key values for the content of the tuple */
// Comparable [] t1 = { "A", 1980};
// Comparable [] t2 = { "B", 1981};
// Comparable [] t3 = { "C", 1982 };
// Comparable [] t4 = { "D", 1983 };
// Comparable [] t5 = { "E", 1984 };
Comparable [] tuple1 = { "A", 1980, 124, "T", "Fox", 12345 };
Comparable [] tuple2 = { "B", 1981, 200, "T", "Universal", 12125 };
Comparable [] tuple3 = { "C", 1982, 200, "T", "Universal", 12125 };
Comparable [] tuple4 = { "D", 1983, 200, "T", "Universal", 12125 };
Comparable [] tuple5 = { "E", 1984, 200, "T", "Universal", 12125 };
Comparable [] tuple6 = { "F", 1985, 200, "T", "Universal", 12125 };
Comparable [] tuple7 = { "G", 1986, 200, "T", "Universal", 12125 };
Comparable [] tuple8 = { "H", 1987, 200, "T", "Universal", 12125 };
Comparable [] tuple9 = { "I", 1988, 200, "T", "Universal", 12125 };
Comparable [] tuple10 = { "J", 1989, 200, "T", "Universal", 12125 };
Comparable [] tuple11 = { "K", 1990, 200, "T", "Universal", 12125 };
Comparable [] tuple12 = { "L", 1991, 200, "T", "Universal", 12125 };
Comparable [] tuple13 = { "M", 1992, 200, "T", "Universal", 12125 };
Comparable [] tuple14 = { "N", 1993, 200, "T", "Universal", 12125 };
Comparable [] tuple15 = { "O", 1994, 200, "T", "Universal", 12125 };
Comparable [] tuple16 = { "P", 1995, 200, "T", "Universal", 12125 };
Comparable [] tuple17 = { "Q", 1996, 200, "T", "Universal", 12125 };
Comparable [] tuple18 = { "R", 1997, 200, "T", "Universal", 12125 };
Comparable [] tuple19 = { "S", 1998, 200, "T", "Universal", 12125 };
Comparable [] tuple20 = { "T", 1999, 200, "T", "Universal", 12125 };
Comparable [] tuple21 = { "U", 2000, 200, "T", "Universal", 12125 };
Comparable [] tuple22 = { "V", 2001, 200, "T", "Universal", 12125 };
Comparable [] tuple23 = { "W", 2002, 200, "T", "Universal", 12125 };
Comparable [] tuple24 = { "X", 2003, 200, "T", "Universal", 12125 };
Comparable [] tuple25 = { "Y", 2004, 200, "T", "Universal", 12125 };
Comparable [] tuple26 = { "Z", 2005, 200, "T", "Universal", 12125 };
Comparable [] tuple27 = { "AA", 1980, 124, "T", "Fox", 12345 };
Comparable [] tuple28 = { "BB", 1981, 200, "T", "Universal", 12125 };
Comparable [] tuple29 = { "CC", 1982, 200, "T", "Universal", 12125 };
Comparable [] tuple30 = { "DD", 1983, 200, "T", "Universal", 12125 };
Comparable [] tuple31 = { "EE", 1984, 200, "T", "Universal", 12125 };
Comparable [] tuple32 = { "FF", 1985, 200, "T", "Universal", 12125 };
Comparable [] tuple33 = { "GG", 1986, 200, "T", "Universal", 12125 };
Comparable [] tuple34 = { "HH", 1987, 200, "T", "Universal", 12125 };
Comparable [] tuple35 = { "II", 1988, 200, "T", "Universal", 12125 };
Comparable [] tuple36 = { "JJ", 1989, 200, "T", "Universal", 12125 };
Comparable [] tuple37 = { "KK", 1990, 200, "T", "Universal", 12125 };
Comparable [] tuple38 = { "LL", 1991, 200, "T", "Universal", 12125 };
Comparable [] tuple39 = { "MM", 1992, 200, "T", "Universal", 12125 };
Comparable [] tuple40 = { "NN", 1993, 200, "T", "Universal", 12125 };
Comparable [] tuple41 = { "OO", 1994, 200, "T", "Universal", 12125 };
Comparable [] tuple42 = { "PP", 1995, 200, "T", "Universal", 12125 };
Comparable [] tuple43 = { "QQ", 1996, 200, "T", "Universal", 12125 };
Comparable [] tuple44 = { "RR", 1997, 200, "T", "Universal", 12125 };
Comparable [] tuple45 = { "SS", 1998, 200, "T", "Universal", 12125 };
Comparable [] tuple46 = { "TT", 1999, 200, "T", "Universal", 12125 };
Comparable [] tuple47 = { "UU", 2000, 200, "T", "Universal", 12125 };
Comparable [] tuple48 = { "VV", 2001, 200, "T", "Universal", 12125 };
Comparable [] tuple49 = { "WW", 2002, 200, "T", "Universal", 12125 };
Comparable [] tuple50 = { "XX", 2003, 200, "T", "Universal", 12125 };
Comparable [] tuple51 = { "YY", 2004, 200, "T", "Universal", 12125 };
Comparable [] tuple52 = { "ZZ", 2005, 200, "T", "Universal", 12125 };
Comparable [] tuple53 = { "AAA", 1980, 124, "T", "Fox", 12345 };
Comparable [] tuple54 = { "BBB", 1981, 200, "T", "Universal", 12125 };
Comparable [] tuple55 = { "CCC", 1982, 200, "T", "Universal", 12125 };
Comparable [] tuple56 = { "DDD", 1983, 200, "T", "Universal", 12125 };
Comparable [] tuple57 = { "EEE", 1984, 200, "T", "Universal", 12125 };
Comparable [] tuple58 = { "FFF", 1985, 200, "T", "Universal", 12125 };
Comparable [] tuple59 = { "GGG", 1986, 200, "T", "Universal", 12125 };
Comparable [] tuple60 = { "HHH", 1987, 200, "T", "Universal", 12125 };
Comparable [] tuple61 = { "III", 1988, 200, "T", "Universal", 12125 };
Comparable [] tuple62 = { "JJJ", 1989, 200, "T", "Universal", 12125 };
Comparable [] tuple63 = { "KKK", 1990, 200, "T", "Universal", 12125 };
Comparable [] tuple64 = { "LLL", 1991, 200, "T", "Universal", 12125 };
Comparable [] tuple65 = { "MMM", 1992, 200, "T", "Universal", 12125 };
Comparable [] tuple66 = { "NNN", 1993, 200, "T", "Universal", 12125 };
Comparable [] tuple67 = { "OOO", 1994, 200, "T", "Universal", 12125 };
Comparable [] tuple68 = { "PPP", 1995, 200, "T", "Universal", 12125 };
Comparable [] tuple69 = { "QQQ", 1996, 200, "T", "Universal", 12125 };
Comparable [] tuple70 = { "RRR", 1997, 200, "T", "Universal", 12125 };
Comparable [] tuple71 = { "SSS", 1998, 200, "T", "Universal", 12125 };
Comparable [] tuple72 = { "TTT", 1999, 200, "T", "Universal", 12125 };
Comparable [] tuple73 = { "UUU", 2000, 200, "T", "Universal", 12125 };
Comparable [] tuple74 = { "VVV", 2001, 200, "T", "Universal", 12125 };
Comparable [] tuple75 = { "WWW", 2002, 200, "T", "Universal", 12125 };
Comparable [] tuple76 = { "XXX", 2003, 200, "T", "Universal", 12125 };
Comparable [] tuple77 = { "YYY", 2004, 200, "T", "Universal", 12125 };
Comparable [] tuple78 = { "ZZZ", 2005, 200, "T", "Universal", 12125 };
Comparable [] tuple79 = { "AAAA", 1980, 124, "T", "Fox", 12345 };
Comparable [] tuple80 = { "BBBB", 1981, 200, "T", "Universal", 12125 };
Comparable [] tuple81 = { "CCCC", 1982, 200, "T", "Universal", 12125 };
Comparable [] tuple82 = { "DDDD", 1983, 200, "T", "Universal", 12125 };
Comparable [] tuple83 = { "EEEE", 1984, 200, "T", "Universal", 12125 };
Comparable [] tuple84 = { "FFFF", 1985, 200, "T", "Universal", 12125 };
Comparable [] tuple85 = { "GGGG", 1986, 200, "T", "Universal", 12125 };
Comparable [] tuple86 = { "HHHH", 1987, 200, "T", "Universal", 12125 };
Comparable [] tuple87 = { "IIII", 1988, 200, "T", "Universal", 12125 };
Comparable [] tuple88 = { "JJJJ", 1989, 200, "T", "Universal", 12125 };
Comparable [] tuple89 = { "KKKK", 1990, 200, "T", "Universal", 12125 };
Comparable [] tuple90 = { "LLLL", 1991, 200, "T", "Universal", 12125 };
Comparable [] tuple91 = { "MMMM", 1992, 200, "T", "Universal", 12125 };
Comparable [] tuple92 = { "NNNN", 1993, 200, "T", "Universal", 12125 };
Comparable [] tuple93 = { "OOOO", 1994, 200, "T", "Universal", 12125 };
Comparable [] tuple94 = { "PPPP", 1995, 200, "T", "Universal", 12125 };
Comparable [] tuple95 = { "QQQQ", 1996, 200, "T", "Universal", 12125 };
Comparable [] tuple96 = { "RRRR", 1997, 200, "T", "Universal", 12125 };
Comparable [] tuple97 = { "SSSS", 1998, 200, "T", "Universal", 12125 };
Comparable [] tuple98 = { "TTTT", 1999, 200, "T", "Universal", 12125 };
Comparable [] tuple99 = { "UUUU", 2000, 200, "T", "Universal", 12125 };
Comparable [] tuple100 = { "VVVV", 2001, 200, "T", "Universal", 12125 };
Comparable [] tuple101 = { "WWWW", 2002, 200, "T", "Universal", 12125 };
Comparable [] tuple102 = { "XXXX", 2003, 200, "T", "Universal", 12125 };
Comparable [] tuple103 = { "YYYY", 2004, 200, "T", "Universal", 12125 };
Comparable [] tuple104 = { "ZZZZ", 2005, 200, "T", "Universal", 12125 };
/* Create KeyType objects with our special key-only tuples */
// KeyType key1 = new KeyType (t1, 2);
// KeyType key2 = new KeyType (t2, 2);
// KeyType key3 = new KeyType (t3, 2);
// KeyType key4 = new KeyType (t4, 2);
// KeyType key5 = new KeyType (t5, 2);
KeyType key1 = new KeyType (tuple1, 2);
KeyType key2 = new KeyType (tuple2, 2);
KeyType key3 = new KeyType (tuple3, 2);
KeyType key4 = new KeyType (tuple4, 2);
KeyType key5 = new KeyType (tuple5, 2);
KeyType key6 = new KeyType (tuple6, 2);
KeyType key7 = new KeyType (tuple7, 2);
KeyType key8 = new KeyType (tuple8, 2);
KeyType key9 = new KeyType (tuple9, 2);
KeyType key10 = new KeyType (tuple10, 2);
KeyType key11 = new KeyType (tuple11, 2);
KeyType key12 = new KeyType (tuple12, 2);
KeyType key13 = new KeyType (tuple13, 2);
KeyType key14 = new KeyType (tuple14, 2);
KeyType key15 = new KeyType (tuple15, 2);
KeyType key16 = new KeyType (tuple16, 2);
KeyType key17 = new KeyType (tuple17, 2);
KeyType key18 = new KeyType (tuple18, 2);
KeyType key19 = new KeyType (tuple19, 2);
KeyType key20 = new KeyType (tuple20, 2);
KeyType key21 = new KeyType (tuple21, 2);
KeyType key22 = new KeyType (tuple22, 2);
KeyType key23 = new KeyType (tuple23, 2);
KeyType key24 = new KeyType (tuple24, 2);
KeyType key25 = new KeyType (tuple25, 2);
KeyType key26 = new KeyType (tuple26, 2);
KeyType key27 = new KeyType (tuple27, 2);
KeyType key28 = new KeyType (tuple28, 2);
KeyType key29 = new KeyType (tuple29, 2);
KeyType key30 = new KeyType (tuple30, 2);
KeyType key31 = new KeyType (tuple31, 2);
KeyType key32 = new KeyType (tuple32, 2);
KeyType key33 = new KeyType (tuple33, 2);
KeyType key34 = new KeyType (tuple34, 2);
KeyType key35 = new KeyType (tuple35, 2);
KeyType key36 = new KeyType (tuple36, 2);
KeyType key37 = new KeyType (tuple37, 2);
KeyType key38 = new KeyType (tuple38, 2);
KeyType key39 = new KeyType (tuple39, 2);
KeyType key40 = new KeyType (tuple40, 2);
KeyType key41 = new KeyType (tuple41, 2);
KeyType key42 = new KeyType (tuple42, 2);
KeyType key43 = new KeyType (tuple43, 2);
KeyType key44 = new KeyType (tuple44, 2);
KeyType key45 = new KeyType (tuple45, 2);
KeyType key46 = new KeyType (tuple46, 2);
KeyType key47 = new KeyType (tuple47, 2);
KeyType key48 = new KeyType (tuple48, 2);
KeyType key49 = new KeyType (tuple49, 2);
KeyType key50 = new KeyType (tuple50, 2);
KeyType key51 = new KeyType (tuple51, 2);
KeyType key52 = new KeyType (tuple52, 2);
KeyType key53 = new KeyType (tuple53, 2);
KeyType key54 = new KeyType (tuple54, 2);
KeyType key55 = new KeyType (tuple55, 2);
KeyType key56 = new KeyType (tuple56, 2);
KeyType key57 = new KeyType (tuple57, 2);
KeyType key58 = new KeyType (tuple58, 2);
KeyType key59 = new KeyType (tuple59, 2);
KeyType key60 = new KeyType (tuple60, 2);
KeyType key61 = new KeyType (tuple61, 2);
KeyType key62 = new KeyType (tuple62, 2);
KeyType key63 = new KeyType (tuple63, 2);
KeyType key64 = new KeyType (tuple64, 2);
KeyType key65 = new KeyType (tuple65, 2);
KeyType key66 = new KeyType (tuple66, 2);
KeyType key67 = new KeyType (tuple67, 2);
KeyType key68 = new KeyType (tuple68, 2);
KeyType key69 = new KeyType (tuple69, 2);
KeyType key70 = new KeyType (tuple70, 2);
KeyType key71 = new KeyType (tuple71, 2);
KeyType key72 = new KeyType (tuple72, 2);
KeyType key73 = new KeyType (tuple73, 2);
KeyType key74 = new KeyType (tuple74, 2);
KeyType key75 = new KeyType (tuple75, 2);
KeyType key76 = new KeyType (tuple76, 2);
KeyType key77 = new KeyType (tuple77, 2);
KeyType key78 = new KeyType (tuple78, 2);
KeyType key79 = new KeyType (tuple79, 2);
KeyType key80 = new KeyType (tuple80, 2);
KeyType key81 = new KeyType (tuple81, 2);
KeyType key82 = new KeyType (tuple82, 2);
KeyType key83 = new KeyType (tuple83, 2);
KeyType key84 = new KeyType (tuple84, 2);
KeyType key85 = new KeyType (tuple85, 2);
KeyType key86 = new KeyType (tuple86, 2);
KeyType key87 = new KeyType (tuple87, 2);
KeyType key88 = new KeyType (tuple88, 2);
KeyType key89 = new KeyType (tuple89, 2);
KeyType key90 = new KeyType (tuple90, 2);
KeyType key91 = new KeyType (tuple91, 2);
KeyType key92 = new KeyType (tuple92, 2);
KeyType key93 = new KeyType (tuple93, 2);
KeyType key94 = new KeyType (tuple94, 2);
KeyType key95 = new KeyType (tuple95, 2);
KeyType key96 = new KeyType (tuple96, 2);
KeyType key97 = new KeyType (tuple97, 2);
KeyType key98 = new KeyType (tuple98, 2);
KeyType key99 = new KeyType (tuple99, 2);
KeyType key100 = new KeyType (tuple100, 2);
KeyType key101 = new KeyType (tuple101, 2);
KeyType key102 = new KeyType (tuple102, 2);
KeyType key103 = new KeyType (tuple103, 2);
KeyType key104 = new KeyType (tuple104, 2);
/* Insert keys/tuples randomly */
Random r = new Random();
BPTree tree = new BPTree();