Repository: hive
Updated Branches:
  refs/heads/branch-3 d8c97cf28 -> 07f2fe43d


HIVE-20621: GetOperationStatus called in resultset.next causing incremental 
slowness (Prasanth Jayachandran reviewed by Gopal V)


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

Branch: refs/heads/branch-3
Commit: 07f2fe43d3a943995bee0e39b562777ee20f6c9c
Parents: d8c97cf
Author: Prasanth Jayachandran <prasan...@apache.org>
Authored: Sun Sep 23 01:24:13 2018 -0700
Committer: Prasanth Jayachandran <prasan...@apache.org>
Committed: Sun Sep 23 01:24:33 2018 -0700

----------------------------------------------------------------------
 .../java/org/apache/hive/jdbc/HiveQueryResultSet.java    | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/07f2fe43/jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java
----------------------------------------------------------------------
diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java 
b/jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java
index 953fa83..78025c5 100644
--- a/jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java
+++ b/jdbc/src/java/org/apache/hive/jdbc/HiveQueryResultSet.java
@@ -43,6 +43,7 @@ import org.apache.hive.service.rpc.thrift.TColumnDesc;
 import org.apache.hive.service.rpc.thrift.TFetchOrientation;
 import org.apache.hive.service.rpc.thrift.TFetchResultsReq;
 import org.apache.hive.service.rpc.thrift.TFetchResultsResp;
+import org.apache.hive.service.rpc.thrift.TGetOperationStatusResp;
 import org.apache.hive.service.rpc.thrift.TGetResultSetMetadataReq;
 import org.apache.hive.service.rpc.thrift.TGetResultSetMetadataResp;
 import org.apache.hive.service.rpc.thrift.TOperationHandle;
@@ -77,6 +78,7 @@ public class HiveQueryResultSet extends HiveBaseResultSet {
   private boolean emptyResultSet = false;
   private boolean isScrollable = false;
   private boolean fetchFirst = false;
+  private TGetOperationStatusResp operationStatus = null;
 
   private final TProtocolVersion protocol;
 
@@ -317,6 +319,7 @@ public class HiveQueryResultSet extends HiveBaseResultSet {
     stmtHandle = null;
     sessHandle = null;
     isClosed = true;
+    operationStatus = null;
   }
 
   private void closeOperationHandle(TOperationHandle stmtHandle) throws 
SQLException {
@@ -348,13 +351,15 @@ public class HiveQueryResultSet extends HiveBaseResultSet 
{
       return false;
     }
 
-    /**
+    /*
      * Poll on the operation status, till the operation is complete.
      * We need to wait only for HiveStatement to complete.
      * HiveDatabaseMetaData which also uses this ResultSet returns only after 
the RPC is complete.
      */
-    if ((statement != null) && (statement instanceof HiveStatement)) {
-      ((HiveStatement) statement).waitForOperationToComplete();
+    // when isHasResultSet is set, the query transitioned from running -> 
complete and is not expected go back to
+    // running state when fetching results (implicit state transition)
+    if ((statement instanceof HiveStatement) && (operationStatus == null || 
!operationStatus.isHasResultSet())) {
+      operationStatus = ((HiveStatement) 
statement).waitForOperationToComplete();
     }
 
     try {

Reply via email to