Merge branch '1.6.0-SNAPSHOT'
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/1a687381 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/1a687381 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/1a687381 Branch: refs/heads/master Commit: 1a6873815a04deb12af5c8921d93c4890f653cdd Parents: 56667cd e68d748 Author: Mike Drob <md...@cloudera.com> Authored: Fri Mar 14 10:37:27 2014 -0400 Committer: Mike Drob <md...@cloudera.com> Committed: Fri Mar 14 10:37:27 2014 -0400 ---------------------------------------------------------------------- .../accumulo/core/data/ArrayByteSequence.java | 7 +- .../apache/accumulo/core/data/KeyExtent.java | 3 +- .../core/data/ArrayByteSequenceTest.java | 107 +++++++++ .../accumulo/core/data/ByteSequenceTest.java | 41 ++++ .../apache/accumulo/core/data/ColumnTest.java | 70 ++++-- .../accumulo/core/data/KeyExtentTest.java | 240 ++++++++++++++----- .../org/apache/accumulo/core/data/KeyTest.java | 33 +++ 7 files changed, 416 insertions(+), 85 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/1a687381/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java ---------------------------------------------------------------------- diff --cc core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java index b29a667,ca769cb..9092c5b --- a/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java +++ b/core/src/main/java/org/apache/accumulo/core/data/ArrayByteSequence.java @@@ -78,22 -51,14 +78,23 @@@ public class ArrayByteSequence extends this(s.getBytes(Constants.UTF8)); } + /** + * Creates a new sequence based on a byte buffer. If the byte buffer has an + * array, that array (and the buffer's offset and limit) are used; otherwise, + * a new backing array is created and a relative bulk get is performed to + * transfer the buffer's contents (starting at its current position and + * not beyond its limit). + * + * @param buffer byte buffer + */ public ArrayByteSequence(ByteBuffer buffer) { + this.length = buffer.remaining(); + if (buffer.hasArray()) { this.data = buffer.array(); - this.offset = buffer.arrayOffset(); - this.length = buffer.limit(); + this.offset = buffer.position(); } else { - this.data = new byte[buffer.remaining()]; + this.data = new byte[length]; this.offset = 0; buffer.get(data); }