You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nk...@apache.org on 2013/08/11 15:27:04 UTC
svn commit: r1512919 - in /hbase/branches/0.95:
hbase-common/src/main/java/org/apache/hadoop/hbase/
hbase-common/src/main/java/org/apache/hadoop/hbase/util/
hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/row/
hbase-pref...
Author: nkeywal
Date: Sun Aug 11 13:27:04 2013
New Revision: 1512919
URL: http://svn.apache.org/r1512919
Log:
HBASE-9091 Update ByteRange to maintain consumer's position (Nick Dimiduck)
Modified:
hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteRange.java
hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/row/RowNodeReader.java
hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/PrefixTreeEncoder.java
hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/row/RowNodeWriter.java
hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/tokenize/TokenizerNode.java
hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/ByteRangeSet.java
hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/impl/ByteRangeTreeSet.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTokenizer.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTreeDepth.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/TestColumnBuilder.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataRandom.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataSimple.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataExerciseFInts.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataUrls.java
hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/util/bytes/TestByteRange.java
Modified: hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java (original)
+++ hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java Sun Aug 11 13:27:04 2013
@@ -22,7 +22,7 @@ import java.nio.ByteBuffer;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
-import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.IterableUtils;
import org.apache.hadoop.io.WritableUtils;
@@ -175,7 +175,7 @@ public class KeyValueUtil {
* Increment the row bytes and clear the other fields
*/
public static KeyValue createFirstKeyInIncrementedRow(final Cell in){
- byte[] thisRow = new ByteRange(in.getRowArray(), in.getRowOffset(), in.getRowLength())
+ byte[] thisRow = new SimpleByteRange(in.getRowArray(), in.getRowOffset(), in.getRowLength())
.deepCopyToNewArray();
byte[] nextRow = Bytes.unsignedCopyAndIncrement(thisRow);
return KeyValue.createFirstOnRow(nextRow);
Modified: hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteRange.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteRange.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteRange.java (original)
+++ hbase/branches/0.95/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteRange.java Sun Aug 11 13:27:04 2013
@@ -18,282 +18,229 @@
package org.apache.hadoop.hbase.util;
-
-
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
/**
- * Lightweight, reusable class for specifying ranges of byte[]'s. CompareTo and equals methods are
- * lexicographic, which is native to HBase.
- * <p/>
- * This class differs from ByteBuffer:
- * <li/>On-heap bytes only
- * <li/>Implements equals, hashCode, and compareTo so that it can be used in standard java
- * Collections, similar to String.
- * <li/>Does not maintain mark/position iterator state inside the class. Doing so leads to many bugs
- * in complex applications.
- * <li/>Allows the addition of simple core methods like this.copyTo(that, offset).
- * <li/>Can be reused in tight loops like a major compaction which can save significant amounts of
- * garbage.
- * <li/>(Without reuse, we throw off garbage like this thing:
- * http://www.youtube.com/watch?v=lkmBH-MjZF4
- * <p/>
- * Mutable, and always evaluates equals, hashCode, and compareTo based on the current contents.
- * <p/>
- * Can contain convenience methods for comparing, printing, cloning, spawning new arrays, copying to
- * other arrays, etc. Please place non-core methods into {@link ByteRangeTool}.
- * <p/>
- * We may consider converting this to an interface and creating separate implementations for a
- * single byte[], a paged byte[] (growable byte[][]), a ByteBuffer, etc
+ * Lightweight, reusable class for specifying ranges of byte[]'s.
+ * <p>
+ * {@code ByteRange} maintains an underlying byte[] and a viewport into that
+ * byte[] as a range of bytes. The {@code ByteRange} is a mutable, reusable
+ * object, so the underlying byte[] can be modified after instantiation. This
+ * is done using the {@link #set(byte[])} and {@link #unset()} methods. Direct
+ * access to the byte[] is also available via {@link #getBytes()}. The viewport
+ * is defined by an {@code offset} into the byte[] and a {@code length}. The
+ * range of bytes is 0-indexed, and is accessed by index via the
+ * {@link #get(int)} and {@link #put(int, byte)} methods.
+ * </p>
+ * <p>
+ * This interface differs from ByteBuffer:
+ * <li>On-heap bytes only</li>
+ * <li>Raw {@code byte} access only; does not encode other primitives.</li>
+ * <li>Implements {@code equals(Object)}, {@code #hashCode()}, and
+ * {@code #compareTo(ByteRange)} so that it can be used in standard java
+ * Collections. Comparison operations are lexicographic, which is native to
+ * HBase.</li>
+ * <li>Allows the addition of simple core methods like the deep and shallow
+ * copy methods.</li>
+ * <li>Can be reused in tight loops like a major compaction which can save
+ * significant amounts of garbage. (Without reuse, we throw off garbage like
+ * <a href="http://www.youtube.com/watch?v=lkmBH-MjZF4">this thing</a>.)</li>
+ * </p>
+ * <p>
+ * Mutable, and always evaluates {@code #equals(Object)}, {@code #hashCode()},
+ * and {@code #compareTo(ByteRange)} based on the current contents.
+ * </p>
+ * <p>
+ * Can contain convenience methods for comparing, printing, cloning, spawning
+ * new arrays, copying to other arrays, etc. Please place non-core methods into
+ * {@link ByteRangeUtils}.
+ * </p>
*/
-public class ByteRange implements Comparable<ByteRange> {
-
- private static final int UNSET_HASH_VALUE = -1;
-
-
- /********************** fields *****************************/
-
- // Do not make these final, as the intention is to reuse objects of this class
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
+public interface ByteRange extends Comparable<ByteRange> {
/**
- * The array containing the bytes in this range. It will be >= length.
+ * The underlying byte[].
*/
- private byte[] bytes;
+ public byte[] getBytes();
/**
- * The index of the first byte in this range. ByteRange.get(0) will return bytes[offset].
+ * Nullifies this ByteRange. That is, it becomes a husk, being a range over
+ * no byte[] whatsoever.
+ * @return this
*/
- private int offset;
+ public ByteRange unset();
/**
- * The number of bytes in the range. Offset + length must be <= bytes.length
+ * Reuse this {@code ByteRange} over a new byte[]. {@code offset} is set to
+ * 0 and {@code length} is set to {@code capacity}.
+ * @param capacity the size of a new byte[].
+ * @return this
*/
- private int length;
+ public ByteRange set(int capacity);
/**
- * Variable for lazy-caching the hashCode of this range. Useful for frequently used ranges,
- * long-lived ranges, or long ranges.
+ * Reuse this {@code ByteRange} over a new byte[]. {@code offset} is set to
+ * 0 and {@code length} is set to {@code bytes.length}. A null {@code bytes}
+ * IS supported, in which case this method will behave equivalently to
+ * {@link #unset()}.
+ * @param bytes the array to wrap.
+ * @return this
*/
- private int hash = UNSET_HASH_VALUE;
-
+ public ByteRange set(byte[] bytes);
- /********************** construct ***********************/
-
- public ByteRange() {
- set(new byte[0]);//Could probably get away with a null array if the need arises.
- }
+ /**
+ * Reuse this {@code ByteRange} over a new byte[]. A null {@code bytes} IS
+ * supported, in which case this method will behave equivalently to
+ * {@link #unset()}, regardless of the values of {@code offset} and
+ * {@code length}.
+ * @param bytes The array to wrap.
+ * @param offset The offset into {@code bytes} considered the beginning of
+ * this range.
+ * @param length The length of this range.
+ * @return this.
+ */
+ public ByteRange set(byte[] bytes, int offset, int length);
- public ByteRange(byte[] bytes) {
- set(bytes);
- }
+ /**
+ * The offset, the index into the underlying byte[] at which this range
+ * begins.
+ * @see #getBytes()
+ */
+ public int getOffset();
- public ByteRange(byte[] bytes, int offset, int length) {
- set(bytes, offset, length);
- }
+ /**
+ * Update the beginning of this range. {@code offset + length} may not be
+ * greater than {@code bytes.length}.
+ * @param offset the new start of this range.
+ * @return this.
+ */
+ public ByteRange setOffset(int offset);
+ /**
+ * The length of the range.
+ */
+ public int getLength();
- /********************** write methods *************************/
+ /**
+ * Update the length of this range. {@code offset + length} should not be
+ * greater than {@code bytes.length}.
+ * @param length The new length of this range.
+ * @return this.
+ */
+ public ByteRange setLength(int length);
- public ByteRange clear() {
- clearHashCache();
- bytes = null;
- offset = 0;
- length = 0;
- return this;
- }
+ /**
+ * @return true when this range is of zero length, false otherwise.
+ */
+ public boolean isEmpty();
- public ByteRange set(byte[] bytes) {
- clearHashCache();
- this.bytes = bytes;
- this.offset = 0;
- this.length = ArrayUtils.length(bytes);
- return this;
- }
+ /**
+ * Retrieve the byte at {@code index}.
+ * @param index zero-based index into this range.
+ * @return single byte at index.
+ */
+ public byte get(int index);
- public ByteRange set(byte[] bytes, int offset, int length) {
- clearHashCache();
- this.bytes = bytes;
- this.offset = offset;
- this.length = length;
- return this;
- }
+ /**
+ * Fill {@code dst} with bytes from the range, starting from {@code index}.
+ * @param index zero-based index into this range.
+ * @param dst the destination of the copy.
+ * @return this.
+ */
+ public ByteRange get(int index, byte[] dst);
- public void setLength(int length) {
- clearHashCache();
- this.length = length;
- }
+ /**
+ * Fill {@code dst} with bytes from the range, starting from {@code index}.
+ * {@code length} bytes are copied into {@code dst}, starting at {@code offset}.
+ * @param index zero-based index into this range.
+ * @param dst the destination of the copy.
+ * @param offset the offset into {@code dst} to start the copy.
+ * @param length the number of bytes to copy into {@code dst}.
+ * @return this.
+ */
+ public ByteRange get(int index, byte[] dst, int offset, int length);
+ /**
+ * Store {@code val} at {@code index}.
+ * @param index the index in the range where {@code val} is stored.
+ * @param val the value to store.
+ * @return this.
+ */
+ public ByteRange put(int index, byte val);
- /*********** read methods (add non-core methods to ByteRangeUtils) *************/
+ /**
+ * Store {@code val} at {@code index}.
+ * @param index the index in the range where {@code val} is stored.
+ * @param val the value to store.
+ * @return this.
+ */
+ public ByteRange put(int index, byte[] val);
/**
- * @param index zero-based index
- * @return single byte at index
+ * Store {@code length} bytes from {@code val} into this range, starting at
+ * {@code index}. Bytes from {@code val} are copied starting at {@code offset}
+ * into the range.
+ * @param index position in this range to start the copy.
+ * @param val the value to store.
+ * @param offset the offset in {@code val} from which to start copying.
+ * @param length the number of bytes to copy from {@code val}.
+ * @return this.
*/
- public byte get(int index) {
- return bytes[offset + index];
- }
+ public ByteRange put(int index, byte[] val, int offset, int length);
/**
- * Instantiate a new byte[] with exact length, which is at least 24 bytes + length. Copy the
- * contents of this range into it.
+ * Instantiate a new byte[] with exact length, which is at least 24 bytes +
+ * length. Copy the contents of this range into it.
* @return The newly cloned byte[].
*/
- public byte[] deepCopyToNewArray() {
- byte[] result = new byte[length];
- System.arraycopy(bytes, offset, result, 0, length);
- return result;
- }
+ public byte[] deepCopyToNewArray();
/**
- * Create a new ByteRange with new backing byte[] and copy the state of this range into the new
- * range. Copy the hash over if it is already calculated.
+ * Create a new {@code ByteRange} with new backing byte[] containing a copy
+ * of the content from {@code this} range's window.
* @return Deep copy
*/
- public ByteRange deepCopy() {
- ByteRange clone = new ByteRange(deepCopyToNewArray());
- if (isHashCached()) {
- clone.hash = hash;
- }
- return clone;
- }
+ public ByteRange deepCopy();
/**
- * Wrapper for System.arraycopy. Copy the contents of this range into the provided array.
+ * Wrapper for System.arraycopy. Copy the contents of this range into the
+ * provided array.
* @param destination Copy to this array
* @param destinationOffset First index in the destination array.
*/
- public void deepCopyTo(byte[] destination, int destinationOffset) {
- System.arraycopy(bytes, offset, destination, destinationOffset, length);
- }
+ public void deepCopyTo(byte[] destination, int destinationOffset);
/**
- * Wrapper for System.arraycopy. Copy the contents of this range into the provided array.
- * @param innerOffset Start copying from this index in this source ByteRange. First byte copied is
- * bytes[offset + innerOffset]
+ * Wrapper for System.arraycopy. Copy the contents of this range into the
+ * provided array.
+ * @param innerOffset Start copying from this index in this source
+ * ByteRange. First byte copied is bytes[offset + innerOffset]
* @param copyLength Copy this many bytes
* @param destination Copy to this array
* @param destinationOffset First index in the destination array.
*/
public void deepCopySubRangeTo(int innerOffset, int copyLength, byte[] destination,
- int destinationOffset) {
- System.arraycopy(bytes, offset + innerOffset, destination, destinationOffset, copyLength);
- }
+ int destinationOffset);
/**
- * Create a new ByteRange that points at this range's byte[]. The new range can have different
- * values for offset and length, but modifying the shallowCopy will modify the bytes in this
- * range's array. Pass over the hash code if it is already cached.
+ * Create a new {@code ByteRange} that points at this range's byte[].
+ * Modifying the shallowCopy will modify the bytes in this range's array.
+ * Pass over the hash code if it is already cached.
+ * @return new {@code ByteRange} object referencing this range's byte[].
+ */
+ public ByteRange shallowCopy();
+
+ /**
+ * Create a new {@code ByteRange} that points at this range's byte[]. The new
+ * range can have different values for offset and length, but modifying the
+ * shallowCopy will modify the bytes in this range's array. Pass over the
+ * hash code if it is already cached.
* @param innerOffset First byte of clone will be this.offset + copyOffset.
* @param copyLength Number of bytes in the clone.
- * @return new ByteRange object referencing this range's byte[].
+ * @return new {@code ByteRange} object referencing this range's byte[].
*/
- public ByteRange shallowCopySubRange(int innerOffset, int copyLength) {
- ByteRange clone = new ByteRange(bytes, offset + innerOffset, copyLength);
- if (isHashCached()) {
- clone.hash = hash;
- }
- return clone;
- }
-
- //TODO move to ByteRangeUtils because it is non-core method
- public int numEqualPrefixBytes(ByteRange that, int thatInnerOffset) {
- int maxCompares = Math.min(length, that.length - thatInnerOffset);
- for (int i = 0; i < maxCompares; ++i) {
- if (bytes[offset + i] != that.bytes[that.offset + thatInnerOffset + i]) {
- return i;
- }
- }
- return maxCompares;
- }
-
- public byte[] getBytes() {
- return bytes;
- }
-
- public int getOffset() {
- return offset;
- }
-
- public int getLength() {
- return length;
- }
-
- public boolean isEmpty(){
- return isEmpty(this);
- }
-
- public boolean notEmpty(){
- return notEmpty(this);
- }
-
-
- /******************* static methods ************************/
-
- public static boolean isEmpty(ByteRange range){
- return range == null || range.length == 0;
- }
-
- public static boolean notEmpty(ByteRange range){
- return range != null && range.length > 0;
- }
-
- /******************* standard methods *********************/
-
- @Override
- public boolean equals(Object thatObject) {
- if (thatObject == null){
- return false;
- }
- if (this == thatObject) {
- return true;
- }
- if (hashCode() != thatObject.hashCode()) {
- return false;
- }
- if (!(thatObject instanceof ByteRange)) {
- return false;
- }
- ByteRange that = (ByteRange) thatObject;
- return Bytes.equals(bytes, offset, length, that.bytes, that.offset, that.length);
- }
-
- @Override
- public int hashCode() {
- if (isHashCached()) {// hash is already calculated and cached
- return hash;
- }
- if (this.isEmpty()) {// return 0 for empty ByteRange
- hash = 0;
- return hash;
- }
- int off = offset;
- hash = 0;
- for (int i = 0; i < length; i++) {
- hash = 31 * hash + bytes[off++];
- }
- return hash;
- }
-
- private boolean isHashCached() {
- return hash != UNSET_HASH_VALUE;
- }
-
- private void clearHashCache() {
- hash = UNSET_HASH_VALUE;
- }
-
- /**
- * Bitwise comparison of each byte in the array. Unsigned comparison, not paying attention to
- * java's signed bytes.
- */
- @Override
- public int compareTo(ByteRange other) {
- return Bytes.compareTo(bytes, offset, length, other.bytes, other.offset, other.length);
- }
-
- @Override
- public String toString() {
- return Bytes.toStringBinary(bytes, offset, length);
- }
-
-}
+ public ByteRange shallowCopySubRange(int innerOffset, int copyLength);
+}
\ No newline at end of file
Modified: hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/row/RowNodeReader.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/row/RowNodeReader.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/row/RowNodeReader.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/decode/row/RowNodeReader.java Sun Aug 11 13:27:04 2013
@@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.codec.pr
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta;
-import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.vint.UFIntTool;
import org.apache.hadoop.hbase.util.vint.UVIntTool;
@@ -202,7 +202,7 @@ public class RowNodeReader {
public byte[] getToken() {
// TODO pass in reusable ByteRange
- return new ByteRange(block, tokenOffset, tokenLength).deepCopyToNewArray();
+ return new SimpleByteRange(block, tokenOffset, tokenLength).deepCopyToNewArray();
}
public int getOffset() {
Modified: hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/PrefixTreeEncoder.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/PrefixTreeEncoder.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/PrefixTreeEncoder.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/PrefixTreeEncoder.java Sun Aug 11 13:27:04 2013
@@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.codec.pre
import org.apache.hadoop.hbase.io.CellOutputStream;
import org.apache.hadoop.hbase.util.ArrayUtils;
import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.byterange.ByteRangeSet;
import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeHashSet;
import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeTreeSet;
@@ -146,9 +147,9 @@ public class PrefixTreeEncoder implement
public PrefixTreeEncoder(OutputStream outputStream, boolean includeMvccVersion) {
// used during cell accumulation
this.blockMeta = new PrefixTreeBlockMeta();
- this.rowRange = new ByteRange();
- this.familyRange = new ByteRange();
- this.qualifierRange = new ByteRange();
+ this.rowRange = new SimpleByteRange();
+ this.familyRange = new SimpleByteRange();
+ this.qualifierRange = new SimpleByteRange();
this.timestamps = new long[INITIAL_PER_CELL_ARRAY_SIZES];
this.mvccVersions = new long[INITIAL_PER_CELL_ARRAY_SIZES];
this.typeBytes = new byte[INITIAL_PER_CELL_ARRAY_SIZES];
@@ -488,7 +489,7 @@ public class PrefixTreeEncoder implement
}
public ByteRange getValueByteRange() {
- return new ByteRange(values, 0, totalValueBytes);
+ return new SimpleByteRange(values, 0, totalValueBytes);
}
}
Modified: hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/row/RowNodeWriter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/row/RowNodeWriter.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/row/RowNodeWriter.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/row/RowNodeWriter.java Sun Aug 11 13:27:04 2013
@@ -28,7 +28,7 @@ import org.apache.hadoop.classification.
import org.apache.hadoop.hbase.codec.prefixtree.PrefixTreeBlockMeta;
import org.apache.hadoop.hbase.codec.prefixtree.encode.PrefixTreeEncoder;
import org.apache.hadoop.hbase.codec.prefixtree.encode.tokenize.TokenizerNode;
-import org.apache.hadoop.hbase.util.ByteRangeTool;
+import org.apache.hadoop.hbase.util.ByteRangeUtils;
import org.apache.hadoop.hbase.util.CollectionUtils;
import org.apache.hadoop.hbase.util.vint.UFIntTool;
import org.apache.hadoop.hbase.util.vint.UVIntTool;
@@ -155,7 +155,7 @@ public class RowNodeWriter{
protected void writeRowToken(OutputStream os) throws IOException {
UVIntTool.writeBytes(tokenWidth, os);
int tokenStartIndex = tokenizerNode.isRoot() ? 0 : 1;
- ByteRangeTool.write(os, tokenizerNode.getToken(), tokenStartIndex);
+ ByteRangeUtils.write(os, tokenizerNode.getToken(), tokenStartIndex);
}
/**
Modified: hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/tokenize/TokenizerNode.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/tokenize/TokenizerNode.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/tokenize/TokenizerNode.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/encode/tokenize/TokenizerNode.java Sun Aug 11 13:27:04 2013
@@ -23,8 +23,10 @@ import java.util.List;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.ByteRangeUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.CollectionUtils;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.Strings;
import com.google.common.collect.Lists;
@@ -135,7 +137,7 @@ public class TokenizerNode{
public TokenizerNode(Tokenizer builder, TokenizerNode parent, int nodeDepth,
int tokenStartOffset, int tokenOffset, int tokenLength) {
- this.token = new ByteRange();
+ this.token = new SimpleByteRange();
reconstruct(builder, parent, nodeDepth, tokenStartOffset, tokenOffset, tokenLength);
this.children = Lists.newArrayList();
}
@@ -164,7 +166,7 @@ public class TokenizerNode{
parent = null;
nodeDepth = 0;
tokenStartOffset = 0;
- token.clear();
+ token.unset();
numOccurrences = 0;
children.clear();// branches & nubs
@@ -298,7 +300,7 @@ public class TokenizerNode{
}
protected int numIdenticalBytes(ByteRange bytes) {
- return token.numEqualPrefixBytes(bytes, tokenStartOffset);
+ return ByteRangeUtils.numEqualPrefixBytes(token, bytes, tokenStartOffset);
}
Modified: hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/ByteRangeSet.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/ByteRangeSet.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/ByteRangeSet.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/ByteRangeSet.java Sun Aug 11 13:27:04 2013
@@ -26,6 +26,7 @@ import org.apache.hadoop.classification.
import org.apache.hadoop.hbase.util.ArrayUtils;
import org.apache.hadoop.hbase.util.ByteRange;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import com.google.common.collect.Lists;
@@ -105,7 +106,7 @@ public abstract class ByteRangeSet {
protected int store(ByteRange bytes) {
int indexOfNewElement = numUniqueRanges;
if (uniqueRanges.size() <= numUniqueRanges) {
- uniqueRanges.add(new ByteRange());
+ uniqueRanges.add(new SimpleByteRange());
}
ByteRange storedRange = uniqueRanges.get(numUniqueRanges);
int neededBytes = numBytes + bytes.getLength();
Modified: hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/impl/ByteRangeTreeSet.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/impl/ByteRangeTreeSet.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/impl/ByteRangeTreeSet.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/util/byterange/impl/ByteRangeTreeSet.java Sun Aug 11 13:27:04 2013
@@ -36,7 +36,7 @@ public class ByteRangeTreeSet extends By
/************************ constructors *****************************/
public ByteRangeTreeSet() {
- this.uniqueIndexByUniqueRange = new TreeMap<ByteRange,Integer>();
+ this.uniqueIndexByUniqueRange = new TreeMap<ByteRange, Integer>();
}
public ByteRangeTreeSet(List<ByteRange> rawByteArrays) {
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTokenizer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTokenizer.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTokenizer.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTokenizer.java Sun Aug 11 13:27:04 2013
@@ -24,7 +24,7 @@ import java.util.List;
import org.apache.hadoop.hbase.codec.prefixtree.encode.tokenize.Tokenizer;
import org.apache.hadoop.hbase.codec.prefixtree.encode.tokenize.TokenizerNode;
import org.apache.hadoop.hbase.codec.prefixtree.encode.tokenize.TokenizerRowSearchResult;
-import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Assert;
import org.junit.Test;
@@ -48,7 +48,7 @@ public class TestTokenizer {
this.inputs = sortedByteArrays.getInputs();
this.builder = new Tokenizer();
for (byte[] array : inputs) {
- builder.addSorted(new ByteRange(array));
+ builder.addSorted(new SimpleByteRange(array));
}
this.roundTripped = builder.getArrays();
}
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTreeDepth.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTreeDepth.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTreeDepth.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/builder/TestTreeDepth.java Sun Aug 11 13:27:04 2013
@@ -21,7 +21,7 @@ package org.apache.hadoop.hbase.codec.pr
import java.util.List;
import org.apache.hadoop.hbase.codec.prefixtree.encode.tokenize.Tokenizer;
-import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Assert;
import org.junit.Test;
@@ -75,7 +75,7 @@ public class TestTreeDepth {
protected void testInternal(List<String> inputs, int expectedTreeDepth) {
Tokenizer builder = new Tokenizer();
for (String s : inputs) {
- ByteRange b = new ByteRange(Bytes.toBytes(s));
+ SimpleByteRange b = new SimpleByteRange(Bytes.toBytes(s));
builder.addSorted(b);
}
Assert.assertEquals(1, builder.getRoot().getNodeDepth());
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/TestColumnBuilder.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/TestColumnBuilder.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/TestColumnBuilder.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/TestColumnBuilder.java Sun Aug 11 13:27:04 2013
@@ -29,7 +29,7 @@ import org.apache.hadoop.hbase.codec.pre
import org.apache.hadoop.hbase.codec.prefixtree.encode.tokenize.Tokenizer;
import org.apache.hadoop.hbase.codec.prefixtree.encode.tokenize.TokenizerNode;
import org.apache.hadoop.hbase.util.ByteRange;
-import org.apache.hadoop.hbase.util.ByteRangeTool;
+import org.apache.hadoop.hbase.util.ByteRangeUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeTreeSet;
import org.junit.Assert;
@@ -67,7 +67,7 @@ public class TestColumnBuilder {
List<ByteRange> inputs = columns.getInputs();
this.columnSorter = new ByteRangeTreeSet(inputs);
this.sortedUniqueColumns = columnSorter.compile().getSortedRanges();
- List<byte[]> copies = ByteRangeTool.copyToNewArrays(sortedUniqueColumns);
+ List<byte[]> copies = ByteRangeUtils.copyToNewArrays(sortedUniqueColumns);
Assert.assertTrue(Bytes.isSorted(copies));
this.blockMeta = new PrefixTreeBlockMeta();
this.blockMeta.setNumMetaBytes(0);
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataRandom.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataRandom.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataRandom.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataRandom.java Sun Aug 11 13:27:04 2013
@@ -23,6 +23,7 @@ import java.util.List;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.codec.prefixtree.column.TestColumnData;
import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.byterange.ByteRangeSet;
import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeTreeSet;
import org.apache.hadoop.hbase.util.test.RedundantKVGenerator;
@@ -39,7 +40,7 @@ public class TestColumnDataRandom implem
ByteRangeSet sortedColumns = new ByteRangeTreeSet();
List<KeyValue> d = generator.generateTestKeyValues(numColumns);
for (KeyValue col : d) {
- ByteRange colRange = new ByteRange(col.getQualifier());
+ ByteRange colRange = new SimpleByteRange(col.getQualifier());
inputs.add(colRange);
sortedColumns.add(colRange);
}
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataSimple.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataSimple.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataSimple.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/column/data/TestColumnDataSimple.java Sun Aug 11 13:27:04 2013
@@ -22,7 +22,7 @@ import java.util.List;
import org.apache.hadoop.hbase.codec.prefixtree.column.TestColumnData;
import org.apache.hadoop.hbase.util.ByteRange;
-import org.apache.hadoop.hbase.util.ByteRangeTool;
+import org.apache.hadoop.hbase.util.ByteRangeUtils;
import org.apache.hadoop.hbase.util.Bytes;
import com.google.common.collect.Lists;
@@ -37,7 +37,7 @@ public class TestColumnDataSimple implem
d.add("abc");
d.add("bbc");
d.add("abc");
- return ByteRangeTool.fromArrays(Bytes.getUtf8ByteArrays(d));
+ return ByteRangeUtils.fromArrays(Bytes.getUtf8ByteArrays(d));
}
@Override
@@ -46,7 +46,7 @@ public class TestColumnDataSimple implem
d.add("abc");
d.add("abcde");
d.add("bbc");
- return ByteRangeTool.fromArrays(Bytes.getUtf8ByteArrays(d));
+ return ByteRangeUtils.fromArrays(Bytes.getUtf8ByteArrays(d));
}
}
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataExerciseFInts.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataExerciseFInts.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataExerciseFInts.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataExerciseFInts.java Sun Aug 11 13:27:04 2013
@@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.codec.pre
import org.apache.hadoop.hbase.codec.prefixtree.row.BaseTestRowData;
import org.apache.hadoop.hbase.util.ByteRange;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeTreeSet;
import org.junit.Assert;
@@ -40,7 +41,7 @@ import com.google.common.collect.Lists;
*/
public class TestRowDataExerciseFInts extends BaseTestRowData{
- static List<ByteRange> rows;
+ static List<ByteRange> rows;
static{
List<String> rowStrings = new ArrayList<String>();
rowStrings.add("com.edsBlog/directoryAa/pageAaa");
@@ -61,7 +62,7 @@ public class TestRowDataExerciseFInts ex
rowStrings.add("com.isabellasBlog/directoryBb/pageHhh");
ByteRangeTreeSet ba = new ByteRangeTreeSet();
for(String row : rowStrings){
- ba.add(new ByteRange(Bytes.toBytes(row)));
+ ba.add(new SimpleByteRange(Bytes.toBytes(row)));
}
rows = ba.compile().getSortedRanges();
}
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataUrls.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataUrls.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataUrls.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/codec/prefixtree/row/data/TestRowDataUrls.java Sun Aug 11 13:27:04 2013
@@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.codec.pre
import org.apache.hadoop.hbase.codec.prefixtree.row.BaseTestRowData;
import org.apache.hadoop.hbase.util.ByteRange;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.apache.hadoop.hbase.util.byterange.impl.ByteRangeTreeSet;
import com.google.common.collect.Lists;
@@ -38,7 +39,7 @@ import com.google.common.collect.Lists;
*/
public class TestRowDataUrls extends BaseTestRowData{
- static List<ByteRange> rows;
+ static List<ByteRange> rows;
static{
List<String> rowStrings = new ArrayList<String>();
rowStrings.add("com.edsBlog/directoryAa/pageAaa");
@@ -59,7 +60,7 @@ public class TestRowDataUrls extends Bas
rowStrings.add("com.isabellasBlog/directoryBb/pageHhh");
ByteRangeTreeSet ba = new ByteRangeTreeSet();
for (String row : rowStrings) {
- ba.add(new ByteRange(Bytes.toBytes(row)));
+ ba.add(new SimpleByteRange(Bytes.toBytes(row)));
}
rows = ba.compile().getSortedRanges();
}
Modified: hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/util/bytes/TestByteRange.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/util/bytes/TestByteRange.java?rev=1512919&r1=1512918&r2=1512919&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/util/bytes/TestByteRange.java (original)
+++ hbase/branches/0.95/hbase-prefix-tree/src/test/java/org/apache/hadoop/hbase/util/bytes/TestByteRange.java Sun Aug 11 13:27:04 2013
@@ -21,13 +21,14 @@ package org.apache.hadoop.hbase.util.byt
import junit.framework.Assert;
import org.apache.hadoop.hbase.util.ByteRange;
+import org.apache.hadoop.hbase.util.SimpleByteRange;
import org.junit.Test;
public class TestByteRange {
@Test
public void testConstructor() {
- ByteRange b = new ByteRange(new byte[] { 0, 1, 2 });
+ ByteRange b = new SimpleByteRange(new byte[] { 0, 1, 2 });
Assert.assertEquals(3, b.getLength());
}