giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clau...@apache.org
Subject svn commit: r1206252 - in /incubator/giraph/trunk: CHANGELOG src/main/java/org/apache/giraph/bsp/BspRecordReader.java
Date Fri, 25 Nov 2011 16:41:55 GMT
Author: claudio
Date: Fri Nov 25 16:41:55 2011
New Revision: 1206252

URL: http://svn.apache.org/viewvc?rev=1206252&view=rev
Log:
GIRAPH-84: Simplify boolean expressions in BspRecordReader

Modified:
    incubator/giraph/trunk/CHANGELOG
    incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspRecordReader.java

Modified: incubator/giraph/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/CHANGELOG?rev=1206252&r1=1206251&r2=1206252&view=diff
==============================================================================
--- incubator/giraph/trunk/CHANGELOG (original)
+++ incubator/giraph/trunk/CHANGELOG Fri Nov 25 16:41:55 2011
@@ -2,6 +2,9 @@ Giraph Change Log
 
 Release 0.70.0 - unreleased
 
+  GIRAPH-89: Simplify boolean expressions in BspRecordReader.
+  (shaunak via claudio)
+
   GIRAPH-90: LongDoubleFloatDoubleVertex has possibily the iterator() 
   implementation broken (claudio)
 

Modified: incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspRecordReader.java
URL: http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspRecordReader.java?rev=1206252&r1=1206251&r2=1206252&view=diff
==============================================================================
--- incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspRecordReader.java (original)
+++ incubator/giraph/trunk/src/main/java/org/apache/giraph/bsp/BspRecordReader.java Fri Nov
25 16:41:55 2011
@@ -29,6 +29,10 @@ import org.apache.hadoop.io.Text;
  * Only returns a single key-value pair so that the map() can run.
  */
 class BspRecordReader extends RecordReader<Text, Text> {
+
+    private static final Text ONLY_KEY = new Text("only key");
+    private static final Text ONLY_VALUE = new Text("only value");
+
     /** Has the one record been seen? */
     private boolean seenRecord = false;
 
@@ -39,22 +43,17 @@ class BspRecordReader extends RecordRead
 
     @Override
     public float getProgress() throws IOException {
-        if (seenRecord == true) {
-            return 1f;
-        }
-        else {
-            return 0f;
-        }
+        return (seenRecord ? 1f : 0f);
     }
 
     @Override
     public Text getCurrentKey() throws IOException, InterruptedException {
-        return new Text("only key");
+        return ONLY_KEY;
     }
 
     @Override
     public Text getCurrentValue() throws IOException, InterruptedException {
-        return new Text("only value");
+        return ONLY_VALUE;
     }
 
     @Override
@@ -64,12 +63,6 @@ class BspRecordReader extends RecordRead
 
     @Override
     public boolean nextKeyValue() throws IOException, InterruptedException {
-        if (seenRecord == false) {
-            seenRecord = true;
-            return true;
-        }
-        else {
-            return false;
-        }
+	return (seenRecord ? false : (seenRecord = true));
     }
 }



Mime
View raw message