Repository: tez
Updated Branches:
  refs/heads/branch-0.7 14a89aed7 -> be57068d1


TEZ-3192. IFile#checkState creating unnecessary objects though auto-boxing 
(jeagles)

(cherry picked from commit 0c7e1c5bb252f2a2631457adad3ebf29c23425e2)


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

Branch: refs/heads/branch-0.7
Commit: be57068d125bbc48c9ed35ad01c179ee51f723d2
Parents: 14a89ae
Author: Jonathan Eagles <[email protected]>
Authored: Thu Mar 31 19:15:58 2016 -0500
Committer: Jonathan Eagles <[email protected]>
Committed: Thu Mar 31 19:21:14 2016 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../runtime/library/common/sort/impl/IFile.java | 23 ++++++++++----------
 2 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/be57068d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9e09532..15a2ce5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,7 @@ INCOMPATIBLE CHANGES
   TEZ-2972. Avoid task rescheduling when a node turns unhealthy
 
 ALL CHANGES:
+  TEZ-3192. IFile#checkState creating unnecessary objects though auto-boxing
   TEZ-3189. Pre-warm dags should not be counted in submitted dags count by 
DAGAppMaster.
   TEZ-2967. Vertex start time should be that of first task start time in UI
   TEZ-3175. Add tez client submit host

http://git-wip-us.apache.org/repos/asf/tez/blob/be57068d/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/IFile.java
----------------------------------------------------------------------
diff --git 
a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/IFile.java
 
b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/IFile.java
index a99eb5e..6d8992e 100644
--- 
a/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/IFile.java
+++ 
b/tez-runtime-library/src/main/java/org/apache/tez/runtime/library/common/sort/impl/IFile.java
@@ -192,7 +192,9 @@ public class IFile {
     }
 
     public void close() throws IOException {
-      checkState(!closed.getAndSet(true), "Writer was already closed earlier");
+      if (closed.getAndSet(true)) {
+        throw new IOException("Writer was already closed earlier");
+      }
 
       // When IFile writer is created by BackupStore, we do not have
       // Key and Value classes set. So, check before closing the
@@ -703,7 +705,9 @@ public class IFile {
      */
     protected boolean positionToNextRecord(DataInput dIn) throws IOException {
       // Sanity check
-      checkState(!eof, "Reached EOF. Completed reading %d", bytesRead);
+      if (eof) {
+        throw new IOException(String.format("Reached EOF. Completed reading 
%d", bytesRead));
+      }
       prevKeyLength = currentKeyLength;
 
       if (prevKeyLength == RLE_MARKER) {
@@ -754,7 +758,9 @@ public class IFile {
         keyBytes = new byte[currentKeyLength << 1];
       }
       int i = readData(keyBytes, 0, currentKeyLength);
-      checkState((i == currentKeyLength), INCOMPLETE_READ, currentKeyLength, 
i);
+      if (i != currentKeyLength) {
+        throw new IOException(String.format(INCOMPLETE_READ, currentKeyLength, 
i));
+      }
       key.reset(keyBytes, currentKeyLength);
       bytesRead += currentKeyLength;
       return KeyState.NEW_KEY;
@@ -766,7 +772,9 @@ public class IFile {
         ? new byte[currentValueLength << 1]
         : value.getData();
       int i = readData(valBytes, 0, currentValueLength);
-      checkState((i == currentValueLength), INCOMPLETE_READ, 
currentValueLength, i);
+      if (i != currentValueLength) {
+        throw new IOException(String.format(INCOMPLETE_READ, 
currentValueLength, i));
+      }
       value.reset(valBytes, currentValueLength);
 
       // Record the bytes read
@@ -819,11 +827,4 @@ public class IFile {
     }
   }
 
-  public static void checkState(boolean expression, String format,
-      Object... args) throws IOException {
-    if (!expression) {
-      throw new IOException(String.format(format, args));
-    }
-  }
-
 }

Reply via email to