From: <mar...@us...> - 2010-10-19 08:50:37
|
Revision: 3816 http://bigdata.svn.sourceforge.net/bigdata/?rev=3816&view=rev Author: martyncutcher Date: 2010-10-19 08:50:30 +0000 (Tue, 19 Oct 2010) Log Message: ----------- merge range check code from trunk Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java 2010-10-18 19:15:33 UTC (rev 3815) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java 2010-10-19 08:50:30 UTC (rev 3816) @@ -744,17 +744,37 @@ @Override public byte[] keyAt(final int entryIndex) { + rangeCheck(entryIndex); + return getKeys().get(entryIndex); } @Override public void valueAt(final int entryIndex, final Tuple tuple) { + + rangeCheck(entryIndex); tuple.copy(entryIndex, this); - + } + final protected boolean rangeCheck(final int index) + throws IndexOutOfBoundsException { + + final int nkeys = data.getKeyCount(); + + if (index < 0 || index >= nkeys) { + + throw new IndexOutOfBoundsException("index=" + index + ", nkeys=" + + nkeys); + + } + + return true; + + } + /** * <p> * Split an over-capacity leaf (a leaf with <code>maxKeys+1</code> keys), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |