This is an automated email from the ASF dual-hosted git repository. dmollitor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push: new 818a68f HIVE-23098: Allow Operation assertState to Accept a Collection (David Mollitor, reviewed by Naveen Gangam) 818a68f is described below commit 818a68ff9b5396dc99237469db25b87513bfff7e Author: David Mollitor <dmolli...@apache.org> AuthorDate: Tue Apr 14 20:42:58 2020 -0400 HIVE-23098: Allow Operation assertState to Accept a Collection (David Mollitor, reviewed by Naveen Gangam) --- .../apache/hive/service/cli/operation/GetCatalogsOperation.java | 5 ++--- .../org/apache/hive/service/cli/operation/GetColumnsOperation.java | 5 ++--- .../hive/service/cli/operation/GetCrossReferenceOperation.java | 7 +++---- .../apache/hive/service/cli/operation/GetFunctionsOperation.java | 7 +++---- .../apache/hive/service/cli/operation/GetPrimaryKeysOperation.java | 7 +++---- .../org/apache/hive/service/cli/operation/GetSchemasOperation.java | 7 +++---- .../apache/hive/service/cli/operation/GetTableTypesOperation.java | 7 +++---- .../org/apache/hive/service/cli/operation/GetTablesOperation.java | 5 +++-- .../apache/hive/service/cli/operation/GetTypeInfoOperation.java | 7 +++---- .../src/java/org/apache/hive/service/cli/operation/Operation.java | 7 +++---- .../java/org/apache/hive/service/cli/operation/SQLOperation.java | 3 ++- 11 files changed, 30 insertions(+), 37 deletions(-) diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetCatalogsOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetCatalogsOperation.java index d7fc1e8..d824ad6 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetCatalogsOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetCatalogsOperation.java @@ -18,8 +18,7 @@ package org.apache.hive.service.cli.operation; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType; import org.apache.hive.service.cli.FetchOrientation; @@ -80,7 +79,7 @@ public class GetCatalogsOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java index 6bbdce5..6d0b587 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetColumnsOperation.java @@ -20,7 +20,6 @@ package org.apache.hive.service.cli.operation; import java.sql.DatabaseMetaData; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -247,7 +246,7 @@ public class GetColumnsOperation extends MetadataOperation { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -256,7 +255,7 @@ public class GetColumnsOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetCrossReferenceOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetCrossReferenceOperation.java index e39502f..37f5b60 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetCrossReferenceOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetCrossReferenceOperation.java @@ -18,8 +18,7 @@ package org.apache.hive.service.cli.operation; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.hadoop.hive.metastore.IMetaStoreClient; @@ -163,7 +162,7 @@ public class GetCrossReferenceOperation extends MetadataOperation { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -172,7 +171,7 @@ public class GetCrossReferenceOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetFunctionsOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetFunctionsOperation.java index 5d5d099..51d6965 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetFunctionsOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetFunctionsOperation.java @@ -19,8 +19,7 @@ package org.apache.hive.service.cli.operation; import java.sql.DatabaseMetaData; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -147,7 +146,7 @@ public class GetFunctionsOperation extends MetadataOperation { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -156,7 +155,7 @@ public class GetFunctionsOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetPrimaryKeysOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetPrimaryKeysOperation.java index 0e5d5c1..97dd9b9 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetPrimaryKeysOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetPrimaryKeysOperation.java @@ -18,8 +18,7 @@ package org.apache.hive.service.cli.operation; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.hadoop.hive.metastore.IMetaStoreClient; @@ -127,7 +126,7 @@ PK_NAME String => primary key name (may be null) */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -136,7 +135,7 @@ PK_NAME String => primary key name (may be null) */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetSchemasOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetSchemasOperation.java index b978787..8690262 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetSchemasOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetSchemasOperation.java @@ -18,8 +18,7 @@ package org.apache.hive.service.cli.operation; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType; @@ -95,7 +94,7 @@ public class GetSchemasOperation extends MetadataOperation { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -104,7 +103,7 @@ public class GetSchemasOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetTableTypesOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetTableTypesOperation.java index b5dac4b..83f6260 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetTableTypesOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetTableTypesOperation.java @@ -18,8 +18,7 @@ package org.apache.hive.service.cli.operation; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.metastore.TableType; @@ -90,7 +89,7 @@ public class GetTableTypesOperation extends MetadataOperation { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -99,7 +98,7 @@ public class GetTableTypesOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java index 5ccdc94..20eabc5 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetTablesOperation.java @@ -20,6 +20,7 @@ package org.apache.hive.service.cli.operation; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.hadoop.hive.conf.HiveConf; @@ -149,7 +150,7 @@ public class GetTablesOperation extends MetadataOperation { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -158,7 +159,7 @@ public class GetTablesOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/GetTypeInfoOperation.java b/service/src/java/org/apache/hive/service/cli/operation/GetTypeInfoOperation.java index e3d26e4..ab0ce36 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/GetTypeInfoOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/GetTypeInfoOperation.java @@ -18,8 +18,7 @@ package org.apache.hive.service.cli.operation; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType; import org.apache.hadoop.hive.serde2.thrift.Type; @@ -139,7 +138,7 @@ public class GetTypeInfoOperation extends MetadataOperation { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -148,7 +147,7 @@ public class GetTypeInfoOperation extends MetadataOperation { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); diff --git a/service/src/java/org/apache/hive/service/cli/operation/Operation.java b/service/src/java/org/apache/hive/service/cli/operation/Operation.java index 76c4da5..3df8f6d 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/Operation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/Operation.java @@ -18,8 +18,8 @@ package org.apache.hive.service.cli.operation; import java.io.File; +import java.util.Collection; import java.util.EnumSet; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -200,10 +200,9 @@ public abstract class Operation { this.operationException = operationException; } - protected final void assertState(List<OperationState> states) throws HiveSQLException { + protected final void assertState(final Collection<OperationState> states) throws HiveSQLException { if (!states.contains(state)) { - throw new HiveSQLException("Expected states: " + states.toString() + ", but found " - + this.state); + throw new HiveSQLException("Expected states: " + states + ", but found " + this.state); } this.lastAccessTime = System.currentTimeMillis(); } diff --git a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java index eefd644..25b6ab3 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java @@ -26,6 +26,7 @@ import java.security.PrivilegedExceptionAction; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -450,7 +451,7 @@ public class SQLOperation extends ExecuteStatementOperation { throws HiveSQLException { validateDefaultFetchOrientation(orientation); - assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); FetchTask fetchTask = driver.getFetchTask(); boolean isBlobBased = false;