AMBARI-19666 : Fixed Hive view loosing one row every 100 row in result set. (nitirajrathore)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9f5a8bf6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9f5a8bf6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9f5a8bf6 Branch: refs/heads/branch-dev-patch-upgrade Commit: 9f5a8bf6a7c670845adfa07369e9c56ff68e9798 Parents: 37b4142 Author: Nitiraj Singh Rathore <nitiraj.rath...@gmail.com> Authored: Mon Jan 30 14:33:43 2017 +0530 Committer: Nitiraj Singh Rathore <nitiraj.rath...@gmail.com> Committed: Mon Jan 30 14:34:26 2017 +0530 ---------------------------------------------------------------------- .../org/apache/ambari/view/hive2/actor/ResultSetIterator.java | 3 ++- .../org/apache/ambari/view/hive20/actor/ResultSetIterator.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9f5a8bf6/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/ResultSetIterator.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/ResultSetIterator.java b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/ResultSetIterator.java index 1052bd4..5bde12d 100644 --- a/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/ResultSetIterator.java +++ b/contrib/views/hive-next/src/main/java/org/apache/ambari/view/hive2/actor/ResultSetIterator.java @@ -116,7 +116,8 @@ public class ResultSetIterator extends HiveActor { } int index = 0; try { - while (resultSet.next() && index < batchSize) { + // check batchsize first becaue resultSet.next() fetches the new row as well before returning true/false. + while (index < batchSize && resultSet.next()) { index++; rows.add(getRowFromResultSet(resultSet)); } http://git-wip-us.apache.org/repos/asf/ambari/blob/9f5a8bf6/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/ResultSetIterator.java ---------------------------------------------------------------------- diff --git a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/ResultSetIterator.java b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/ResultSetIterator.java index 4b4a407..5da5ee1 100644 --- a/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/ResultSetIterator.java +++ b/contrib/views/hive20/src/main/java/org/apache/ambari/view/hive20/actor/ResultSetIterator.java @@ -115,7 +115,8 @@ public class ResultSetIterator extends HiveActor { } int index = 0; try { - while (resultSet.next() && index < batchSize) { + // check batchsize first becaue resultSet.next() fetches the new row as well before returning true/false. + while (index < batchSize && resultSet.next()) { index++; rows.add(getRowFromResultSet(resultSet)); }