KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > dbi > DbCursorDuplicateDeleteTest


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: DbCursorDuplicateDeleteTest.java,v 1.54 2006/10/30 21:14:43 bostic Exp $
7  */

8
9 package com.sleepycat.je.dbi;
10
11 import java.util.Hashtable JavaDoc;
12
13 import com.sleepycat.je.Cursor;
14 import com.sleepycat.je.DatabaseEntry;
15 import com.sleepycat.je.DatabaseException;
16 import com.sleepycat.je.DbInternal;
17 import com.sleepycat.je.DeadlockException;
18 import com.sleepycat.je.LockMode;
19 import com.sleepycat.je.OperationStatus;
20 import com.sleepycat.je.Transaction;
21 import com.sleepycat.je.VerifyConfig;
22 import com.sleepycat.je.junit.JUnitThread;
23 import com.sleepycat.je.tree.BIN;
24 import com.sleepycat.je.tree.DIN;
25 import com.sleepycat.je.util.StringDbt;
26
27 /**
28  * Various unit tests for CursorImpl using duplicates.
29  */

30 public class DbCursorDuplicateDeleteTest extends DbCursorTestBase {
31
32     private volatile int sequence;
33
34     public DbCursorDuplicateDeleteTest()
35         throws DatabaseException {
36
37         super();
38     }
39
40     /**
41      * Create some simple duplicate data. Delete it all. Try to create
42      * it again.
43      */

44     public void testSimpleDeleteInsert()
45     throws Throwable JavaDoc {
46
47         try {
48             initEnv(true);
49             doSimpleDuplicatePuts();
50             DataWalker dw = new DataWalker(null) {
51                     void perData(String JavaDoc foundKey, String JavaDoc foundData)
52                         throws DatabaseException {
53             if (prevKey.equals("")) {
54                 prevKey = foundKey;
55             }
56             if (!prevKey.equals(foundKey)) {
57                 deletedEntries = 0;
58             }
59             prevKey = foundKey;
60                         if (cursor.delete() == OperationStatus.SUCCESS) {
61                 deletedEntries++;
62             }
63             assertEquals(simpleKeyStrings.length - deletedEntries,
64                      cursor.count());
65                     }
66                 };
67             dw.setIgnoreDataMap(true);
68             dw.walkData();
69             doSimpleDuplicatePuts();
70
71             dw = new DataWalker(null);
72             dw.setIgnoreDataMap(true);
73             dw.walkData();
74             assertEquals(simpleKeyStrings.length * simpleKeyStrings.length,
75                          dw.nEntries);
76         } catch (Throwable JavaDoc t) {
77             t.printStackTrace();
78             throw t;
79         }
80     }
81
82     public void testCountAfterDelete()
83     throws Throwable JavaDoc {
84         initEnv(true);
85         DatabaseEntry key =
86             new DatabaseEntry(new byte[] {(byte) 'n',
87                                           (byte) 'o', (byte) 0 });
88         DatabaseEntry val1 =
89             new DatabaseEntry(new byte[] {(byte) 'k',
90                                           (byte) '1', (byte) 0 });
91         DatabaseEntry val2 =
92             new DatabaseEntry(new byte[] {(byte) 'k',
93                                           (byte) '2', (byte) 0 });
94         OperationStatus status =
95             exampleDb.putNoDupData(null, key, val1);
96         if (status != OperationStatus.SUCCESS)
97             throw new Exception JavaDoc("status on put 1=" + status);
98         status = exampleDb.putNoDupData(null, key, val2);
99         if (status != OperationStatus.SUCCESS)
100             throw new Exception JavaDoc("status on put 2=" + status);
101
102         Cursor c = exampleDb.openCursor(null, null);
103         try {
104             status = c.getSearchKey(key, new DatabaseEntry(),
105                                     LockMode.DEFAULT);
106             if (status != OperationStatus.SUCCESS)
107                 throw new Exception JavaDoc("status on search=" + status);
108         assertEquals(2, c.count());
109             status = c.delete();
110             if (status != OperationStatus.SUCCESS)
111                 throw new Exception JavaDoc("err on del 1=" + status);
112             status = c.getNext(key, new DatabaseEntry(), LockMode.DEFAULT);
113             if (status != OperationStatus.SUCCESS)
114                 throw new Exception JavaDoc("err on next=" + status);
115             status = c.delete();
116             if (status != OperationStatus.SUCCESS)
117                 throw new Exception JavaDoc("err on del 2=" + status);
118         assertEquals(0, c.count());
119         } finally {
120             c.close();
121         }
122
123         status = exampleDb.putNoDupData(null, key, val1);
124         if (status != OperationStatus.SUCCESS)
125             throw new Exception JavaDoc("err on put 3=" + status);
126
127         c = exampleDb.openCursor(null, null);
128         try {
129             status =
130         c.getSearchKey(key, new DatabaseEntry(), LockMode.DEFAULT);
131             if (status != OperationStatus.SUCCESS)
132         throw new Exception JavaDoc("err on search=" + status);
133         assertEquals(1, c.count());
134         } finally {
135             c.close();
136         }
137     }
138
139     public void testDuplicateDeletionAll()
140     throws Throwable JavaDoc {
141         
142         try {
143             initEnv(true);
144             Hashtable JavaDoc dataMap = new Hashtable JavaDoc();
145             createRandomDuplicateData(10, 1000, dataMap, false, false);
146
147             DataWalker dw = new DataWalker(dataMap) {
148                     void perData(String JavaDoc foundKey, String JavaDoc foundData)
149                         throws DatabaseException {
150                         Hashtable JavaDoc ht = (Hashtable JavaDoc) dataMap.get(foundKey);
151                         if (ht == null) {
152                             fail("didn't find ht " +
153                  foundKey + "/" + foundData);
154                         }
155
156                         if (ht.get(foundData) != null) {
157                             ht.remove(foundData);
158                             if (ht.size() == 0) {
159                                 dataMap.remove(foundKey);
160                             }
161                         } else {
162                             fail("didn't find " + foundKey + "/" + foundData);
163                         }
164
165                         /* Make sure keys are ascending/descending. */
166                         assertTrue(foundKey.compareTo(prevKey) >= 0);
167
168                         /*
169              * Make sure duplicate items within key are asc/desc.
170              */

171                         if (prevKey.equals(foundKey)) {
172                             if (duplicateComparisonFunction == null) {
173                                 assertTrue(foundData.compareTo(prevData) >= 0);
174                             } else {
175                                 assertTrue
176                                     (duplicateComparisonFunction.compare
177                                      (foundData.getBytes(),
178                                       prevData.getBytes()) >= 0);
179                             }
180                             prevData = foundData;
181                         } else {
182                             prevData = "";
183                         }
184
185                         prevKey = foundKey;
186                         assertTrue(cursor.delete() == OperationStatus.SUCCESS);
187             assertEquals(ht.size(), cursor.count());
188                     }
189                 };
190             dw.setIgnoreDataMap(true);
191             dw.walkData();
192             assertTrue(dataMap.size() == 0);
193
194             dw = new DataWalker(dataMap) {
195                     void perData(String JavaDoc foundKey, String JavaDoc foundData)
196                         throws DatabaseException {
197                         fail("data found after deletion: " +
198                  foundKey + "/" + foundData);
199                     }
200                 };
201             dw.setIgnoreDataMap(true);
202             dw.walkData();
203         } catch (Throwable JavaDoc t) {
204             t.printStackTrace();
205             throw t;
206         }
207     }
208         
209     public void testDuplicateDeletionAssorted()
210     throws Throwable JavaDoc {
211
212         try {
213             initEnv(true);
214             Hashtable JavaDoc dataMap = new Hashtable JavaDoc();
215             Hashtable JavaDoc deletedDataMap = new Hashtable JavaDoc();
216             createRandomDuplicateData(10, 1000, dataMap, false, false);
217
218             /* Use the DataWalker.addedData field for a deleted Data Map. */
219             DataWalker dw = new DataWalker(dataMap, deletedDataMap) {
220                     void perData(String JavaDoc foundKey, String JavaDoc foundData)
221                         throws DatabaseException {
222                         Hashtable JavaDoc ht = (Hashtable JavaDoc) dataMap.get(foundKey);
223                         if (ht == null) {
224                             fail("didn't find ht " +
225                  foundKey + "/" + foundData);
226                         }
227
228                         /* Make sure keys are ascending/descending. */
229                         assertTrue(foundKey.compareTo(prevKey) >= 0);
230
231                         /*
232              * Make sure duplicate items within key are asc/desc.
233              */

234                         if (prevKey.equals(foundKey)) {
235                             if (duplicateComparisonFunction == null) {
236                                 assertTrue(foundData.compareTo(prevData) >= 0);
237                             } else {
238                                 assertTrue
239                                     (duplicateComparisonFunction.compare
240                                      (foundData.getBytes(),
241                                       prevData.getBytes()) >= 0);
242                             }
243                             prevData = foundData;
244                         } else {
245                             prevData = "";
246                         }
247
248                         prevKey = foundKey;
249                         if (rnd.nextInt(10) < 8) {
250                             Hashtable JavaDoc delht =
251                                 (Hashtable JavaDoc) addedDataMap.get(foundKey);
252                             if (delht == null) {
253                                 delht = new Hashtable JavaDoc();
254                                 addedDataMap.put(foundKey, delht);
255                             }
256                             delht.put(foundData, foundData);
257                             assertTrue(cursor.delete() ==
258                        OperationStatus.SUCCESS);
259
260                             if (ht.get(foundData) == null) {
261                                 fail("didn't find " +
262                      foundKey + "/" + foundData);
263                             }
264                             ht.remove(foundData);
265                 assertEquals(ht.size(), cursor.count());
266                             if (ht.size() == 0) {
267                                 dataMap.remove(foundKey);
268                             }
269                         }
270                     }
271                 };
272             dw.setIgnoreDataMap(true);
273             dw.walkData();
274
275             dw = new DataWalker(dataMap, deletedDataMap) {
276                     void perData(String JavaDoc foundKey, String JavaDoc foundData)
277                         throws DatabaseException {
278                         Hashtable JavaDoc delht =
279                 (Hashtable JavaDoc) addedDataMap.get(foundKey);
280                         if (delht != null &&
281                             delht.get(foundData) != null) {
282                             fail("found deleted entry for " +
283                                  foundKey + "/" + foundData);
284                         }
285
286                         Hashtable JavaDoc ht = (Hashtable JavaDoc) dataMap.get(foundKey);
287                         if (ht == null) {
288                             fail("couldn't find hashtable for " + foundKey);
289                         }
290                         if (ht.get(foundData) == null) {
291                             fail("couldn't find entry for " +
292                                  foundKey + "/" + foundData);
293                         }
294                         ht.remove(foundData);
295                         if (ht.size() == 0) {
296                             dataMap.remove(foundKey);
297                         }
298                     }
299                 };
300             dw.setIgnoreDataMap(true);
301             dw.walkData();
302             assertTrue(dataMap.size() == 0);
303         } catch (Throwable JavaDoc t) {
304             t.printStackTrace();
305             throw t;
306         }
307     }
308
309     public void testDuplicateDeleteFirst()
310     throws Throwable JavaDoc {
311
312         try {
313             initEnv(true);
314             Hashtable JavaDoc dataMap = new Hashtable JavaDoc();
315             Hashtable JavaDoc deletedDataMap = new Hashtable JavaDoc();
316             createRandomDuplicateData(-10, 10, dataMap, false, false);
317
318             /* Use the DataWalker.addedData field for a deleted Data Map. */
319             DataWalker dw = new DataWalker(dataMap, deletedDataMap) {
320                     void perData(String JavaDoc foundKey, String JavaDoc foundData)
321                         throws DatabaseException {
322
323                         Hashtable JavaDoc ht = (Hashtable JavaDoc) dataMap.get(foundKey);
324                         if (ht == null) {
325                             fail("didn't find ht " +
326                  foundKey + "/" + foundData);
327                         }
328
329                         /* Make sure keys are ascending/descending. */
330                         assertTrue(foundKey.compareTo(prevKey) >= 0);
331
332                         /*
333              * Make sure duplicate items within key are asc/desc.
334              */

335                         if (prevKey.equals(foundKey)) {
336                             if (duplicateComparisonFunction == null) {
337                                 assertTrue(foundData.compareTo(prevData) >= 0);
338                             } else {
339                                 assertTrue
340                                     (duplicateComparisonFunction.compare
341                                      (foundData.getBytes(),
342                                       prevData.getBytes()) >= 0);
343                             }
344                             prevData = foundData;
345                         } else {
346                             prevData = "";
347                 if (cursor.count() > 1) {
348                 Hashtable JavaDoc delht =
349                     (Hashtable JavaDoc) addedDataMap.get(foundKey);
350                 if (delht == null) {
351                     delht = new Hashtable JavaDoc();
352                     addedDataMap.put(foundKey, delht);
353                 }
354                 delht.put(foundData, foundData);
355                 assertTrue(cursor.delete() ==
356                        OperationStatus.SUCCESS);
357
358                 if (ht.get(foundData) == null) {
359                     fail("didn't find " +
360                      foundKey + "/" + foundData);
361                 }
362                 ht.remove(foundData);
363                 assertEquals(ht.size(), cursor.count());
364                 if (ht.size() == 0) {
365                     dataMap.remove(foundKey);
366                 }
367                 }
368                         }
369
370                         prevKey = foundKey;
371                     }
372                 };
373             dw.setIgnoreDataMap(true);
374             dw.walkData();
375
376             dw = new DataWalker(dataMap, deletedDataMap) {
377                     void perData(String JavaDoc foundKey, String JavaDoc foundData)
378                         throws DatabaseException {
379                         Hashtable JavaDoc delht =
380                 (Hashtable JavaDoc) addedDataMap.get(foundKey);
381                         if (delht != null &&
382                             delht.get(foundData) != null) {
383                             fail("found deleted entry for " +
384                                  foundKey + "/" + foundData);
385                         }
386
387                         Hashtable JavaDoc ht = (Hashtable JavaDoc) dataMap.get(foundKey);
388                         if (ht == null) {
389                             fail("couldn't find hashtable for " + foundKey);
390                         }
391                         if (ht.get(foundData) == null) {
392                             fail("couldn't find entry for " +
393                                  foundKey + "/" + foundData);
394                         }
395                         ht.remove(foundData);
396                         if (ht.size() == 0) {
397                             dataMap.remove(foundKey);
398                         }
399                     }
400                 };
401             dw.setIgnoreDataMap(true);
402             dw.walkData();
403             assertTrue(dataMap.size() == 0);
404         } catch (Throwable JavaDoc t) {
405             t.printStackTrace();
406             throw t;
407         }
408     }
409
410     /**
411      * Similar to above test, but there was some question about whether
412      * this tests new functionality or not. Insert k1/d1 and d1/k1.
413      * Iterate through the data and delete k1/d1. Reinsert k1/d1 and
414      * make sure it inserts ok.
415      */

416     public void testSimpleSingleElementDupTree()
417     throws DatabaseException {
418         initEnv(true);
419     StringDbt key = new StringDbt("k1");
420     StringDbt data1 = new StringDbt("d1");
421     StringDbt data2 = new StringDbt("d2");
422
423     assertEquals(OperationStatus.SUCCESS,
424              putAndVerifyCursor(cursor, key, data1, true));
425     assertEquals(OperationStatus.SUCCESS,
426              putAndVerifyCursor(cursor, key, data2, true));
427
428     DataWalker dw = new DataWalker(null) {
429         void perData(String JavaDoc foundKey, String JavaDoc foundData)
430             throws DatabaseException {
431
432             if (foundKey.equals("k1") && deletedEntries == 0) {
433             if (cursor.delete() == OperationStatus.SUCCESS) {
434                 deletedEntries++;
435             }
436             }
437         }
438         };
439     dw.setIgnoreDataMap(true);
440     dw.walkData();
441
442     dw = new DataWalker(null) {
443         void perData(String JavaDoc foundKey, String JavaDoc foundData)
444             throws DatabaseException {
445
446             deletedEntries++;
447         }
448         };
449     dw.setIgnoreDataMap(true);
450     dw.walkData();
451
452     assertEquals(1, dw.deletedEntries);
453     }
454
455     public void testEmptyNodes()
456     throws Throwable JavaDoc {
457
458         initEnv(true);
459     synchronized (DbInternal.envGetEnvironmentImpl(exampleEnv).
460               getINCompressor()) {
461         writeEmptyNodeData();
462
463         BIN bin = null;
464         try {
465         bin = (BIN) DbInternal.dbGetDatabaseImpl(exampleDb)
466             .getTree()
467             .getFirstNode();
468         DIN dupRoot = (DIN) bin.fetchTarget(0);
469         bin.releaseLatch();
470         bin = null;
471         dupRoot.latch();
472         bin = (BIN) DbInternal.dbGetDatabaseImpl(exampleDb)
473             .getTree()
474             .getFirstNode(dupRoot);
475         bin.compress(null, true);
476         bin.releaseLatch();
477         bin = null;
478
479         Cursor cursor = exampleDb.openCursor(null, null);
480         DatabaseEntry foundKey = new DatabaseEntry();
481         DatabaseEntry foundData = new DatabaseEntry();
482         OperationStatus status = cursor.getFirst(foundKey, foundData,
483                              LockMode.DEFAULT);
484         cursor.close();
485         assertEquals(OperationStatus.SUCCESS, status);
486         } finally {
487         if (bin != null) {
488             bin.releaseLatch();
489         }
490         }
491     }
492     }
493
494     public void testDeletedReplaySR8984()
495     throws DatabaseException {
496
497     initEnvTransactional(true);
498     Transaction txn = exampleEnv.beginTransaction(null, null);
499     Cursor c = exampleDb.openCursor(txn, null);
500     c.put(simpleKeys[0], simpleData[0]);
501     c.delete();
502     for (int i = 1; i < 3; i++) {
503         c.put(simpleKeys[0], simpleData[i]);
504     }
505     c.close();
506     txn.abort();
507     txn = exampleEnv.beginTransaction(null, null);
508     c = exampleDb.openCursor(txn, null);
509     assertEquals(OperationStatus.NOTFOUND,
510              c.getFirst(new DatabaseEntry(),
511                 new DatabaseEntry(),
512                 LockMode.DEFAULT));
513     c.close();
514     txn.commit();
515     }
516
517     public void testDuplicateDeadlockSR9885()
518     throws DatabaseException {
519
520     initEnvTransactional(true);
521     Transaction txn = exampleEnv.beginTransaction(null, null);
522     Cursor c = exampleDb.openCursor(txn, null);
523     for (int i = 0; i < simpleKeyStrings.length; i++) {
524         c.put(simpleKeys[0], simpleData[i]);
525     }
526     c.close();
527     txn.commit();
528     sequence = 0;
529
530     JUnitThread tester1 =
531         new JUnitThread("testDuplicateDeadlock1") {
532         public void testBody()
533             throws DatabaseException {
534
535             DatabaseEntry key = new DatabaseEntry();
536             DatabaseEntry data = new DatabaseEntry();
537             Transaction txn1 = exampleEnv.beginTransaction(null, null);
538             Cursor cursor1 = exampleDb.openCursor(txn1, null);
539             try {
540             cursor1.getFirst(key, data, LockMode.DEFAULT);
541             sequence++;
542             while (sequence < 2) {
543                 Thread.yield();
544             }
545             cursor1.delete();
546             sequence++;
547             while (sequence < 4) {
548                 Thread.yield();
549             }
550
551             } catch (DeadlockException DBE) {
552             } finally {
553             cursor1.close();
554             txn1.abort();
555             sequence = 4;
556             }
557         }
558         };
559
560     JUnitThread tester2 =
561         new JUnitThread("testDuplicateDeadlock2") {
562         public void testBody()
563             throws DatabaseException {
564             
565             DatabaseEntry key = new DatabaseEntry();
566             DatabaseEntry data = new DatabaseEntry();
567             Transaction txn2 = exampleEnv.beginTransaction(null, null);
568             Cursor cursor2 = exampleDb.openCursor(txn2, null);
569             try {
570             while (sequence < 1) {
571                 Thread.yield();
572             }
573             cursor2.getLast(key, data, LockMode.DEFAULT);
574             sequence++;
575             //cursor2.put(key,
576
//new DatabaseEntry("d1d1d1".getBytes()));
577
cursor2.delete();
578             sequence++;
579             while (sequence < 4) {
580                 Thread.yield();
581             }
582
583             } catch (DeadlockException DBE) {
584             } finally {
585             cursor2.close();
586             txn2.abort();
587             sequence = 4;
588             }
589         }
590         };
591
592     try {
593         tester1.start();
594         tester2.start();
595         tester1.finishTest();
596         tester2.finishTest();
597         DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(exampleDb);
598         assertTrue(dbImpl.verify(new VerifyConfig(), dbImpl.getEmptyStats()));
599     } catch (Throwable JavaDoc T) {
600         fail("testDuplicateDeadlock caught: " + T);
601     }
602     }
603
604     public void testSR9992()
605     throws DatabaseException {
606
607     initEnvTransactional(true);
608     Transaction txn = exampleEnv.beginTransaction(null, null);
609     Cursor c = exampleDb.openCursor(txn, null);
610     for (int i = 1; i < simpleKeys.length; i++) {
611         c.put(simpleKeys[0], simpleData[i]);
612     }
613     DatabaseEntry key = new DatabaseEntry();
614     DatabaseEntry data = new DatabaseEntry();
615     c.getCurrent(key, data, LockMode.DEFAULT);
616     c.delete();
617     /* Expect "Can't replace a duplicate with different data." */
618     assertEquals(OperationStatus.NOTFOUND,
619              c.putCurrent(new DatabaseEntry("aaaa".getBytes())));
620     c.close();
621     txn.commit();
622     }
623
624     public void testSR9900()
625     throws DatabaseException {
626
627     initEnvTransactional(true);
628     Transaction txn = exampleEnv.beginTransaction(null, null);
629     Cursor c = exampleDb.openCursor(txn, null);
630     c.put(simpleKeys[0], simpleData[0]);
631     DatabaseEntry key = new DatabaseEntry();
632     DatabaseEntry data = new DatabaseEntry();
633     c.getCurrent(key, data, LockMode.DEFAULT);
634     c.delete();
635     /* Expect "Can't replace a duplicate with different data." */
636     assertEquals(OperationStatus.NOTFOUND,
637              c.putCurrent(new DatabaseEntry("aaaa".getBytes())));
638     c.close();
639     txn.commit();
640     }
641
642     private void put(int data, int key)
643     throws DatabaseException {
644
645     byte[] keyBytes = new byte[1];
646     keyBytes[0] = (byte) (key & 0xff);
647     DatabaseEntry keyDbt = new DatabaseEntry(keyBytes);
648
649     byte[] dataBytes = new byte[1];
650     if (data == -1) {
651         dataBytes = new byte[0];
652     } else {
653         dataBytes[0] = (byte) (data & 0xff);
654     }
655     DatabaseEntry dataDbt = new DatabaseEntry(dataBytes);
656
657     OperationStatus status = exampleDb.put(null, keyDbt, dataDbt);
658     if (status != OperationStatus.SUCCESS) {
659         System.out.println("db.put returned " + status +
660                    " for key " + key + "/" + data);
661     }
662     }
663
664     private void del(int key)
665     throws DatabaseException {
666
667     byte[] keyBytes = new byte[1];
668     keyBytes[0] = (byte) (key & 0xff);
669     DatabaseEntry keyDbt = new DatabaseEntry(keyBytes);
670
671     OperationStatus status = exampleDb.delete(null, keyDbt);
672     if (status != OperationStatus.SUCCESS) {
673         System.out.println("db.del returned " + status +
674                    " for key " + key);
675     }
676     }
677
678     private void delBoth(int key, int data)
679     throws DatabaseException {
680
681     byte[] keyBytes = new byte[1];
682     keyBytes[0] = (byte) (key & 0xff);
683     DatabaseEntry keyDbt = new DatabaseEntry(keyBytes);
684
685     byte[] dataBytes = new byte[1];
686     dataBytes[0] = (byte) (data & 0xff);
687     DatabaseEntry dataDbt = new DatabaseEntry(dataBytes);
688
689     Cursor cursor = exampleDb.openCursor(null, null);
690     OperationStatus status =
691         cursor.getSearchBoth(keyDbt, dataDbt, LockMode.DEFAULT);
692     if (status != OperationStatus.SUCCESS) {
693         System.out.println("getSearchBoth returned " + status +
694                    " for key " + key + "/" + data);
695     }
696
697     status = cursor.delete();
698     if (status != OperationStatus.SUCCESS) {
699         System.out.println("Dbc.delete returned " + status +
700                    " for key " + key + "/" + data);
701     }
702     cursor.close();
703     }
704
705     private void writeEmptyNodeData()
706     throws DatabaseException {
707
708     put(101, 1);
709     put(102, 2);
710     put(103, 3);
711     put(104, 4);
712     put(105, 5);
713     put(106, 6);
714     del(1);
715     del(3);
716     del(5);
717     put(101, 1);
718     put(103, 3);
719     put(105, 5);
720     del(1);
721     del(3);
722     del(5);
723     put(101, 1);
724     put(103, 3);
725     put(105, 5);
726     del(1);
727     del(3);
728     del(5);
729     put(101, 1);
730     put(103, 3);
731     put(105, 5);
732     del(1);
733     del(2);
734     del(3);
735     del(4);
736     del(5);
737     del(6);
738     put(102, 2);
739     put(104, 4);
740     put(106, 6);
741     put(101, 1);
742     put(103, 3);
743     put(105, 5);
744     del(1);
745     del(2);
746     del(3);
747     del(4);
748     del(5);
749     del(6);
750     put(102, 2);
751     put(104, 4);
752     put(106, 6);
753     put(101, 1);
754     put(103, 3);
755     put(105, 5);
756     del(1);
757     del(2);
758     del(3);
759     del(4);
760     del(5);
761     del(6);
762     put(102, 2);
763     put(104, 4);
764     put(106, 6);
765     put(101, 1);
766     put(103, 3);
767     put(105, 5);
768     del(1);
769     del(2);
770     del(3);
771     del(4);
772     del(5);
773     del(6);
774     put(102, 2);
775     put(104, 4);
776     put(106, 6);
777     put(101, 1);
778     put(103, 3);
779     put(105, 5);
780     del(1);
781     del(2);
782     del(3);
783     del(4);
784     del(5);
785     del(6);
786     put(102, 2);
787     put(104, 4);
788     put(106, 6);
789     put(101, 1);
790     put(103, 3);
791     put(105, 5);
792     del(1);
793     del(2);
794     del(3);
795     del(4);
796     del(5);
797     del(6);
798     put(-1, 2);
799     put(-1, 4);
800     put(-1, 6);
801     put(-1, 1);
802     put(-1, 3);
803     put(-1, 5);
804     del(1);
805     del(2);
806     del(3);
807     del(4);
808     del(5);
809     del(6);
810     put(102, 2);
811     put(104, 4);
812     put(106, 6);
813     put(101, 1);
814     put(103, 3);
815     put(105, 5);
816     del(1);
817     del(2);
818     del(3);
819     del(4);
820     del(5);
821     del(6);
822     put(102, 2);
823     put(104, 4);
824     put(106, 6);
825     put(101, 1);
826     put(103, 3);
827     put(105, 5);
828     put(102, 1);
829     put(103, 1);
830     put(104, 1);
831     put(105, 1);
832     delBoth(1, 101);
833     delBoth(1, 102);
834     delBoth(1, 103);
835     delBoth(1, 104);
836     delBoth(1, 105);
837     put(101, 1);
838     put(102, 1);
839     put(103, 1);
840     put(104, 1);
841     put(105, 1);
842     delBoth(1, 101);
843     delBoth(1, 102);
844     delBoth(1, 103);
845     delBoth(1, 104);
846     delBoth(1, 105);
847     put(101, 1);
848     put(102, 1);
849     put(103, 1);
850     put(104, 1);
851     put(105, 1);
852     delBoth(1, 101);
853     delBoth(1, 102);
854     delBoth(1, 103);
855     delBoth(1, 104);
856     delBoth(1, 105);
857     put(101, 1);
858     put(102, 1);
859     put(103, 1);
860     put(104, 1);
861     put(105, 1);
862     delBoth(1, 102);
863     delBoth(1, 103);
864     delBoth(1, 104);
865     delBoth(1, 105);
866     put(103, 2);
867     put(104, 2);
868     put(105, 2);
869     put(106, 2);
870     delBoth(2, 102);
871     delBoth(2, 103);
872     delBoth(2, 104);
873     delBoth(2, 105);
874     delBoth(2, 106);
875     put(102, 2);
876     put(103, 2);
877     put(104, 2);
878     put(105, 2);
879     put(106, 2);
880     delBoth(2, 102);
881     delBoth(2, 103);
882     delBoth(2, 104);
883     delBoth(2, 105);
884     delBoth(2, 106);
885     put(102, 2);
886     put(103, 2);
887     put(104, 2);
888     put(105, 2);
889     put(106, 2);
890     delBoth(2, 102);
891     delBoth(2, 103);
892     delBoth(2, 104);
893     delBoth(2, 105);
894     delBoth(2, 106);
895     put(102, 2);
896     put(103, 2);
897     put(104, 2);
898     put(105, 2);
899     put(106, 2);
900     delBoth(2, 102);
901     delBoth(2, 103);
902     delBoth(2, 104);
903     delBoth(2, 105);
904     delBoth(2, 106);
905     put(107, 6);
906     put(108, 6);
907     put(109, 6);
908     put(110, 6);
909     delBoth(6, 106);
910     delBoth(6, 107);
911     delBoth(6, 108);
912     delBoth(6, 109);
913     delBoth(6, 110);
914     put(106, 6);
915     put(107, 6);
916     put(108, 6);
917     put(109, 6);
918     put(110, 6);
919     delBoth(6, 106);
920     delBoth(6, 107);
921     delBoth(6, 108);
922     delBoth(6, 109);
923     delBoth(6, 110);
924     put(106, 6);
925     put(107, 6);
926     put(108, 6);
927     put(109, 6);
928     put(110, 6);
929     delBoth(6, 106);
930     delBoth(6, 107);
931     delBoth(6, 108);
932     delBoth(6, 109);
933     delBoth(6, 110);
934     put(106, 6);
935     put(107, 6);
936     put(108, 6);
937     put(109, 6);
938     put(110, 6);
939     delBoth(6, 107);
940     delBoth(6, 108);
941     delBoth(6, 109);
942     delBoth(6, 110);
943     put(106, 5);
944     put(107, 5);
945     put(108, 5);
946     put(109, 5);
947     delBoth(5, 105);
948     delBoth(5, 106);
949     delBoth(5, 107);
950     delBoth(5, 108);
951     delBoth(5, 109);
952     put(105, 5);
953     put(106, 5);
954     put(107, 5);
955     put(108, 5);
956     put(109, 5);
957     delBoth(5, 105);
958     delBoth(5, 106);
959     delBoth(5, 107);
960     delBoth(5, 108);
961     delBoth(5, 109);
962     put(105, 5);
963     put(106, 5);
964     put(107, 5);
965     put(108, 5);
966     put(109, 5);
967     delBoth(5, 105);
968     delBoth(5, 106);
969     delBoth(5, 107);
970     delBoth(5, 108);
971     delBoth(5, 109);
972     put(105, 5);
973     put(106, 5);
974     put(107, 5);
975     put(108, 5);
976     put(109, 5);
977     delBoth(5, 106);
978     delBoth(5, 107);
979     delBoth(5, 108);
980     delBoth(5, 109);
981     delBoth(1, 101);
982     }
983 }
984
Popular Tags