kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From granthe...@apache.org
Subject kudu git commit: [spark] Cleanup hasNext logic
Date Thu, 27 Sep 2018 22:32:55 GMT
Repository: kudu
Updated Branches:
  refs/heads/master ecc4998cb -> ad620415a


[spark] Cleanup hasNext logic

When returning to the while loop in
RowIterator.hasNext() I always have to do a
double take on the logic. This change makes
the logic a bit more clear.

Change-Id: I340af13a695b3a8489e03018542b8ad7db614758
Reviewed-on: http://gerrit.cloudera.org:8080/11529
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <adar@cloudera.com>


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

Branch: refs/heads/master
Commit: ad620415af0b7da700eb1ffdd5f864d33e984d12
Parents: ecc4998
Author: Grant Henke <granthenke@apache.org>
Authored: Wed Sep 26 14:28:33 2018 -0700
Committer: Grant Henke <granthenke@apache.org>
Committed: Thu Sep 27 00:41:06 2018 +0000

----------------------------------------------------------------------
 .../src/main/scala/org/apache/kudu/backup/KuduBackupRDD.scala   | 5 ++---
 .../src/main/java/org/apache/kudu/client/RowResultIterator.java | 2 +-
 .../src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala     | 5 ++---
 3 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/ad620415/java/kudu-backup/src/main/scala/org/apache/kudu/backup/KuduBackupRDD.scala
----------------------------------------------------------------------
diff --git a/java/kudu-backup/src/main/scala/org/apache/kudu/backup/KuduBackupRDD.scala b/java/kudu-backup/src/main/scala/org/apache/kudu/backup/KuduBackupRDD.scala
index 3b75236..740dfb9 100644
--- a/java/kudu-backup/src/main/scala/org/apache/kudu/backup/KuduBackupRDD.scala
+++ b/java/kudu-backup/src/main/scala/org/apache/kudu/backup/KuduBackupRDD.scala
@@ -105,11 +105,10 @@ private case class KuduBackupPartition(index: Int, scanToken: Array[Byte],
locat
  */
 private class RowIterator(private val scanner: KuduScanner) extends Iterator[Row] {
 
-  private var currentIterator: RowResultIterator = _
+  private var currentIterator: RowResultIterator = RowResultIterator.empty
 
   override def hasNext: Boolean = {
-    while ((currentIterator != null && !currentIterator.hasNext && scanner.hasMoreRows)
||
-      (scanner.hasMoreRows && currentIterator == null)) {
+    while (!currentIterator.hasNext && scanner.hasMoreRows) {
       if (TaskContext.get().isInterrupted()) {
         throw new RuntimeException("KuduBackup spark task interrupted")
       }

http://git-wip-us.apache.org/repos/asf/kudu/blob/ad620415/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
index f5c4cec..e9effd9 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RowResultIterator.java
@@ -93,7 +93,7 @@ public class RowResultIterator extends KuduRpcResponse implements Iterator<RowRe
   /**
    * @return an empty row result iterator
    */
-  static RowResultIterator empty() {
+  public static RowResultIterator empty() {
     return EMPTY;
   }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/ad620415/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
----------------------------------------------------------------------
diff --git a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
index ccc60fd..c16a6a0 100644
--- a/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
+++ b/java/kudu-spark/src/main/scala/org/apache/kudu/spark/kudu/KuduRDD.scala
@@ -118,11 +118,10 @@ private class KuduPartition(
 private class RowIterator(private val scanner: KuduScanner, private val kuduContext: KuduContext)
     extends Iterator[Row] {
 
-  private var currentIterator: RowResultIterator = null
+  private var currentIterator: RowResultIterator = RowResultIterator.empty
 
   override def hasNext: Boolean = {
-    while ((currentIterator != null && !currentIterator.hasNext && scanner.hasMoreRows)
||
-      (scanner.hasMoreRows && currentIterator == null)) {
+    while (!currentIterator.hasNext && scanner.hasMoreRows) {
       if (TaskContext.get().isInterrupted()) {
         throw new RuntimeException("Kudu task interrupted")
       }


Mime
View raw message