tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject tez git commit: TEZ-3937. Empty partition BitSet to byte[] conversion creates one extra byte in rounding error (Jonathan Eagles via jlowe)
Date Mon, 21 May 2018 14:35:38 GMT
Repository: tez
Updated Branches:
  refs/heads/branch-0.9 7b145c827 -> b1fbcebbe


TEZ-3937. Empty partition BitSet to byte[] conversion creates one extra byte in rounding error
(Jonathan Eagles via jlowe)

(cherry picked from commit fd9c015750c320a9a70b917cf22f993cf144e89e)


Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/b1fbcebb
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/b1fbcebb
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/b1fbcebb

Branch: refs/heads/branch-0.9
Commit: b1fbcebbea9ac331fe79492d5b1542fa6b66f468
Parents: 7b145c8
Author: Jason Lowe <jlowe@apache.org>
Authored: Mon May 21 09:32:08 2018 -0500
Committer: Jason Lowe <jlowe@apache.org>
Committed: Mon May 21 09:33:49 2018 -0500

----------------------------------------------------------------------
 .../src/main/java/org/apache/tez/common/TezUtilsInternal.java    | 2 +-
 tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/b1fbcebb/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
----------------------------------------------------------------------
diff --git a/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java b/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
index 5ba2972..5d7aea3 100644
--- a/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
+++ b/tez-common/src/main/java/org/apache/tez/common/TezUtilsInternal.java
@@ -238,7 +238,7 @@ public class TezUtilsInternal {
     if (bits == null) {
       return null;
     }
-    byte[] bytes = new byte[bits.length() / 8 + 1];
+    byte[] bytes = new byte[(bits.length() + 7) / 8];
     for (int i = 0; i < bits.length(); i++) {
       if (bits.get(i)) {
         bytes[(bytes.length) - (i / 8) - 1] |= 1 << (i % 8);

http://git-wip-us.apache.org/repos/asf/tez/blob/b1fbcebb/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
----------------------------------------------------------------------
diff --git a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
index 16efc8f..04eb2c0 100644
--- a/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
+++ b/tez-common/src/test/java/org/apache/tez/common/TestTezUtils.java
@@ -81,11 +81,11 @@ public class TestTezUtils {
   public void testBitSetToByteArray() {
     BitSet bitSet = createBitSet(0);
     byte[] bytes = TezUtilsInternal.toByteArray(bitSet);
-    Assert.assertTrue(bytes.length == ((bitSet.length() / 8) + 1));
+    Assert.assertEquals(bytes.length, (bitSet.length() + 7) / 8);
 
     bitSet = createBitSet(1000);
     bytes = TezUtilsInternal.toByteArray(bitSet);
-    Assert.assertTrue(bytes.length == ((bitSet.length() / 8) + 1));
+    Assert.assertEquals(bytes.length, (bitSet.length() + 7) / 8);
   }
 
   @Test (timeout=2000)


Mime
View raw message