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 d7fc1e8f91..d824ad6e89 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 TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 6bbdce5120..6d0b587af7 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 @@ 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 void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -256,7 +255,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 e39502fe0b..37f5b60a0a 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 void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -172,7 +171,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 5d5d099d81..51d69656c1 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 void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -156,7 +155,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 0e5d5c1b19..97dd9b97b8 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 @@ public void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -136,7 +135,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 b97878735c..8690262401 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 void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -104,7 +103,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 b5dac4b924..83f6260dbd 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 void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -99,7 +98,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 5ccdc94773..20eabc5301 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 @@ 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 void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -158,7 +159,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 e3d26e447d..ab0ce36d05 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 void runInternal() throws HiveSQLException { */ @Override public TableSchema getResultSetSchema() throws HiveSQLException { - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); return RESULT_SET_SCHEMA; } @@ -148,7 +147,7 @@ public TableSchema getResultSetSchema() throws HiveSQLException { */ @Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { - assertState(new ArrayList(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 76c4da5bb3..64e7f41e2c 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,6 +18,7 @@ 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; @@ -200,10 +201,9 @@ protected void setOperationException(HiveSQLException operationException) { this.operationException = operationException; } - protected final void assertState(List states) throws HiveSQLException { + protected final void assertState(final Collection 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 96770f4f34..eeed7d9a93 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 @@ -25,7 +25,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; @@ -437,7 +437,7 @@ public void close() throws HiveSQLException { public TableSchema getResultSetSchema() throws HiveSQLException { // Since compilation is always a blocking RPC call, and schema is ready after compilation, // we can return when are in the RUNNING state. - assertState(Arrays.asList(OperationState.RUNNING, OperationState.FINISHED)); + assertState(Collections.singleton(OperationState.FINISHED)); if (resultSchema == null) { resultSchema = new TableSchema(driver.getSchema()); } @@ -451,7 +451,7 @@ public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { validateDefaultFetchOrientation(orientation); - assertState(new ArrayList(Arrays.asList(OperationState.FINISHED))); + assertState(Collections.singleton(OperationState.FINISHED)); FetchTask fetchTask = driver.getFetchTask(); boolean isBlobBased = false;