h2/src/main/org/h2/mvstore/MVMap.java
/**
     * Remove a key-value pair.
     *
     * @param p the page (may not be null)
     * @param writeVersion the write version
     * @param key the key
     * @return the old value, or null if the key did not exist
     */
Remove a key-value pair.
@param p the page (may not be null)
@param writeVersion the write version
@param key the key
@return the old value, or null if the key did not exist
Remove a key - value pair . @param p the page ( may not be null ) @param writeVersion the write version @param key the key @return the old value or null if the key did not exist
protected Object remove(Page p, long writeVersion, Object key) {
        int index = p.binarySearch(key);
        Object result = null;
        if (p.isLeaf()) {
            if (index >= 0) {
                result = p.getValue(index);
                p.remove(index);
            }
            return result;
        }
        if (index < 0) {
            index = -index - 1;
        } else {
            index++;
        }
        Page cOld = p.getChildPage(index);
        Page c = copyOnWrite(cOld, writeVersion);
        result = remove(c, writeVersion, key);
        if (result == null || c.getTotalCount() != 0) {
            p.setChild(index, c);
            p.setCounts(index, c);
        } else {
            if (p.getKeyCount() == 0) {
                p.setChild(index, c);
                p.setCounts(index, c);
                c.removePage();
            } else {
                p.remove(index);
            }
        }
        return result;
    }
protected Object remove ( Page p , long writeVersion , Object key ) { int index = p . binarySearch ( key ) ; Object result = null ; if ( p . isLeaf ( ) ) { if ( index >= 0 ) { result = p . getValue ( index ) ; p . remove ( index ) ; } return result ; } if ( index < 0 ) { index = - index - 1 ; } else { index ++ ; } Page cOld = p . getChildPage ( index ) ; Page c = copyOnWrite ( cOld , writeVersion ) ; result = remove ( c , writeVersion , key ) ; if ( result == null || c . getTotalCount ( ) != 0 ) { p . setChild ( index , c ) ; p . setCounts ( index , c ) ; } else { if ( p . getKeyCount ( ) == 0 ) { p . setChild ( index , c ) ; p . setCounts ( index , c ) ; c . removePage ( ) ; } else { p . remove ( index ) ; } } return result ; }
Remove a key-value pair.
Remove a key - value pair .
// node // no change, or // there are more nodes // this child was deleted