h2/src/main/org/h2/mvstore/Page.java
/**
     * Insert a key-value pair into this leaf.
     *
     * @param index the index
     * @param key the key
     * @param value the value
     */
Insert a key-value pair into this leaf.
@param index the index
@param key the key
@param value the value
Insert a key - value pair into this leaf . @param index the index @param key the key @param value the value
public void insertLeaf(int index, Object key, Object value) {
        if (((sharedFlags & SHARED_KEYS) == 0) && keys.length > keyCount + 1) {
            if (index < keyCount) {
                System.arraycopy(keys, index, keys, index + 1, keyCount - index);
                System.arraycopy(values, index, values, index + 1, keyCount - index);
            }
        } else {
            int len = keyCount + 6;
            Object[] newKeys = new Object[len];
            DataUtils.copyWithGap(keys, newKeys, keyCount, index);
            keys = newKeys;
            Object[] newValues = new Object[len];
            DataUtils.copyWithGap(values, newValues, keyCount, index);
            values = newValues;
        }
        keys[index] = key;
        values[index] = value;
        keyCount++;
        sharedFlags &= ~(SHARED_KEYS | SHARED_VALUES);
        totalCount++;
        memory += map.getKeyType().getMemory(key);
        memory += map.getValueType().getMemory(value);
    }
public void insertLeaf ( int index , Object key , Object value ) { if ( ( ( sharedFlags & SHARED_KEYS ) == 0 ) && keys . length > keyCount + 1 ) { if ( index < keyCount ) { System . arraycopy ( keys , index , keys , index + 1 , keyCount - index ) ; System . arraycopy ( values , index , values , index + 1 , keyCount - index ) ; } } else { int len = keyCount + 6 ; Object [ ] newKeys = new Object [ len ] ; DataUtils . copyWithGap ( keys , newKeys , keyCount , index ) ; keys = newKeys ; Object [ ] newValues = new Object [ len ] ; DataUtils . copyWithGap ( values , newValues , keyCount , index ) ; values = newValues ; } keys [ index ] = key ; values [ index ] = value ; keyCount ++ ; sharedFlags &= ~ ( SHARED_KEYS | SHARED_VALUES ) ; totalCount ++ ; memory += map . getKeyType ( ) . getMemory ( key ) ; memory += map . getValueType ( ) . getMemory ( value ) ; }
Insert a key-value pair into this leaf.
Insert a key - value pair into this leaf .