[CARBONDATA-3121] Improvement of CarbonReader build time

CarbonReader builder is taking huge time.

Reason
Initialization of ChunkRowIterator is triggering actual I/O operation, and thus 
huge build time.

Solution
remove CarbonIterator.hasNext() and CarbonIterator.next() from build.

This closes #2942


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

Branch: refs/heads/branch-1.5
Commit: 38b79f325a82a58bc2d5e4581825eacf78bff32c
Parents: 1dd7f9e
Author: Naman Rastogi <naman.rastogi...@gmail.com>
Authored: Thu Nov 22 13:57:50 2018 +0530
Committer: ravipesala <ravi.pes...@gmail.com>
Committed: Fri Nov 30 21:55:29 2018 +0530

----------------------------------------------------------------------
 .../scan/result/iterator/ChunkRowIterator.java   | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/38b79f32/core/src/main/java/org/apache/carbondata/core/scan/result/iterator/ChunkRowIterator.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/carbondata/core/scan/result/iterator/ChunkRowIterator.java
 
b/core/src/main/java/org/apache/carbondata/core/scan/result/iterator/ChunkRowIterator.java
index 3ce69ed..03efc3d 100644
--- 
a/core/src/main/java/org/apache/carbondata/core/scan/result/iterator/ChunkRowIterator.java
+++ 
b/core/src/main/java/org/apache/carbondata/core/scan/result/iterator/ChunkRowIterator.java
@@ -39,9 +39,6 @@ public class ChunkRowIterator extends 
CarbonIterator<Object[]> {
 
   public ChunkRowIterator(CarbonIterator<RowBatch> iterator) {
     this.iterator = iterator;
-    if (iterator.hasNext()) {
-      currentChunk = iterator.next();
-    }
   }
 
   /**
@@ -52,17 +49,11 @@ public class ChunkRowIterator extends 
CarbonIterator<Object[]> {
    * @return {@code true} if the iteration has more elements
    */
   @Override public boolean hasNext() {
-    if (null != currentChunk) {
-      if ((currentChunk.hasNext())) {
-        return true;
-      } else if (!currentChunk.hasNext()) {
-        while (iterator.hasNext()) {
-          currentChunk = iterator.next();
-          if (currentChunk != null && currentChunk.hasNext()) {
-            return true;
-          }
-        }
-      }
+    if (currentChunk != null && currentChunk.hasNext()) {
+      return true;
+    } else if (iterator != null && iterator.hasNext()) {
+      currentChunk = iterator.next();
+      return hasNext();
     }
     return false;
   }

Reply via email to