rollback (bug in the previous commit needs to be fixed) BLD200412151900
authordprusa@netbeans.org
Wed, 15 Dec 2004 10:48:25 +0000
changeset 164723e5a2ff5441
parent 1646 6f697e35c83c
child 1648 cefc2cecd773
rollback (bug in the previous commit needs to be fixed)
mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreeindex/BtreePage.java
     1.1 --- a/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreeindex/BtreePage.java	Fri Dec 10 09:50:12 2004 +0000
     1.2 +++ b/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreeindex/BtreePage.java	Wed Dec 15 10:48:25 2004 +0000
     1.3 @@ -770,100 +770,14 @@
     1.4  	}
     1.5  	return pageSource.getPage(getData(childEntry), btree);
     1.6      }
     1.7 -    
     1.8 +
     1.9      /*
    1.10       * Search the page for an entry matching the specified key.  The leftmost
    1.11       * matching entry is returned, which may or may not be on this page.  If
    1.12       * no match was found, the location where this key would be inserted is
    1.13       * returned.
    1.14       */
    1.15 -    private SearchResult searchPage(byte[] key) throws StorageException {
    1.16 -        int base;
    1.17 -        int limit;
    1.18 -        int midpoint;
    1.19 -        byte compare;
    1.20 -        SearchResult test, result;
    1.21 -        
    1.22 -        // Binary search the entries on this page
    1.23 -        base = 0;
    1.24 -        result = null;
    1.25 -        if (numEntries() > 0) {
    1.26 -            for (base = 0, limit = numEntries(); limit > 0; limit = limit/2) {
    1.27 -                
    1.28 -                midpoint = base + limit/2;
    1.29 -                
    1.30 -                if ((compare = compare(key, midpoint)) == EntryTypeInfo.EQUAL) {
    1.31 -                    result = new SearchResult(true, midpoint, this);
    1.32 -                    if (btree.uniqueKeys) break;
    1.33 -                } else if (compare == EntryTypeInfo.GREATER) {
    1.34 -                    base = midpoint + 1;
    1.35 -                    limit--;
    1.36 -                }
    1.37 -            }
    1.38 -        }
    1.39 -        
    1.40 -        if (result == null) {
    1.41 -            result = new SearchResult(false, base, this);
    1.42 -        }
    1.43 -        
    1.44 -        // If this is a non-unique index, we're not done.
    1.45 -        if (!btree.uniqueKeys) {
    1.46 -            
    1.47 -            test = new SearchResult(result);
    1.48 -            
    1.49 -            if (!result.matched && isLeaf()) {
    1.50 -                // If there was no match, and this is a leaf page,
    1.51 -                // there could be a match on an adjoining page (this
    1.52 -                // could happen if there were duplicate entries
    1.53 -                // on this page that were deleted).
    1.54 -                if (result.entryNum == 0) {
    1.55 -                    getPrevious(key, test);
    1.56 -                    if (test.matched) {
    1.57 -                        //System.err.println("matching on previous page");
    1.58 -                        test.copy(result);
    1.59 -                    }
    1.60 -                }
    1.61 -                if (!result.matched &&
    1.62 -                        result.entryNum == numEntries()) {
    1.63 -                    //System.err.println("matching on next page");
    1.64 -                    result.copy(test);
    1.65 -                    getNext(key, test);
    1.66 -                    if (test.matched) {
    1.67 -                        test.copy(result);
    1.68 -                    }
    1.69 -                }
    1.70 -            }
    1.71 -            // Get the leftmost match
    1.72 -            if (result.matched) {
    1.73 -                result.copy(test);
    1.74 -                do {
    1.75 -                    // XXX waaay to slow to linearly traverse them.
    1.76 -                    getPrevious(key, test);
    1.77 -                    if (test.matched) {
    1.78 -                        if ((test.page != result.page) && (result.page != this)) {
    1.79 -                            pageSource.unpinPage(result.page);
    1.80 -                        }
    1.81 -                        if (test.page != result.page) { // moved across page
    1.82 -                            // find the leftmost page
    1.83 -                            SearchResult test2 = new SearchResult(test);
    1.84 -                            do {
    1.85 -                                test2.copy(test);
    1.86 -                                test2.entryNum = 0;
    1.87 -                                getPrevious(key, test2); // try previous page
    1.88 -                            } while (test2.matched);
    1.89 -                            // test contains the leftmost page now
    1.90 -                            return test.page.searchPage(key);
    1.91 -                            
    1.92 -                        }
    1.93 -                        test.copy(result);
    1.94 -                    }
    1.95 -                } while (test.matched);
    1.96 -            }
    1.97 -        }
    1.98 -        return result;
    1.99 -    }
   1.100 -    
   1.101 -    /*
   1.102 +
   1.103      private SearchResult searchPage(byte[] key) throws StorageException {
   1.104  
   1.105          int 		base;