From: <tho...@us...> - 2014-01-27 16:09:39
|
Revision: 7830 http://bigdata.svn.sourceforge.net/bigdata/?rev=7830&view=rev Author: thompsonbry Date: 2014-01-27 16:09:26 +0000 (Mon, 27 Jan 2014) Log Message: ----------- Fix for [1]. This incorporates a fix for the stochastic behavior of the analytic query mode whose root cause was the failure of the leaf keys coder for the HTree to support duplicate keys. Committed to CI for feedback. I will also re-run the govtrack queries to establish a new baseline and assess the performance impact relative to the last released code. [1] https://sourceforge.net/apps/trac/bigdata/ticket/763 (Stochastic results in Analytic query mode). Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/.classpath branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/join/HTreeHashJoinUtility.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractKeyBuffer.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractRaba.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/ConditionalRabaCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/EmptyRaba.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/IRaba.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableKeysRaba.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableValueBuffer.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/AbstractCodedRaba.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/CanonicalHuffmanRabaCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/EmptyRabaValueCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FixedLengthValueRabaCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/IRabaCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/SimpleRabaCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/DirectoryPage.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/NodeSerializer.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/raba/MutableKeyBuffer.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/raba/MutableValueBuffer.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/btree/raba/codec/MutableRabaCoder.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/htree/AbstractHTreeTestCase.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/htree/TestDuplicates.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/htree/TestHTreeWithMemStore.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/test/com/bigdata/htree/TestIncrementalWrite.java branches/BIGDATA_RELEASE_1_3_0/bigdata-rdf/src/java/com/bigdata/rdf/spo/FastRDFValueCoder2.java branches/BIGDATA_RELEASE_1_3_0/build.properties branches/BIGDATA_RELEASE_1_3_0/lgpl-utils/src/java/it/unimi/dsi/fastutil/bytes/custom/CustomByteArrayFrontCodedList.java branches/BIGDATA_RELEASE_1_3_0/pom.xml Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/bigdata/lib/lgpl-utils-1.0.7-270114.jar branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoderDupKeys.java Removed Paths: ------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/lib/lgpl-utils-1.0.7-140114.jar Modified: branches/BIGDATA_RELEASE_1_3_0/.classpath =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/.classpath 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/.classpath 2014-01-27 16:09:26 UTC (rev 7830) @@ -32,7 +32,7 @@ <classpathentry kind="src" path="bigdata-gas/src/java"/> <classpathentry kind="src" path="bigdata-gas/src/test"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/dsi-utils-1.0.6-020610.jar"/> - <classpathentry exported="true" kind="lib" path="bigdata/lib/lgpl-utils-1.0.7-140114.jar"/> + <classpathentry kind="lib" path="bigdata/lib/lgpl-utils-1.0.7-270114.jar"/> <classpathentry kind="lib" path="bigdata-jini/lib/apache/zookeeper-3.3.3.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-continuation-7.2.2.v20101205.jar"/> <classpathentry exported="true" kind="lib" path="bigdata/lib/jetty/jetty-http-7.2.2.v20101205.jar"/> Deleted: branches/BIGDATA_RELEASE_1_3_0/bigdata/lib/lgpl-utils-1.0.7-140114.jar =================================================================== (Binary files differ) Added: branches/BIGDATA_RELEASE_1_3_0/bigdata/lib/lgpl-utils-1.0.7-270114.jar =================================================================== (Binary files differ) Property changes on: branches/BIGDATA_RELEASE_1_3_0/bigdata/lib/lgpl-utils-1.0.7-270114.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/join/HTreeHashJoinUtility.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/join/HTreeHashJoinUtility.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/join/HTreeHashJoinUtility.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -59,6 +59,7 @@ import com.bigdata.btree.keys.ASCIIKeyBuilderFactory; import com.bigdata.btree.keys.IKeyBuilder; import com.bigdata.btree.raba.codec.FrontCodedRabaCoder; +import com.bigdata.btree.raba.codec.FrontCodedRabaCoderDupKeys; import com.bigdata.btree.raba.codec.SimpleRabaCoder; import com.bigdata.counters.CAT; import com.bigdata.htree.HTree; @@ -486,7 +487,8 @@ @SuppressWarnings("rawtypes") final ITupleSerializer<?, ?> tupleSer = new DefaultTupleSerializer( new ASCIIKeyBuilderFactory(Bytes.SIZEOF_INT), - new FrontCodedRabaCoder(ratio),// keys : TODO Optimize for int32! + // new FrontCodedRabaCoder(ratio),// keys : TODO Optimize for int32! + new FrontCodedRabaCoderDupKeys(ratio),// keys : TODO Optimize for int32! new SimpleRabaCoder() // vals ); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/IndexMetadata.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -48,6 +48,7 @@ import com.bigdata.btree.raba.codec.CanonicalHuffmanRabaCoder; import com.bigdata.btree.raba.codec.FrontCodedRabaCoder; import com.bigdata.btree.raba.codec.FrontCodedRabaCoder.DefaultFrontCodedRabaCoder; +import com.bigdata.btree.raba.codec.FrontCodedRabaCoderDupKeys; import com.bigdata.btree.raba.codec.IRabaCoder; import com.bigdata.btree.view.FusedView; import com.bigdata.config.Configuration; @@ -2096,9 +2097,16 @@ // this.addrSer = AddressSerializer.INSTANCE; // this.nodeKeySer = PrefixSerializer.INSTANCE; + final Class keyRabaCoder; + if (this instanceof HTreeIndexMetadata) { + keyRabaCoder = FrontCodedRabaCoderDupKeys.class; + } else { + keyRabaCoder = DefaultFrontCodedRabaCoder.class; + } + this.nodeKeysCoder = newInstance(getProperty(indexManager, properties, namespace, Options.NODE_KEYS_CODER, - DefaultFrontCodedRabaCoder.class.getName()), IRabaCoder.class); + keyRabaCoder.getName()), IRabaCoder.class); // this.tupleSer = DefaultTupleSerializer.newInstance(); { @@ -2116,7 +2124,7 @@ final IRabaCoder leafKeysCoder = newInstance(getProperty( indexManager, properties, namespace, - Options.LEAF_KEYS_CODER, DefaultFrontCodedRabaCoder.class + Options.LEAF_KEYS_CODER, keyRabaCoder .getName()), IRabaCoder.class); final IRabaCoder valuesCoder = newInstance(getProperty( Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractKeyBuffer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractKeyBuffer.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractKeyBuffer.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -76,20 +76,24 @@ */ abstract protected int _binarySearch(final int searchKeyOffset, final byte[] searchKey); + @Override public Iterator<byte[]> iterator() { return new Iterator<byte[]>() { int i = 0; + @Override public boolean hasNext() { return i < size(); } + @Override public byte[] next() { return get(i++); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -107,5 +111,5 @@ * The length of the leading prefix shared by all keys. */ abstract public int getPrefixLength(); - + } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractRaba.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractRaba.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/AbstractRaba.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -124,25 +124,29 @@ this.a = a; } - + + @Override final public int size() { return (toIndex - fromIndex); } + @Override final public boolean isEmpty() { return toIndex == fromIndex; } + @Override final public boolean isFull() { return size() == capacity(); } + @Override final public int capacity() { return capacity; @@ -163,6 +167,7 @@ } + @Override final public byte[] get(final int index) { assert rangeCheck(index); @@ -171,6 +176,7 @@ } + @Override final public int length(final int index) { assert rangeCheck(index); @@ -184,6 +190,7 @@ } + @Override final public boolean isNull(final int index) { assert rangeCheck(index); @@ -192,6 +199,7 @@ } + @Override final public int copy(final int index, final OutputStream out) { assert rangeCheck(index); @@ -215,18 +223,21 @@ } + @Override final public Iterator<byte[]> iterator() { return new Iterator<byte[]>() { int i = fromIndex; + @Override public boolean hasNext() { return i < toIndex; } + @Override public byte[] next() { if (!hasNext()) @@ -236,6 +247,7 @@ } + @Override public void remove() { if (isReadOnly()) @@ -294,6 +306,7 @@ } + @Override public void set(final int index, final byte[] key) { assertNotReadOnly(); @@ -306,6 +319,7 @@ } + @Override public int add(final byte[] key) { assertNotReadOnly(); @@ -322,6 +336,7 @@ } + @Override public int add(final byte[] key, final int off, final int len) { assertNotReadOnly(); @@ -346,6 +361,7 @@ } + @Override public int add(final DataInput in, final int len) throws IOException { assertNotReadOnly(); @@ -362,6 +378,7 @@ } + @Override public int search(final byte[] searchKey) { if (!isKeys()) { @@ -375,6 +392,7 @@ } + @Override public String toString() { return toString(this); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/ConditionalRabaCoder.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/ConditionalRabaCoder.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/ConditionalRabaCoder.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -74,18 +74,27 @@ } + @Override final public boolean isKeyCoder() { return smallCoder.isKeyCoder() && bigCoder.isKeyCoder(); } + @Override final public boolean isValueCoder() { return smallCoder.isValueCoder() && bigCoder.isValueCoder(); } + @Override + public boolean isDuplicateKeys() { + + return smallCoder.isDuplicateKeys() && bigCoder.isDuplicateKeys(); + + } + /** * De-serialization ctor. */ @@ -123,6 +132,7 @@ } + @Override public ICodedRaba decode(final AbstractFixedByteArrayBuffer data) { final boolean isSmall = data.getByte(0) == 1 ? true : false; @@ -146,6 +156,7 @@ } + @Override public ICodedRaba encodeLive(final IRaba raba, final DataOutputBuffer buf) { final int size = raba.size(); @@ -175,6 +186,7 @@ } + @Override public AbstractFixedByteArrayBuffer encode(final IRaba raba, final DataOutputBuffer buf) { @@ -201,6 +213,7 @@ } + @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { @@ -220,6 +233,7 @@ } + @Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeByte(VERSION0); @@ -260,72 +274,89 @@ } + @Override public AbstractFixedByteArrayBuffer data() { return data; } + @Override public int add(byte[] value, int off, int len) { return delegate.add(value, off, len); } + @Override public int add(byte[] a) { return delegate.add(a); } + @Override public int add(DataInput in, int len) throws IOException { return delegate.add(in, len); } + @Override public int capacity() { return delegate.capacity(); } - public int copy(int index, OutputStream os) { + @Override + public int copy(final int index, final OutputStream os) { return delegate.copy(index, os); } - public byte[] get(int index) { + @Override + public byte[] get(final int index) { return delegate.get(index); } + @Override public boolean isEmpty() { return delegate.isEmpty(); } + @Override public boolean isFull() { return delegate.isFull(); } + @Override public boolean isKeys() { return delegate.isKeys(); } - public boolean isNull(int index) { + @Override + public boolean isNull(final int index) { return delegate.isNull(index); } + @Override public boolean isReadOnly() { return delegate.isReadOnly(); } + @Override public Iterator<byte[]> iterator() { return delegate.iterator(); } - public int length(int index) { + @Override + public int length(final int index) { return delegate.length(index); } - public int search(byte[] searchKey) { + @Override + public int search(final byte[] searchKey) { return delegate.search(searchKey); } - public void set(int index, byte[] a) { + @Override + public void set(final int index, final byte[] a) { delegate.set(index, a); } + @Override public int size() { return delegate.size(); } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/EmptyRaba.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/EmptyRaba.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/EmptyRaba.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -50,6 +50,7 @@ } + @Override final public boolean isKeys() { return true; @@ -78,6 +79,7 @@ } + @Override final public boolean isKeys() { return false; @@ -92,75 +94,92 @@ public EmptyRaba() { } - + + @Override final public int capacity() { return 0; } + @Override final public boolean isEmpty() { return true; } + @Override final public boolean isFull() { return true; } + @Override final public int size() { return 0; } + @Override final public boolean isReadOnly() { return true; } + @Override final public boolean isNull(int index) { throw new IndexOutOfBoundsException(); } + @Override final public int length(int index) { throw new IndexOutOfBoundsException(); } + @Override final public byte[] get(int index) { throw new IndexOutOfBoundsException(); } + @Override final public int copy(int index, OutputStream os) { throw new IndexOutOfBoundsException(); } + @Override @SuppressWarnings("unchecked") final public Iterator<byte[]> iterator() { return EmptyIterator.DEFAULT; } + @Override final public int search(byte[] searchKey) { if (isKeys()) return -1; throw new UnsupportedOperationException(); } + @Override final public void set(int index, byte[] a) { throw new UnsupportedOperationException(); } + @Override final public int add(byte[] a) { throw new UnsupportedOperationException(); } + @Override final public int add(byte[] value, int off, int len) { throw new UnsupportedOperationException(); } + @Override final public int add(DataInput in, int len) throws IOException { throw new UnsupportedOperationException(); } + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // NOP } + @Override public void writeExternal(ObjectOutput out) throws IOException { // NOP } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/IRaba.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/IRaba.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/IRaba.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -64,7 +64,6 @@ * support {@link #search(byte[])} and <code>null</code>s are allowed. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ * * @todo consider discarding all of the {@link #add(byte[])} methods. It is * typically easier and more convenient to directly manage the existing @@ -78,7 +77,7 @@ /** * Return <code>true</code> if this implementation is read-only. */ - public boolean isReadOnly(); + boolean isReadOnly(); /** * When <code>true</code> the {@link IRaba} supports search and elements are @@ -96,6 +95,19 @@ */ boolean isKeys(); + /* + * TODO This could be added to differentiate between IRaba implementations + * that do / do not support duplicate keys. The ones used with the HTree do. + * The rest do not. + */ +// /** +// * When <code>true</code>, then {@link IRaba} supports duplicate keys. +// * +// * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/763" > +// * Stochastic Results With Analytic Query Mode </a> +// */ +// boolean isDuplicateKeys(); + /** * The capacity of the logical byte[][]. * @@ -194,6 +206,7 @@ * <code>null</code>, then the iterator will report a <code>null</code> for * that element. */ + @Override public Iterator<byte[]> iterator(); /* Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableKeysRaba.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableKeysRaba.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableKeysRaba.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -42,6 +42,7 @@ /** * No - this view is mutable. */ + @Override public boolean isReadOnly() { return false; @@ -51,12 +52,13 @@ /** * Yes. */ + @Override final public boolean isKeys() { return true; } - + /** * Create a view of a byte[][]. All elements in the array are visible in the * view. @@ -113,6 +115,7 @@ } + @Override public MutableKeysRaba resize(final int n) { return (MutableKeysRaba) super.resize(n); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableValueBuffer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableValueBuffer.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/MutableValueBuffer.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -63,6 +63,7 @@ /** * For B+Tree values. */ + @Override final public boolean isKeys() { return false; @@ -142,24 +143,28 @@ } + @Override final public int size() { return nvalues; } + @Override final public boolean isEmpty() { return nvalues == 0; } + @Override final public boolean isFull() { return nvalues == values.length; } + @Override final public int capacity() { return values.length; @@ -188,6 +193,7 @@ } + @Override final public int length(final int index) { assert rangeCheck(index); @@ -201,6 +207,7 @@ } + @Override final public boolean isNull(final int index) { assert rangeCheck(index); @@ -209,6 +216,7 @@ } + @Override final public int copy(final int index, final OutputStream out) { assert rangeCheck(index); @@ -232,18 +240,21 @@ } + @Override final public Iterator<byte[]> iterator() { return new Iterator<byte[]>() { int i = 0; + @Override public boolean hasNext() { return i < nvalues; } + @Override public byte[] next() { if (!hasNext()) @@ -253,6 +264,7 @@ } + @Override public void remove() { if (isReadOnly()) @@ -281,6 +293,7 @@ } + @Override public void set(final int index, final byte[] key) { assert rangeCheck(index); @@ -289,6 +302,7 @@ } + @Override public int add(final byte[] key) { assertNotFull(); @@ -299,6 +313,7 @@ } + @Override public int add(final byte[] key, final int off, final int len) { assertNotFull(); @@ -313,6 +328,7 @@ } + @Override public int add(final DataInput in, final int len) throws IOException { assertNotFull(); @@ -327,12 +343,14 @@ } + @Override final public int search(final byte[] searchKey) { throw new UnsupportedOperationException(); } + @Override public String toString() { return AbstractRaba.toString(this); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/AbstractCodedRaba.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/AbstractCodedRaba.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/AbstractCodedRaba.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -39,7 +39,6 @@ * mutation operations. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ abstract public class AbstractCodedRaba implements ICodedRaba { @@ -50,28 +49,34 @@ /** * Implementation is read-only. */ + @Override final public boolean isReadOnly() { return true; } + @Override final public int add(byte[] a) { throw new UnsupportedOperationException(); } + @Override final public int add(byte[] value, int off, int len) { throw new UnsupportedOperationException(); } + @Override final public int add(DataInput in, int len) throws IOException { throw new UnsupportedOperationException(); } + @Override final public void set(int index, byte[] a) { throw new UnsupportedOperationException(); } + @Override final public String toString() { return AbstractRaba.toString(this); @@ -82,18 +87,21 @@ * Basic implementation may be overridden if a faster implementation is * available. */ + @Override public Iterator<byte[]> iterator() { return new Iterator<byte[]>() { int i = 0; + @Override public boolean hasNext() { return i < size(); } + @Override public byte[] next() { if (!hasNext()) @@ -103,6 +111,7 @@ } + @Override public void remove() { throw new UnsupportedOperationException(); @@ -112,5 +121,5 @@ }; } - + } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/CanonicalHuffmanRabaCoder.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/CanonicalHuffmanRabaCoder.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/CanonicalHuffmanRabaCoder.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -202,7 +202,6 @@ * the codec and the decoder, which must process 8 bytes at a time. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ public class CanonicalHuffmanRabaCoder implements IRabaCoder, Externalizable { @@ -218,21 +217,25 @@ */ final protected static transient byte VERSION0 = 0x00; + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // No state. } + @Override public void writeExternal(ObjectOutput out) throws IOException { // No state. } + @Override final public boolean isKeyCoder() { return true; } + @Override final public boolean isValueCoder() { return true; @@ -666,6 +669,7 @@ /** * Return the #of distinct symbols used to generate the code. */ + @Override abstract public int getSymbolCount(); /** @@ -930,6 +934,7 @@ private final DecoderInputs decoderInputs; + @Override public DecoderInputs decoderInputs() { return decoderInputs; @@ -956,12 +961,14 @@ } + @Override final public int byte2symbol(final byte b) { return byte2symbol.get(b); } + @Override final public byte symbol2byte(final int symbol) { return (byte) symbol2byte[symbol]; @@ -1104,6 +1111,7 @@ } + @Override public AbstractFixedByteArrayBuffer encode(final IRaba raba, final DataOutputBuffer buf) { @@ -1111,6 +1119,7 @@ } + @Override public ICodedRaba encodeLive(final IRaba raba, final DataOutputBuffer buf) { final AbstractCodingSetup setup = new RabaCodingSetup(raba); @@ -1334,6 +1343,7 @@ } + @Override public ICodedRaba decode(final AbstractFixedByteArrayBuffer data) { return new CodedRabaImpl(data); @@ -1668,6 +1678,7 @@ } + @Override final public int size() { return size; @@ -1677,12 +1688,14 @@ /** * The capacity is equal to the size (the data are immutable). */ + @Override final public int capacity() { return size; } + @Override final public boolean isEmpty() { return size == 0; @@ -1693,18 +1706,21 @@ * Always returns <code>true</code> since {@link #size()} == * {@link #capacity()} by definition for this class. */ + @Override final public boolean isFull() { return true; } + @Override final public boolean isKeys() { return isKeys; } + @Override public AbstractFixedByteArrayBuffer data() { return data; @@ -1750,6 +1766,7 @@ // // } + @Override public boolean isNull(final int index) { if (index < 0 || index >= size) @@ -1774,6 +1791,7 @@ * This computes the length of the decoded byte[] by counting the code * words for the coded value. */ + @Override public int length(final int index) { if (index < 0 || index >= size) @@ -1876,6 +1894,7 @@ * allocates the byte[]. The second pass decodes into the allocated * byte[]. */ + @Override public byte[] get(final int index) { if (index < 0 || index >= size) @@ -2048,6 +2067,7 @@ * This decodes the value at the specified index in a single pass onto * the caller's stream. */ + @Override public int copy(final int index, final OutputStream os) { if (index < 0 || index >= size) @@ -2213,6 +2233,7 @@ * Basic implementation may be overridden if a faster implementation is * available. */ + @Override public Iterator<byte[]> iterator() { /** @@ -2232,12 +2253,14 @@ int i = 0; + @Override public boolean hasNext() { return i < size(); } + @Override public byte[] next() { if (!hasNext()) @@ -2280,6 +2303,7 @@ } + @Override public void remove() { throw new UnsupportedOperationException(); @@ -2294,6 +2318,7 @@ * This is an efficient binary search performed without materializing the * coded byte[][]. */ + @Override public int search(final byte[] probe) { if (probe == null) @@ -2520,4 +2545,11 @@ } + @Override + public boolean isDuplicateKeys() { + + return false; + + } + } Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/EmptyRabaValueCoder.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/EmptyRabaValueCoder.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/EmptyRabaValueCoder.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -46,7 +46,6 @@ * B+Tree will be <strong>discarded</strong> by this {@link IRabaCoder}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ public class EmptyRabaValueCoder implements IRabaCoder, Externalizable { @@ -55,6 +54,7 @@ */ private static final long serialVersionUID = -8011456562258609162L; + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { @@ -62,6 +62,7 @@ } + @Override public void writeExternal(ObjectOutput out) throws IOException { // NOP @@ -77,6 +78,7 @@ /** * No. Keys can not be constrained to be empty. */ + @Override final public boolean isKeyCoder() { return false; @@ -86,12 +88,21 @@ /** * Yes. */ + @Override final public boolean isValueCoder() { return true; } + @Override + public boolean isDuplicateKeys() { + + return false; + + } + + @Override public ICodedRaba encodeLive(final IRaba raba, final DataOutputBuffer buf) { if (raba == null) @@ -119,6 +130,7 @@ * <strong>Any data in the {@link IRaba} will be discarded!</strong> Only * the {@link IRaba#size()} is maintained. */ + @Override public AbstractFixedByteArrayBuffer encode(final IRaba raba, final DataOutputBuffer buf) { @@ -140,6 +152,7 @@ } + @Override public ICodedRaba decode(final AbstractFixedByteArrayBuffer data) { return new EmptyCodedRaba(data); @@ -182,6 +195,7 @@ } + @Override final public AbstractFixedByteArrayBuffer data() { return data; @@ -191,43 +205,50 @@ /** * Yes. */ + @Override final public boolean isReadOnly() { return true; } + @Override public boolean isKeys() { return false; } + @Override final public int capacity() { return size; } + @Override final public int size() { return size; } + @Override final public boolean isEmpty() { return size == 0; } + @Override final public boolean isFull() { return true; } - final public boolean isNull(int index) { + @Override + final public boolean isNull(final int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); @@ -236,7 +257,8 @@ } - final public int length(int index) { + @Override + final public int length(final int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); @@ -245,7 +267,8 @@ } - final public byte[] get(int index) { + @Override + final public byte[] get(final int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); @@ -254,7 +277,8 @@ } - final public int copy(int index, OutputStream os) { + @Override + final public int copy(final int index, final OutputStream os) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); @@ -263,18 +287,21 @@ } + @Override final public Iterator<byte[]> iterator() { return new Iterator<byte[]>() { int i = 0; + @Override public boolean hasNext() { return i < size; } + @Override public byte[] next() { i++; @@ -283,6 +310,7 @@ } + @Override public void remove() { throw new UnsupportedOperationException(); @@ -299,6 +327,7 @@ * @throws UnsupportedOperationException * unless the {@link IRaba} represents B+Tree keys. */ + @Override final public int search(final byte[] searchKey) { if (isKeys()) @@ -312,22 +341,27 @@ * Mutation API is not supported. */ + @Override final public int add(byte[] a) { throw new UnsupportedOperationException(); } + @Override final public int add(byte[] value, int off, int len) { throw new UnsupportedOperationException(); } + @Override final public int add(DataInput in, int len) throws IOException { throw new UnsupportedOperationException(); } + @Override final public void set(int index, byte[] a) { throw new UnsupportedOperationException(); } + @Override final public String toString() { return AbstractRaba.toString(this); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FixedLengthValueRabaCoder.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FixedLengthValueRabaCoder.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FixedLengthValueRabaCoder.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -73,7 +73,6 @@ * </dl> * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ public class FixedLengthValueRabaCoder implements IRabaCoder, Externalizable { @@ -87,6 +86,7 @@ /** * No. */ + @Override final public boolean isKeyCoder() { return false; @@ -96,12 +96,20 @@ /** * Yes. */ + @Override final public boolean isValueCoder() { return true; } + @Override + public boolean isDuplicateKeys() { + + return false; + + } + /** * The required length for all non-<code>null</code> values. */ @@ -132,12 +140,14 @@ } + @Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeInt(len); } + @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { @@ -168,6 +178,7 @@ * if the {@link IRaba} has a non-<code>null</code> value with a * length other than the length specified to the constructor. */ + @Override public ICodedRaba encodeLive(final IRaba raba, final DataOutputBuffer buf) { if (raba == null) @@ -262,6 +273,7 @@ } + @Override public AbstractFixedByteArrayBuffer encode(final IRaba raba, final DataOutputBuffer buf) { @@ -269,6 +281,7 @@ } + @Override public ICodedRaba decode(final AbstractFixedByteArrayBuffer data) { return new CodedRabaImpl(len, data); @@ -355,36 +368,42 @@ */ private final int O_values; + @Override final public AbstractFixedByteArrayBuffer data() { return data; } + @Override public boolean isKeys() { return false; } + @Override final public int capacity() { return size; } + @Override final public int size() { return size; } + @Override final public boolean isEmpty() { return size == 0; } + @Override final public boolean isFull() { return true; @@ -398,6 +417,7 @@ } + @Override public boolean isNull(final int index) { rangeCheck(index); @@ -406,6 +426,7 @@ } + @Override public int length(final int index) { if (isNull(index)) @@ -415,6 +436,7 @@ } + @Override public byte[] get(final int index) { if (isNull(index)) @@ -431,6 +453,7 @@ } + @Override public int copy(final int index, final OutputStream os) { if (isNull(index)) @@ -456,6 +479,7 @@ * Search */ + @Override public int search(final byte[] key) { throw new UnsupportedOperationException(); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoder.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoder.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoder.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -45,7 +45,6 @@ * The data MUST be ordered. <code>null</code> values are not allowed. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ public class FrontCodedRabaCoder implements IRabaCoder, Externalizable { @@ -59,6 +58,7 @@ private int ratio; + @Override public String toString() { return super.toString() + "{ratio=" + ratio + "}"; @@ -72,7 +72,6 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> - * @version $Id$ */ public static class DefaultFrontCodedRabaCoder extends FrontCodedRabaCoder { @@ -91,11 +90,13 @@ } + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // NOP } + @Override public void writeExternal(ObjectOutput out) throws IOException { // NOP } @@ -142,18 +143,28 @@ } + @Override final public boolean isKeyCoder() { return true; } + @Override final public boolean isValueCoder() { return false; } + @Override + public boolean isDuplicateKeys() { + + return false; + + } + + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { @@ -161,6 +172,7 @@ } + @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(ratio); @@ -190,6 +202,7 @@ /** The byte offset of the start of the front-coded representation. */ private static final int O_DATA = O_RATIO + SIZEOF_RATIO; + @Override public ICodedRaba encodeLive(final IRaba raba, final DataOutputBuffer buf) { if (raba == null) @@ -212,7 +225,7 @@ // front-code the byte[][]. final CustomByteArrayFrontCodedList decoder = new CustomByteArrayFrontCodedList( - raba.iterator(), ratio); + raba.iterator(), ratio, isDuplicateKeys()); try { @@ -242,6 +255,7 @@ } + @Override public AbstractFixedByteArrayBuffer encode(final IRaba raba, final DataOutputBuffer buf) { @@ -255,9 +269,10 @@ } + @Override public ICodedRaba decode(final AbstractFixedByteArrayBuffer data) { - return new CodedRabaImpl(data); + return new CodedRabaImpl(data, isDuplicateKeys()); } @@ -278,8 +293,12 @@ * * @param data * The record containing the coded data. + * @param hasDups + * <code>true</code> iff the {@link IRabaCoder} supports + * duplicate keys. */ - public CodedRabaImpl(final AbstractFixedByteArrayBuffer data) { + public CodedRabaImpl(final AbstractFixedByteArrayBuffer data, + final boolean hasDups) { final byte version = data.getByte(O_VERSION); @@ -297,7 +316,7 @@ // wrap slice with decoder. this.decoder = new CustomByteArrayFrontCodedList(size, ratio, data - .array(), data.off() + O_DATA, data.len()); + .array(), data.off() + O_DATA, data.len(), hasDups); this.data = data; @@ -321,6 +340,7 @@ } + @Override public AbstractFixedByteArrayBuffer data() { return data; @@ -330,24 +350,28 @@ /** * Represents B+Tree keys. */ + @Override final public boolean isKeys() { return true; } + @Override final public int size() { return decoder.size(); } + @Override final public int capacity() { return decoder.size(); } + @Override final public boolean isEmpty() { return size() == 0; @@ -358,6 +382,7 @@ * Always returns <code>true</code> since the front-coded representation * is dense. */ + @Override final public boolean isFull() { return true; @@ -368,24 +393,28 @@ * Always returns <code>false</code> (<code>null</code>s are not * allowed). */ + @Override final public boolean isNull(final int index) { return false; } + @Override final public byte[] get(final int index) { return decoder.get(index); } + @Override final public int length(final int index) { return decoder.arrayLength(index); } + @Override public int copy(final int index, final OutputStream os) { try { @@ -400,12 +429,14 @@ } + @Override public Iterator<byte[]> iterator() { return decoder.iterator(); } + @Override public int search(final byte[] searchKey) { // optimization: always keys. Added: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoderDupKeys.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoderDupKeys.java (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/FrontCodedRabaCoderDupKeys.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -0,0 +1,59 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.btree.raba.codec; + +/** + * Variant of the {@link FrontCodedRabaCoder} that supports duplicate keys. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +public class FrontCodedRabaCoderDupKeys extends FrontCodedRabaCoder { + + /** + * A default instance. + */ + public static final transient FrontCodedRabaCoderDupKeys INSTANCE = new FrontCodedRabaCoderDupKeys(); + + protected transient static final int DEFAULT_RATIO = 8; + + public FrontCodedRabaCoderDupKeys(final int ratio) { + + super(ratio); + + } + + public FrontCodedRabaCoderDupKeys() { + + super(DEFAULT_RATIO); + + } + + @Override + public boolean isDuplicateKeys() { + + return true; + + } + +} Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/IRabaCoder.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/IRabaCoder.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/IRabaCoder.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -36,7 +36,6 @@ * @see IRaba * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ public interface IRabaCoder extends Serializable { @@ -55,6 +54,14 @@ boolean isValueCoder(); /** + * Return true iff this {@link IRabaCoder} supports duplicate keys. + * + * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/763" > + * Stochastic Results With Analytic Query Mode </a> + */ + boolean isDuplicateKeys(); + + /** * Encode the data, returning an {@link ICodedRaba}. Implementations of this * method should be optimized for the very common use case where the caller * requires immediate access to the coded data record. In that case, many of Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/SimpleRabaCoder.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/SimpleRabaCoder.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/btree/raba/codec/SimpleRabaCoder.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -47,7 +47,6 @@ * and B+Tree values. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ */ public class SimpleRabaCoder implements IRabaCoder, Externalizable { @@ -74,6 +73,7 @@ /** * Yes. */ + @Override final public boolean isKeyCoder() { return true; @@ -83,25 +83,35 @@ /** * Yes. */ + @Override final public boolean isValueCoder() { return true; } - /** + @Override + public boolean isDuplicateKeys() { + + return false; + + } + + /** * De-serialization ctor. Use {@link #INSTANCE} otherwise. */ public SimpleRabaCoder() { } + @Override public void writeExternal(ObjectOutput out) throws IOException { // NOP } + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { @@ -136,6 +146,7 @@ return O_SIZE + SIZEOF_SIZE + SIZEOF_CAPACITY; } + @Override public ICodedRaba encodeLive(final IRaba raba, final DataOutputBuffer buf) { if (raba == null) @@ -244,6 +255,7 @@ } + @Override public AbstractFixedByteArrayBuffer encode(final IRaba raba, final DataOutputBuffer buf) { @@ -256,6 +268,7 @@ } + @Override public ICodedRaba decode(final AbstractFixedByteArrayBuffer data) { return new CodedRabaImpl(data); @@ -366,36 +379,42 @@ */ private final int O_offsets; + @Override final public AbstractFixedByteArrayBuffer data() { return data; } + @Override public boolean isKeys() { return isKeys; } + @Override final public int capacity() { return capacity; } + @Override final public int size() { return size; } + @Override final public boolean isEmpty() { return size == 0; } + @Override final public boolean isFull() { return true; @@ -409,6 +428,7 @@ } + @Override public boolean isNull(final int index) { if (index >= size && index < capacity) { @@ -425,6 +445,7 @@ } + @Override public int length(final int index) { if (isNull(index)) @@ -443,6 +464,7 @@ } + @Override public byte[] get(final int index) { if (isNull(index)) @@ -477,6 +499,7 @@ } + @Override public int copy(final int index, final OutputStream os) { if (isNull(index)) @@ -509,6 +532,7 @@ * Search */ + @Override public int search(final byte[] key) { if (!isKeys()) Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/DirectoryPage.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/DirectoryPage.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/DirectoryPage.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -38,7 +38,6 @@ import com.bigdata.btree.ITuple; import com.bigdata.btree.ITupleIterator; import com.bigdata.btree.Node; -import com.bigdata.btree.PageStats; import com.bigdata.htree.AbstractHTree.ChildMemoizer; import com.bigdata.htree.AbstractHTree.LoadChildRequest; import com.bigdata.htree.data.IDirectoryData; @@ -2058,6 +2057,23 @@ } /** + * If this is an overflow directory then the depth-based hashCode is irrelevant + * since it is used as a blob container for BucketPage references. + */ + public int getLocalHashCode(final byte[] key, final int prefixLength) { + if (isOverflowDirectory()) { + /* + * Shouldn't need to check the key, this will be handled when + * the BucketPage is checked for a precise match + */ + return 0; + } + + return super.getLocalHashCode(key, prefixLength); + + } + + /** * This method is never called at present since DirectoryPages are * always created at maximum depth. Whether there is any advantage * in supporting pages of lesser depths is yet to be determined. Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/NodeSerializer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/NodeSerializer.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/NodeSerializer.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -253,6 +253,19 @@ */ this.nodeCoder = new DefaultDirectoryPageCoder(); + if (!indexMetadata.getTupleSerializer().getLeafKeysCoder().isDuplicateKeys()) { + + /* + * This constraint *could* be relaxed, but the HTree API presumes + * that we can have duplicate keys and this check verifies tha the + * keys coder supports duplicate keys. + */ + + throw new IllegalArgumentException( + "The leaf keys coder for HTree should allow duplicate keys."); + + } + /* * Note: We are using the same leaf coder class as the BTree. */ Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/raba/MutableKeyBuffer.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/raba/MutableKeyBuffer.java 2014-01-26 20:37:25 UTC (rev 7829) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/htree/raba/MutableKeyBuffer.java 2014-01-27 16:09:26 UTC (rev 7830) @@ -187,6 +187,7 @@ } + @Override public String toString() { return AbstractRaba.toString(this); @@ -196,12 +197,14 @@ /** * Returns a reference to the key at that index. */ + @Override final public byte[] get(final int index) { return keys[index]; } + @Override final public int length(final int index) { final byte[] tmp = keys[index]; @@ -213,6 +216,7 @@ } + @Override final public int copy(final int index, final OutputStream out) { final byte[] tmp = keys[index]; @@ -236,12 +240,14 @@ * * @return <code>true</code> iff the key at that index is <code>null</code>. */ + @Override final public boolean isNull(final int index) { return keys[index] == null; } + @Override final public boolean isEmpty() { return nkeys == 0; @@ -256,18 +262,21 @@ * MUST explicitly scan a buddy bucket to determine the #of keys in a buddy * bucket on the page. */ + @Override final public int size() { return nkeys; } + @Override final public int capacity() { return keys.length; } + @Override final public boolean isFull() { return nkeys == keys.length; @@ -277,6 +286,7 @@ /** * Mutable. */ + @Override final public boolean isReadOnly() { return false; @@ -284,11 +294,11 @@ } /** - * Instances are NOT searchable. Duplicates and <code>null</code>s ARE - * permitted. + * Instances are searchable and support duplicate keys. * - * @returns <code>false</code> + * @returns <code>true</code> */ + @Override final public boolean isKeys() { return true; @@ -301,20 +311,24 @@ * This iterator visits all keys on the bucket page, including * <code>null</code>s. */ + @Override public Iterator<byte[]> iterator() { return new Iterator<byte[]>() { int i = 0; + @Override public boolean hasNext() { return i < size(); } + @Override public byte[] next() { return get(i++); } + @Override public void remove() { throw new UnsupportedOperationException(); } @@ -32... [truncated message content] |