You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ja...@apache.org on 2019/08/05 09:12:37 UTC
[hbase] branch master updated: HBASE-22788 Removed deprecated
methods from Bytes
This is an automated email from the ASF dual-hosted git repository.
janh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 32434d1 HBASE-22788 Removed deprecated methods from Bytes
32434d1 is described below
commit 32434d12002502149df9df2876791c88aca4adb0
Author: Jan Hentschel <ja...@ultratendency.com>
AuthorDate: Mon Aug 5 11:12:30 2019 +0200
HBASE-22788 Removed deprecated methods from Bytes
Signed-off-by: stack <st...@apache.org>
---
.../java/org/apache/hadoop/hbase/util/Bytes.java | 198 +--------------------
1 file changed, 2 insertions(+), 196 deletions(-)
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
index 06a1df7..6ecfa10 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
@@ -40,7 +40,6 @@ import java.util.List;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
-import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.io.RawComparator;
import org.apache.hadoop.io.WritableComparator;
import org.apache.hadoop.io.WritableUtils;
@@ -48,13 +47,11 @@ import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import sun.misc.Unsafe;
+
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils;
-import com.google.protobuf.ByteString;
-
-import sun.misc.Unsafe;
-
/**
* Utility class that handles byte arrays, conversions to/from other types,
* comparisons, hash code generation, manufacturing keys for HashMaps or
@@ -185,16 +182,6 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Copy bytes from ByteString instance.
- * @param byteString copy from
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public Bytes(final ByteString byteString) {
- this(byteString.toByteArray());
- }
-
- /**
* Get the data from the Bytes.
* @return The data is only valid between offset and offset+length.
*/
@@ -226,21 +213,6 @@ public class Bytes implements Comparable<Bytes> {
/**
* @return the number of valid bytes in the buffer
- * @deprecated since 2.0.0 and will be removed in 3.0.0. Use {@link #getLength()} instead.
- * @see #getLength()
- * @see <a href="https://issues.apache.org/jira/browse/HBASE-11862">HBASE-11862</a>
- */
- @Deprecated
- public int getSize() {
- if (this.bytes == null) {
- throw new IllegalStateException("Uninitialiized. Null constructor " +
- "called w/o accompaying readFields invocation");
- }
- return this.length;
- }
-
- /**
- * @return the number of valid bytes in the buffer
*/
public int getLength() {
if (this.bytes == null) {
@@ -257,14 +229,6 @@ public class Bytes implements Comparable<Bytes> {
return this.offset;
}
- /**
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public ByteString toByteString() {
- return ByteString.copyFrom(this.bytes, this.offset, this.length);
- }
-
@Override
public int hashCode() {
return Bytes.hashCode(bytes, offset, length);
@@ -850,19 +814,6 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Put a long value out to the specified byte array position (Unsafe).
- * @param bytes the byte array
- * @param offset position in the array
- * @param val long to write out
- * @return incremented offset
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public static int putLongUnsafe(byte[] bytes, int offset, long val) {
- return UnsafeAccess.putLong(bytes, offset, val);
- }
-
- /**
* Presumes float encoded as IEEE 754 floating-point "single format"
* @param bytes byte array
* @return Float made from passed byte array.
@@ -992,42 +943,6 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Converts a byte array to an int value (Unsafe version)
- * @param bytes byte array
- * @param offset offset into array
- * @return the int value
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public static int toIntUnsafe(byte[] bytes, int offset) {
- return UnsafeAccess.toInt(bytes, offset);
- }
-
- /**
- * Converts a byte array to an short value (Unsafe version)
- * @param bytes byte array
- * @param offset offset into array
- * @return the short value
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public static short toShortUnsafe(byte[] bytes, int offset) {
- return UnsafeAccess.toShort(bytes, offset);
- }
-
- /**
- * Converts a byte array to an long value (Unsafe version)
- * @param bytes byte array
- * @param offset offset into array
- * @return the long value
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public static long toLongUnsafe(byte[] bytes, int offset) {
- return UnsafeAccess.toLong(bytes, offset);
- }
-
- /**
* Converts a byte array to an int value
* @param bytes byte array
* @param offset offset into array
@@ -1067,19 +982,6 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Put an int value out to the specified byte array position (Unsafe).
- * @param bytes the byte array
- * @param offset position in the array
- * @param val int to write out
- * @return incremented offset
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public static int putIntUnsafe(byte[] bytes, int offset, int val) {
- return UnsafeAccess.putInt(bytes, offset, val);
- }
-
- /**
* Convert a short value to a byte array of {@link #SIZEOF_SHORT} bytes long.
* @param val value
* @return the byte array
@@ -1158,19 +1060,6 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Put a short value out to the specified byte array position (Unsafe).
- * @param bytes the byte array
- * @param offset position in the array
- * @param val short to write out
- * @return incremented offset
- * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
- */
- @Deprecated
- public static int putShortUnsafe(byte[] bytes, int offset, short val) {
- return UnsafeAccess.putShort(bytes, offset, val);
- }
-
- /**
* Put an int value as short out to the specified byte array position. Only the lower 2 bytes of
* the short will be put into the array. The caller of the API need to make sure they will not
* loose the value by doing so. This is useful to store an unsigned short which is represented as
@@ -1319,22 +1208,6 @@ public class Bytes implements Comparable<Bytes> {
* Reads a zero-compressed encoded long from input buffer and returns it.
* @param buffer Binary array
* @param offset Offset into array at which vint begins.
- * @throws java.io.IOException e
- * @return deserialized long from buffer.
- * @deprecated since 0.98.12. Use {@link #readAsVLong(byte[],int)} instead.
- * @see #readAsVLong(byte[], int)
- * @see <a href="https://issues.apache.org/jira/browse/HBASE-6919">HBASE-6919</a>
- */
- @Deprecated
- public static long readVLong(final byte [] buffer, final int offset)
- throws IOException {
- return readAsVLong(buffer, offset);
- }
-
- /**
- * Reads a zero-compressed encoded long from input buffer and returns it.
- * @param buffer Binary array
- * @param offset Offset into array at which vint begins.
* @return deserialized long from buffer.
*/
public static long readAsVLong(final byte [] buffer, final int offset) {
@@ -2093,31 +1966,6 @@ public class Bytes implements Comparable<Bytes> {
}
/**
- * Binary search for keys in indexes.
- *
- * @param arr array of byte arrays to search for
- * @param key the key you want to find
- * @param offset the offset in the key you want to find
- * @param length the length of the key
- * @param comparator a comparator to compare.
- * @return zero-based index of the key, if the key is present in the array.
- * Otherwise, a value -(i + 1) such that the key is between arr[i -
- * 1] and arr[i] non-inclusively, where i is in [0, i], if we define
- * arr[-1] = -Inf and arr[N] = Inf for an N-element array. The above
- * means that this function can return 2N + 1 different values
- * ranging from -(N + 1) to N - 1.
- * @deprecated since 2.0.0 and will be removed in 3.0.0. Use
- * {@link #binarySearch(byte[][], byte[], int, int)} instead.
- * @see #binarySearch(byte[][], byte[], int, int)
- * @see <a href="https://issues.apache.org/jira/browse/HBASE-13450">HBASE-13450</a>
- */
- @Deprecated
- public static int binarySearch(byte [][]arr, byte []key, int offset,
- int length, RawComparator<?> comparator) {
- return binarySearch(arr, key, offset, length);
- }
-
- /**
* Binary search for keys in indexes using Bytes.BYTES_RAWCOMPARATOR.
*
* @param arr array of byte arrays to search for
@@ -2167,48 +2015,6 @@ public class Bytes implements Comparable<Bytes> {
* means that this function can return 2N + 1 different values
* ranging from -(N + 1) to N - 1.
* @return the index of the block
- * @deprecated since 2.0.0 and will be removed in 3.0.0. Use
- * {@link #binarySearch(Cell[], Cell, CellComparator)} instead.
- * @see #binarySearch(Cell[], Cell, CellComparator)
- * @see <a href="https://issues.apache.org/jira/browse/HBASE-13450">HBASE-13450</a>
- */
- @Deprecated
- public static int binarySearch(byte[][] arr, Cell key, RawComparator<Cell> comparator) {
- int low = 0;
- int high = arr.length - 1;
- KeyValue.KeyOnlyKeyValue r = new KeyValue.KeyOnlyKeyValue();
- while (low <= high) {
- int mid = low + ((high - low) >> 1);
- // we have to compare in this order, because the comparator order
- // has special logic when the 'left side' is a special key.
- r.setKey(arr[mid], 0, arr[mid].length);
- int cmp = comparator.compare(key, r);
- // key lives above the midpoint
- if (cmp > 0)
- low = mid + 1;
- // key lives below the midpoint
- else if (cmp < 0)
- high = mid - 1;
- // BAM. how often does this really happen?
- else
- return mid;
- }
- return - (low+1);
- }
-
- /**
- * Binary search for keys in indexes.
- *
- * @param arr array of byte arrays to search for
- * @param key the key you want to find
- * @param comparator a comparator to compare.
- * @return zero-based index of the key, if the key is present in the array.
- * Otherwise, a value -(i + 1) such that the key is between arr[i -
- * 1] and arr[i] non-inclusively, where i is in [0, i], if we define
- * arr[-1] = -Inf and arr[N] = Inf for an N-element array. The above
- * means that this function can return 2N + 1 different values
- * ranging from -(N + 1) to N - 1.
- * @return the index of the block
*/
public static int binarySearch(Cell[] arr, Cell key, CellComparator comparator) {
int low = 0;