hbase git commit: HBASE-13496 Make Bytes::compareTo inlineable.
Repository: hbase Updated Branches: refs/heads/0.98 fa14b028b -> 80cf84838 HBASE-13496 Make Bytes::compareTo inlineable. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/80cf8483 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/80cf8483 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/80cf8483 Branch: refs/heads/0.98 Commit: 80cf84838d8f86391c16cb9910a4efdd141744e4 Parents: fa14b02 Author: anoopsjohn Authored: Thu Apr 23 10:36:08 2015 +0530 Committer: anoopsjohn Committed: Thu Apr 23 10:45:42 2015 +0530 -- .../org/apache/hadoop/hbase/util/Bytes.java | 45 1 file changed, 28 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/80cf8483/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java -- 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 1fa22fc..c373901 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 @@ -1326,24 +1326,45 @@ public class Bytes { /** * Returns true if x1 is less than x2, when both values are treated as * unsigned long. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedLong(long x1, long x2) { +if (littleEndian) { + x1 = Long.reverseBytes(x1); + x2 = Long.reverseBytes(x2); +} return (x1 + Long.MIN_VALUE) < (x2 + Long.MIN_VALUE); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned int. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedInt(int x1, int x2) { +if (littleEndian) { + x1 = Integer.reverseBytes(x1); + x2 = Integer.reverseBytes(x2); +} return (x1 & 0xL) < (x2 & 0xL); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned short. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedShort(short x1, short x2) { +if (littleEndian) { + x1 = Short.reverseBytes(x1); + x2 = Short.reverseBytes(x2); +} return (x1 & 0x) < (x2 & 0x); } @@ -1387,40 +1408,30 @@ public class Bytes { * time is no slower than comparing 4 bytes at a time even on 32-bit. * On the other hand, it is substantially faster on 64-bit. */ -for (int i = 0; i < minWords * SIZEOF_LONG; i += SIZEOF_LONG) { +// This is the end offset of long parts. +int j = minWords << 3; // Same as minWords * SIZEOF_LONG +for (int i = 0; i < j; i += SIZEOF_LONG) { long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i); long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i); long diff = lw ^ rw; - if(littleEndian){ -lw = Long.reverseBytes(lw); -rw = Long.reverseBytes(rw); - } if (diff != 0) { return lessThanUnsignedLong(lw, rw) ? -1 : 1; } } -int offset = minWords * SIZEOF_LONG; +int offset = j; if (minLength - offset >= SIZEOF_INT) { int il = theUnsafe.getInt(buffer1, offset1Adj + offset); int ir = theUnsafe.getInt(buffer2, offset2Adj + offset); - if(littleEndian){ -il = Integer.reverseBytes(il); -ir = Integer.reverseBytes(ir); - } - if(il != ir){ + if (il != ir) { return lessThanUnsignedInt(il, ir) ? -1: 1; } - offset += SIZEOF_INT; + offset += SIZEOF_INT; } if (minLength - offset >= SIZEOF_SHORT) { short sl = theUnsafe.getShort(buffer1, offset1Adj + offset); short sr = theUnsafe.getShort(buffer2, offset2Adj + offset); - if(littleEndian){ -sl = Short.reverseBytes(sl); -sr = Short.reverseBytes(sr); - } -
hbase git commit: HBASE-13496 Make Bytes::compareTo inlineable.
Repository: hbase Updated Branches: refs/heads/branch-1.0 0184a5c99 -> 3d285cbad HBASE-13496 Make Bytes::compareTo inlineable. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3d285cba Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3d285cba Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3d285cba Branch: refs/heads/branch-1.0 Commit: 3d285cbad80fd9a0e230867df2396d0061e223eb Parents: 0184a5c Author: anoopsjohn Authored: Thu Apr 23 10:36:08 2015 +0530 Committer: anoopsjohn Committed: Thu Apr 23 10:45:09 2015 +0530 -- .../org/apache/hadoop/hbase/util/Bytes.java | 45 1 file changed, 28 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/3d285cba/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java -- 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 dd666e6..05d5ad1 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 @@ -1315,24 +1315,45 @@ public class Bytes { /** * Returns true if x1 is less than x2, when both values are treated as * unsigned long. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedLong(long x1, long x2) { +if (littleEndian) { + x1 = Long.reverseBytes(x1); + x2 = Long.reverseBytes(x2); +} return (x1 + Long.MIN_VALUE) < (x2 + Long.MIN_VALUE); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned int. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedInt(int x1, int x2) { +if (littleEndian) { + x1 = Integer.reverseBytes(x1); + x2 = Integer.reverseBytes(x2); +} return (x1 & 0xL) < (x2 & 0xL); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned short. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedShort(short x1, short x2) { +if (littleEndian) { + x1 = Short.reverseBytes(x1); + x2 = Short.reverseBytes(x2); +} return (x1 & 0x) < (x2 & 0x); } @@ -1376,40 +1397,30 @@ public class Bytes { * time is no slower than comparing 4 bytes at a time even on 32-bit. * On the other hand, it is substantially faster on 64-bit. */ -for (int i = 0; i < minWords * SIZEOF_LONG; i += SIZEOF_LONG) { +// This is the end offset of long parts. +int j = minWords << 3; // Same as minWords * SIZEOF_LONG +for (int i = 0; i < j; i += SIZEOF_LONG) { long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i); long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i); long diff = lw ^ rw; - if(littleEndian){ -lw = Long.reverseBytes(lw); -rw = Long.reverseBytes(rw); - } if (diff != 0) { return lessThanUnsignedLong(lw, rw) ? -1 : 1; } } -int offset = minWords * SIZEOF_LONG; +int offset = j; if (minLength - offset >= SIZEOF_INT) { int il = theUnsafe.getInt(buffer1, offset1Adj + offset); int ir = theUnsafe.getInt(buffer2, offset2Adj + offset); - if(littleEndian){ -il = Integer.reverseBytes(il); -ir = Integer.reverseBytes(ir); - } - if(il != ir){ + if (il != ir) { return lessThanUnsignedInt(il, ir) ? -1: 1; } - offset += SIZEOF_INT; + offset += SIZEOF_INT; } if (minLength - offset >= SIZEOF_SHORT) { short sl = theUnsafe.getShort(buffer1, offset1Adj + offset); short sr = theUnsafe.getShort(buffer2, offset2Adj + offset); - if(littleEndian){ -sl = Short.reverseBytes(sl); -sr = Short.reverseBytes(sr); -
hbase git commit: HBASE-13496 Make Bytes::compareTo inlineable.
Repository: hbase Updated Branches: refs/heads/branch-1.1 92e689ddd -> 5511ce6d3 HBASE-13496 Make Bytes::compareTo inlineable. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5511ce6d Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5511ce6d Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5511ce6d Branch: refs/heads/branch-1.1 Commit: 5511ce6d3c54236022289e574af049692d210853 Parents: 92e689d Author: anoopsjohn Authored: Thu Apr 23 10:36:08 2015 +0530 Committer: anoopsjohn Committed: Thu Apr 23 10:44:29 2015 +0530 -- .../org/apache/hadoop/hbase/util/Bytes.java | 45 1 file changed, 28 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/5511ce6d/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java -- 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 a3ebc63..5695b94 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 @@ -1352,24 +1352,45 @@ public class Bytes { /** * Returns true if x1 is less than x2, when both values are treated as * unsigned long. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedLong(long x1, long x2) { +if (littleEndian) { + x1 = Long.reverseBytes(x1); + x2 = Long.reverseBytes(x2); +} return (x1 + Long.MIN_VALUE) < (x2 + Long.MIN_VALUE); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned int. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedInt(int x1, int x2) { +if (littleEndian) { + x1 = Integer.reverseBytes(x1); + x2 = Integer.reverseBytes(x2); +} return (x1 & 0xL) < (x2 & 0xL); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned short. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedShort(short x1, short x2) { +if (littleEndian) { + x1 = Short.reverseBytes(x1); + x2 = Short.reverseBytes(x2); +} return (x1 & 0x) < (x2 & 0x); } @@ -1413,40 +1434,30 @@ public class Bytes { * time is no slower than comparing 4 bytes at a time even on 32-bit. * On the other hand, it is substantially faster on 64-bit. */ -for (int i = 0; i < minWords * SIZEOF_LONG; i += SIZEOF_LONG) { +// This is the end offset of long parts. +int j = minWords << 3; // Same as minWords * SIZEOF_LONG +for (int i = 0; i < j; i += SIZEOF_LONG) { long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i); long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i); long diff = lw ^ rw; - if(littleEndian){ -lw = Long.reverseBytes(lw); -rw = Long.reverseBytes(rw); - } if (diff != 0) { return lessThanUnsignedLong(lw, rw) ? -1 : 1; } } -int offset = minWords * SIZEOF_LONG; +int offset = j; if (minLength - offset >= SIZEOF_INT) { int il = theUnsafe.getInt(buffer1, offset1Adj + offset); int ir = theUnsafe.getInt(buffer2, offset2Adj + offset); - if(littleEndian){ -il = Integer.reverseBytes(il); -ir = Integer.reverseBytes(ir); - } - if(il != ir){ + if (il != ir) { return lessThanUnsignedInt(il, ir) ? -1: 1; } - offset += SIZEOF_INT; + offset += SIZEOF_INT; } if (minLength - offset >= SIZEOF_SHORT) { short sl = theUnsafe.getShort(buffer1, offset1Adj + offset); short sr = theUnsafe.getShort(buffer2, offset2Adj + offset); - if(littleEndian){ -sl = Short.reverseBytes(sl); -sr = Short.reverseBytes(sr); -
hbase git commit: HBASE-13496 Make Bytes::compareTo inlineable.
Repository: hbase Updated Branches: refs/heads/branch-1 c8d8499da -> 4666bf86a HBASE-13496 Make Bytes::compareTo inlineable. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4666bf86 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4666bf86 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4666bf86 Branch: refs/heads/branch-1 Commit: 4666bf86a23f98d0989ec4e7b09fe729f654a65c Parents: c8d8499 Author: anoopsjohn Authored: Thu Apr 23 10:36:08 2015 +0530 Committer: anoopsjohn Committed: Thu Apr 23 10:40:56 2015 +0530 -- .../org/apache/hadoop/hbase/util/Bytes.java | 45 1 file changed, 28 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/4666bf86/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java -- 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 a3ebc63..5695b94 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 @@ -1352,24 +1352,45 @@ public class Bytes { /** * Returns true if x1 is less than x2, when both values are treated as * unsigned long. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedLong(long x1, long x2) { +if (littleEndian) { + x1 = Long.reverseBytes(x1); + x2 = Long.reverseBytes(x2); +} return (x1 + Long.MIN_VALUE) < (x2 + Long.MIN_VALUE); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned int. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedInt(int x1, int x2) { +if (littleEndian) { + x1 = Integer.reverseBytes(x1); + x2 = Integer.reverseBytes(x2); +} return (x1 & 0xL) < (x2 & 0xL); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned short. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedShort(short x1, short x2) { +if (littleEndian) { + x1 = Short.reverseBytes(x1); + x2 = Short.reverseBytes(x2); +} return (x1 & 0x) < (x2 & 0x); } @@ -1413,40 +1434,30 @@ public class Bytes { * time is no slower than comparing 4 bytes at a time even on 32-bit. * On the other hand, it is substantially faster on 64-bit. */ -for (int i = 0; i < minWords * SIZEOF_LONG; i += SIZEOF_LONG) { +// This is the end offset of long parts. +int j = minWords << 3; // Same as minWords * SIZEOF_LONG +for (int i = 0; i < j; i += SIZEOF_LONG) { long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i); long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i); long diff = lw ^ rw; - if(littleEndian){ -lw = Long.reverseBytes(lw); -rw = Long.reverseBytes(rw); - } if (diff != 0) { return lessThanUnsignedLong(lw, rw) ? -1 : 1; } } -int offset = minWords * SIZEOF_LONG; +int offset = j; if (minLength - offset >= SIZEOF_INT) { int il = theUnsafe.getInt(buffer1, offset1Adj + offset); int ir = theUnsafe.getInt(buffer2, offset2Adj + offset); - if(littleEndian){ -il = Integer.reverseBytes(il); -ir = Integer.reverseBytes(ir); - } - if(il != ir){ + if (il != ir) { return lessThanUnsignedInt(il, ir) ? -1: 1; } - offset += SIZEOF_INT; + offset += SIZEOF_INT; } if (minLength - offset >= SIZEOF_SHORT) { short sl = theUnsafe.getShort(buffer1, offset1Adj + offset); short sr = theUnsafe.getShort(buffer2, offset2Adj + offset); - if(littleEndian){ -sl = Short.reverseBytes(sl); -sr = Short.reverseBytes(sr); -
hbase git commit: HBASE-13496 Make Bytes::compareTo inlineable.
Repository: hbase Updated Branches: refs/heads/master 6c427175b -> a4202879a HBASE-13496 Make Bytes::compareTo inlineable. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a4202879 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a4202879 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a4202879 Branch: refs/heads/master Commit: a4202879ad12d797d8c05f3174b824e06cd74279 Parents: 6c42717 Author: anoopsjohn Authored: Thu Apr 23 10:36:08 2015 +0530 Committer: anoopsjohn Committed: Thu Apr 23 10:36:08 2015 +0530 -- .../org/apache/hadoop/hbase/util/Bytes.java | 45 1 file changed, 28 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/a4202879/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java -- 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 21b0a99..f294ec9 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 @@ -1542,24 +1542,45 @@ public class Bytes implements Comparable { /** * Returns true if x1 is less than x2, when both values are treated as * unsigned long. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedLong(long x1, long x2) { +if (littleEndian) { + x1 = Long.reverseBytes(x1); + x2 = Long.reverseBytes(x2); +} return (x1 + Long.MIN_VALUE) < (x2 + Long.MIN_VALUE); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned int. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedInt(int x1, int x2) { +if (littleEndian) { + x1 = Integer.reverseBytes(x1); + x2 = Integer.reverseBytes(x2); +} return (x1 & 0xL) < (x2 & 0xL); } /** * Returns true if x1 is less than x2, when both values are treated as * unsigned short. + * Both values are passed as is read by Unsafe. When platform is Little Endian, have to + * convert to corresponding Big Endian value and then do compare. We do all writes in + * Big Endian format. */ static boolean lessThanUnsignedShort(short x1, short x2) { +if (littleEndian) { + x1 = Short.reverseBytes(x1); + x2 = Short.reverseBytes(x2); +} return (x1 & 0x) < (x2 & 0x); } @@ -1603,40 +1624,30 @@ public class Bytes implements Comparable { * time is no slower than comparing 4 bytes at a time even on 32-bit. * On the other hand, it is substantially faster on 64-bit. */ -for (int i = 0; i < minWords * SIZEOF_LONG; i += SIZEOF_LONG) { +// This is the end offset of long parts. +int j = minWords << 3; // Same as minWords * SIZEOF_LONG +for (int i = 0; i < j; i += SIZEOF_LONG) { long lw = theUnsafe.getLong(buffer1, offset1Adj + (long) i); long rw = theUnsafe.getLong(buffer2, offset2Adj + (long) i); long diff = lw ^ rw; - if(littleEndian){ -lw = Long.reverseBytes(lw); -rw = Long.reverseBytes(rw); - } if (diff != 0) { return lessThanUnsignedLong(lw, rw) ? -1 : 1; } } -int offset = minWords * SIZEOF_LONG; +int offset = j; if (minLength - offset >= SIZEOF_INT) { int il = theUnsafe.getInt(buffer1, offset1Adj + offset); int ir = theUnsafe.getInt(buffer2, offset2Adj + offset); - if(littleEndian){ -il = Integer.reverseBytes(il); -ir = Integer.reverseBytes(ir); - } - if(il != ir){ + if (il != ir) { return lessThanUnsignedInt(il, ir) ? -1: 1; } - offset += SIZEOF_INT; + offset += SIZEOF_INT; } if (minLength - offset >= SIZEOF_SHORT) { short sl = theUnsafe.getShort(buffer1, offset1Adj + offset); short sr = theUnsafe.getShort(buffer2, offset2Adj + offset); - if(littleEndian){ -sl = Short.reverseBytes(sl); -