http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java index 2ee5433..f58ba04 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java @@ -59,7 +59,6 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.FileMetadataExprType; import org.apache.hadoop.hive.metastore.api.Function; import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; import org.apache.hadoop.hive.metastore.api.InvalidOperationException; @@ -709,7 +708,9 @@ public class CachedStore implements RawStore, Configurable { public void createDatabase(Database db) throws InvalidObjectException, MetaException { rawStore.createDatabase(db); SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return; + if (sharedCache == null) { + return; + } try { // Wait if background cache update is happening databaseCacheLock.readLock().lock(); @@ -746,7 +747,9 @@ public class CachedStore implements RawStore, Configurable { boolean succ = rawStore.dropDatabase(dbname); if (succ) { SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } try { // Wait if background cache update is happening databaseCacheLock.readLock().lock(); @@ -765,7 +768,9 @@ public class CachedStore implements RawStore, Configurable { boolean succ = rawStore.alterDatabase(dbName, db); if (succ) { SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } try { // Wait if background cache update is happening databaseCacheLock.readLock().lock(); @@ -845,7 +850,9 @@ public class CachedStore implements RawStore, Configurable { return; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return; + if (sharedCache == null) { + return; + } validateTableType(tbl); try { // Wait if background cache update is happening @@ -868,7 +875,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } // Remove table try { // Wait if background table cache update is happening @@ -917,7 +926,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } try { // Wait if background cache update is happening partitionCacheLock.readLock().lock(); @@ -950,7 +961,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } try { // Wait if background cache update is happening partitionCacheLock.readLock().lock(); @@ -985,7 +998,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } try { // Wait if background cache update is happening partitionCacheLock.readLock().lock(); @@ -1053,7 +1068,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } // Remove partition try { // Wait if background cache update is happening @@ -1109,7 +1126,9 @@ public class CachedStore implements RawStore, Configurable { return; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return; + if (sharedCache == null) { + return; + } if (shouldCacheTable(dbName, newTblName)) { validateTableType(newTable); @@ -1340,7 +1359,9 @@ public class CachedStore implements RawStore, Configurable { return; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return; + if (sharedCache == null) { + return; + } // Update partition cache try { // Wait if background cache update is happening @@ -1380,7 +1401,9 @@ public class CachedStore implements RawStore, Configurable { return; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return; + if (sharedCache == null) { + return; + } // Update partition cache try { // Wait if background cache update is happening @@ -1418,42 +1441,6 @@ public class CachedStore implements RawStore, Configurable { } } - @Override - public boolean addIndex(Index index) - throws InvalidObjectException, MetaException { - return rawStore.addIndex(index); - } - - @Override - public Index getIndex(String dbName, String origTableName, String indexName) - throws MetaException { - return rawStore.getIndex(dbName, origTableName, indexName); - } - - @Override - public boolean dropIndex(String dbName, String origTableName, - String indexName) throws MetaException { - return rawStore.dropIndex(dbName, origTableName, indexName); - } - - @Override - public List<Index> getIndexes(String dbName, String origTableName, int max) - throws MetaException { - return rawStore.getIndexes(dbName, origTableName, max); - } - - @Override - public List<String> listIndexNames(String dbName, String origTableName, - short max) throws MetaException { - return rawStore.listIndexNames(dbName, origTableName, max); - } - - @Override - public void alterIndex(String dbname, String baseTblName, String name, - Index newIndex) throws InvalidObjectException, MetaException { - rawStore.alterIndex(dbname, baseTblName, name, newIndex); - } - private boolean getPartitionNamesPrunedByExprNoTxn(Table table, byte[] expr, String defaultPartName, short maxParts, List<String> result, SharedCache sharedCache) throws MetaException, NoSuchObjectException { @@ -1518,7 +1505,9 @@ public class CachedStore implements RawStore, Configurable { } private static List<String> partNameToVals(String name) { - if (name == null) return null; + if (name == null) { + return null; + } List<String> vals = new ArrayList<>(); String[] kvp = name.split("/"); for (String kv : kvp) { @@ -1832,7 +1821,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } List<ColumnStatisticsObj> statsObjs = colStats.getStatsObj(); Table tbl = getTable(dbName, tblName); List<String> colNames = new ArrayList<>(); @@ -1898,7 +1889,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } try { // Wait if background cache update is happening tableColStatsCacheLock.readLock().lock(); @@ -1922,7 +1915,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } List<ColumnStatisticsObj> statsObjs = colStats.getStatsObj(); Partition part = getPartition(dbName, tblName, partVals); List<String> colNames = new ArrayList<>(); @@ -1982,7 +1977,9 @@ public class CachedStore implements RawStore, Configurable { return succ; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return succ; + if (sharedCache == null) { + return succ; + } try { // Wait if background cache update is happening partitionColStatsCacheLock.readLock().lock(); @@ -2180,7 +2177,9 @@ public class CachedStore implements RawStore, Configurable { return; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return; + if (sharedCache == null) { + return; + } // Remove partitions try { // Wait if background cache update is happening @@ -2445,7 +2444,9 @@ public class CachedStore implements RawStore, Configurable { return constraintNames; } SharedCache sharedCache = sharedCacheWrapper.get(); - if (sharedCache == null) return constraintNames; + if (sharedCache == null) { + return constraintNames; + } sharedCache.addTableToCache(StringUtils.normalizeIdentifier(tbl.getDbName()), StringUtils.normalizeIdentifier(tbl.getTableName()), tbl); return constraintNames; @@ -2567,7 +2568,9 @@ public class CachedStore implements RawStore, Configurable { * Fails on any initialization error, even if the init will be retried later. */ public SharedCache get() throws MetaException { - if (!waitForInit()) return null; + if (!waitForInit()) { + return null; + } return instance; }
http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/IndexBuilder.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/IndexBuilder.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/IndexBuilder.java deleted file mode 100644 index 50fc186..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/IndexBuilder.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hive.metastore.client.builder; - -import org.apache.hadoop.hive.metastore.api.Index; -import org.apache.hadoop.hive.metastore.api.MetaException; -import org.apache.hadoop.hive.metastore.api.Table; - -import java.util.HashMap; -import java.util.Map; - -/** - * Builder for indices. You must supply the database name and table name (or table reference), a - * name for the index, and whatever StorageDescriptorBuilder requires. All other fields will be - * given reasonable defaults. - */ -public class IndexBuilder extends StorageDescriptorBuilder<IndexBuilder> { - private String dbName, tableName, indexName, indexTableName, handlerClass; - private int createTime, lastAccessTime; - private Map<String, String> indexParams; - private boolean deferredRebuild; - - public IndexBuilder() { - // Set some reasonable defaults - indexParams = new HashMap<>(); - createTime = lastAccessTime = (int)(System.currentTimeMillis() / 1000); - super.setChild(this); - } - - public IndexBuilder setDbName(String dbName) { - this.dbName = dbName; - return this; - } - - public IndexBuilder setTableName(String tableName) { - this.tableName = tableName; - return this; - } - - public IndexBuilder setDbAndTableName(Table table) { - this.dbName = table.getDbName(); - this.tableName = table.getTableName(); - return this; - } - - public IndexBuilder setCreateTime(int createTime) { - this.createTime = createTime; - return this; - } - - public IndexBuilder setLastAccessTime(int lastAccessTime) { - this.lastAccessTime = lastAccessTime; - return this; - } - - public IndexBuilder setIndexParams(Map<String, String> indexParams) { - this.indexParams = indexParams; - return this; - } - - public IndexBuilder addIndexParam(String key, String value) { - indexParams.put(key, value); - return this; - } - - public IndexBuilder setIndexName(String indexName) { - this.indexName = indexName; - return this; - } - - public IndexBuilder setIndexTableName(String indexTableName) { - this.indexTableName = indexTableName; - return this; - } - - public IndexBuilder setHandlerClass(String handlerClass) { - this.handlerClass = handlerClass; - return this; - } - - public IndexBuilder setDeferredRebuild(boolean deferredRebuild) { - this.deferredRebuild = deferredRebuild; - return this; - } - - public Index build() throws MetaException { - if (dbName == null || tableName == null || indexName == null) { - throw new MetaException("You must provide database name, table name, and index name"); - } - if (indexTableName == null) indexTableName = tableName + "_" + indexName + "_table"; - return new Index(indexName, handlerClass, dbName, tableName, createTime, lastAccessTime, - indexTableName, buildSd(), indexParams, deferredRebuild); - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java index a5325e7..2b9f816 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/client/builder/TableBuilder.java @@ -20,7 +20,6 @@ package org.apache.hadoop.hive.metastore.client.builder; import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.FieldSchema; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.utils.MetaStoreUtils; @@ -123,7 +122,9 @@ public class TableBuilder extends StorageDescriptorBuilder<TableBuilder> { } public TableBuilder addTableParam(String key, String value) { - if (tableParams == null) tableParams = new HashMap<>(); + if (tableParams == null) { + tableParams = new HashMap<>(); + } tableParams.put(key, value); return this; } @@ -138,14 +139,6 @@ public class TableBuilder extends StorageDescriptorBuilder<TableBuilder> { return this; } - public TableBuilder fromIndex(Index index) { - dbName = index.getDbName(); - tableName = index.getIndexTableName(); - setCols(index.getSd().getCols()); - setType(TableType.INDEX_TABLE.name()); - return this; - } - public Table build() throws MetaException { if (dbName == null || tableName == null) { throw new MetaException("You must set the database and table name"); @@ -159,8 +152,12 @@ public class TableBuilder extends StorageDescriptorBuilder<TableBuilder> { } Table t = new Table(tableName, dbName, owner, createTime, lastAccessTime, retention, buildSd(), partCols, tableParams, viewOriginalText, viewExpandedText, type); - if (rewriteEnabled) t.setRewriteEnabled(true); - if (temporary) t.setTemporary(temporary); + if (rewriteEnabled) { + t.setRewriteEnabled(true); + } + if (temporary) { + t.setTemporary(temporary); + } return t; } http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AddIndexEvent.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AddIndexEvent.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AddIndexEvent.java deleted file mode 100644 index 0d6cb56..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AddIndexEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.metastore.events; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hive.metastore.IHMSHandler; -import org.apache.hadoop.hive.metastore.api.Index; - -@InterfaceAudience.Public -@InterfaceStability.Stable -public class AddIndexEvent extends ListenerEvent { - - private final Index index; - - public AddIndexEvent(Index index, boolean status, IHMSHandler handler) { - super(status, handler); - this.index = index; - } - - public Index getIndex() { - return index; - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AlterIndexEvent.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AlterIndexEvent.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AlterIndexEvent.java deleted file mode 100644 index 2c72b83..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/AlterIndexEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.metastore.events; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hive.metastore.IHMSHandler; -import org.apache.hadoop.hive.metastore.api.Index; - -@InterfaceAudience.Public -@InterfaceStability.Stable -public class AlterIndexEvent extends ListenerEvent { - - private final Index newIndex; - private final Index oldIndex; - - public AlterIndexEvent(Index oldIndex, Index newIndex, boolean status, IHMSHandler handler) { - super(status, handler); - this.oldIndex = oldIndex; - this.newIndex = newIndex; - } - - public Index getOldIndex() { - return oldIndex; - } - - public Index getNewIndex() { - return newIndex; - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/DropIndexEvent.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/DropIndexEvent.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/DropIndexEvent.java deleted file mode 100644 index 4d69834..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/DropIndexEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.metastore.events; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hive.metastore.IHMSHandler; -import org.apache.hadoop.hive.metastore.api.Index; - -@InterfaceAudience.Public -@InterfaceStability.Stable -public class DropIndexEvent extends ListenerEvent { - - private final Index index; - - public DropIndexEvent(Index index, boolean status, IHMSHandler handler) { - super(status, handler); - this.index = index; - } - - public Index getIndex() { - return index; - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAddIndexEvent.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAddIndexEvent.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAddIndexEvent.java deleted file mode 100644 index d9a53f8..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAddIndexEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.metastore.events; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hive.metastore.IHMSHandler; -import org.apache.hadoop.hive.metastore.api.Index; - -@InterfaceAudience.Public -@InterfaceStability.Stable -public class PreAddIndexEvent extends PreEventContext { - -private final Index table; - - public PreAddIndexEvent(Index table, IHMSHandler handler) { - super(PreEventType.ADD_INDEX, handler); - this.table = table; - } - - public Index getIndex() { - return table; - } -} - http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAlterIndexEvent.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAlterIndexEvent.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAlterIndexEvent.java deleted file mode 100644 index 2e9d9d7..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreAlterIndexEvent.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.metastore.events; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hive.metastore.IHMSHandler; -import org.apache.hadoop.hive.metastore.api.Index; - -@InterfaceAudience.Public -@InterfaceStability.Stable -public class PreAlterIndexEvent extends PreEventContext { - - private final Index newIndex; - private final Index oldIndex; - - public PreAlterIndexEvent(Index oldIndex, Index newIndex, IHMSHandler handler) { - super(PreEventType.ALTER_INDEX, handler); - this.oldIndex = oldIndex; - this.newIndex = newIndex; - } - - public Index getOldIndex() { - return oldIndex; - } - - public Index getNewIndex() { - return newIndex; - } -} - http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreDropIndexEvent.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreDropIndexEvent.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreDropIndexEvent.java deleted file mode 100644 index ad570db..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreDropIndexEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.hive.metastore.events; - -import org.apache.hadoop.classification.InterfaceAudience; -import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.hive.metastore.IHMSHandler; -import org.apache.hadoop.hive.metastore.api.Index; - -@InterfaceAudience.Public -@InterfaceStability.Stable -public class PreDropIndexEvent extends PreEventContext { - - private final Index index; - - public PreDropIndexEvent(Index index, IHMSHandler handler) { - super(PreEventType.DROP_INDEX, handler); - this.index = index; - } - - public Index getIndex() { - return index; - } -} http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreEventContext.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreEventContext.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreEventContext.java index a3f4836..c5efde3 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreEventContext.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/events/PreEventContext.java @@ -42,9 +42,6 @@ public abstract class PreEventContext { AUTHORIZATION_API_CALL, READ_TABLE, READ_DATABASE, - ADD_INDEX, - ALTER_INDEX, - DROP_INDEX, ALTER_DATABASE } http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java deleted file mode 100644 index 78259ba..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterIndexMessage.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging; - -import org.apache.hadoop.hive.metastore.api.Index; - -public abstract class AlterIndexMessage extends EventMessage { - - public abstract Index getIndexObjBefore() throws Exception; - - public abstract Index getIndexObjAfter() throws Exception; - - protected AlterIndexMessage() { - super(EventType.ALTER_INDEX); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java deleted file mode 100644 index f107100..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/CreateIndexMessage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging; - -import org.apache.hadoop.hive.metastore.api.Index; - -public abstract class CreateIndexMessage extends EventMessage { - - protected CreateIndexMessage() { - super(EventType.CREATE_INDEX); - } - - public abstract Index getIndexObj() throws Exception; - - @Override - public EventMessage checkValid() { - try { - if (getIndexObj() == null) - throw new IllegalStateException("Function object unset."); - } catch (Exception e) { - if (! (e instanceof IllegalStateException)){ - throw new IllegalStateException("Event not set up correctly", e); - } else { - throw (IllegalStateException) e; - } - } - return super.checkValid(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java deleted file mode 100644 index 210b592..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/DropIndexMessage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging; - -public abstract class DropIndexMessage extends EventMessage { - - public abstract String getIndexName(); - public abstract String getOrigTableName(); - public abstract String getIndexTableName(); - - protected DropIndexMessage() { - super(EventType.DROP_INDEX); - } - - @Override - public EventMessage checkValid() { - if (getIndexName() == null){ - throw new IllegalStateException("Index name unset."); - } - if (getOrigTableName() == null){ - throw new IllegalStateException("Index original table name unset."); - } - // NOTE: we do not do a not-null check on getIndexTableName, - // since, per the index design wiki, it can actually be null. - - return super.checkValid(); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java index dad2f5b..92d2eb4 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/EventMessage.java @@ -42,9 +42,7 @@ public abstract class EventMessage { INSERT(MessageFactory.INSERT_EVENT), CREATE_FUNCTION(MessageFactory.CREATE_FUNCTION_EVENT), DROP_FUNCTION(MessageFactory.DROP_FUNCTION_EVENT), - CREATE_INDEX(MessageFactory.CREATE_INDEX_EVENT), - DROP_INDEX(MessageFactory.DROP_INDEX_EVENT), - ALTER_INDEX(MessageFactory.ALTER_INDEX_EVENT), + ADD_PRIMARYKEY(MessageFactory.ADD_PRIMARYKEY_EVENT), ADD_FOREIGNKEY(MessageFactory.ADD_FOREIGNKEY_EVENT), ADD_UNIQUECONSTRAINT(MessageFactory.ADD_UNIQUECONSTRAINT_EVENT), @@ -100,12 +98,15 @@ public abstract class EventMessage { * Class invariant. Checked after construction or deserialization. */ public EventMessage checkValid() { - if (getServer() == null || getServicePrincipal() == null) + if (getServer() == null || getServicePrincipal() == null) { throw new IllegalStateException("Server-URL/Service-Principal shouldn't be null."); - if (getEventType() == null) + } + if (getEventType() == null) { throw new IllegalStateException("Event-type unset."); - if (getDB() == null) + } + if (getDB() == null) { throw new IllegalArgumentException("DB-name unset."); + } return this; } http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java index f85dc40..0fd4601 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageDeserializer.java @@ -52,12 +52,6 @@ public abstract class MessageDeserializer { return getCreateFunctionMessage(messageBody); case DROP_FUNCTION: return getDropFunctionMessage(messageBody); - case CREATE_INDEX: - return getCreateIndexMessage(messageBody); - case DROP_INDEX: - return getDropIndexMessage(messageBody); - case ALTER_INDEX: - return getAlterIndexMessage(messageBody); case INSERT: return getInsertMessage(messageBody); case ADD_PRIMARYKEY: @@ -135,21 +129,6 @@ public abstract class MessageDeserializer { public abstract DropFunctionMessage getDropFunctionMessage(String messageBody); /** - * Method to de-serialize CreateIndexMessage instance. - */ - public abstract CreateIndexMessage getCreateIndexMessage(String messageBody); - - /** - * Method to de-serialize DropIndexMessage instance. - */ - public abstract DropIndexMessage getDropIndexMessage(String messageBody); - - /** - * Method to de-serialize AlterIndexMessage instance. - */ - public abstract AlterIndexMessage getAlterIndexMessage(String messageBody); - - /** * Method to deserialize InsertMessage * @param messageBody the message in serialized form * @return message in object form http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java index 0e3357d..c59ca02 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/MessageFactory.java @@ -22,7 +22,6 @@ package org.apache.hadoop.hive.metastore.messaging; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.Function; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.Partition; import org.apache.hadoop.hive.metastore.api.SQLForeignKey; @@ -55,9 +54,6 @@ public abstract class MessageFactory { public static final String INSERT_EVENT = "INSERT"; public static final String CREATE_FUNCTION_EVENT = "CREATE_FUNCTION"; public static final String DROP_FUNCTION_EVENT = "DROP_FUNCTION"; - public static final String CREATE_INDEX_EVENT = "CREATE_INDEX"; - public static final String DROP_INDEX_EVENT = "DROP_INDEX"; - public static final String ALTER_INDEX_EVENT = "ALTER_INDEX"; public static final String ADD_PRIMARYKEY_EVENT = "ADD_PRIMARYKEY"; public static final String ADD_FOREIGNKEY_EVENT = "ADD_FOREIGNKEY"; public static final String ADD_UNIQUECONSTRAINT_EVENT = "ADD_UNIQUECONSTRAINT"; @@ -220,28 +216,6 @@ public abstract class MessageFactory { public abstract DropFunctionMessage buildDropFunctionMessage(Function fn); /** - * Factory method for CreateIndexMessage. - * @param idx The Index being added. - * @return CreateIndexMessage instance. - */ - public abstract CreateIndexMessage buildCreateIndexMessage(Index idx); - - /** - * Factory method for DropIndexMessage. - * @param idx The Index being dropped. - * @return DropIndexMessage instance. - */ - public abstract DropIndexMessage buildDropIndexMessage(Index idx); - - /** - * Factory method for AlterIndexMessage. - * @param before The index before the alter - * @param after The index after the alter - * @return AlterIndexMessage - */ - public abstract AlterIndexMessage buildAlterIndexMessage(Index before, Index after); - - /** * Factory method for building insert message * * @param tableObj Table object where the insert occurred in http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java deleted file mode 100644 index d1657b4..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterIndexMessage.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; - -import org.apache.hadoop.hive.metastore.api.Index; -import org.apache.hadoop.hive.metastore.messaging.AlterIndexMessage; -import org.apache.thrift.TException; -import org.codehaus.jackson.annotate.JsonProperty; - -/** - * JSON Implementation of AlterIndexMessage. - */ -public class JSONAlterIndexMessage extends AlterIndexMessage { - - @JsonProperty - String server, servicePrincipal, db, beforeIndexObjJson, afterIndexObjJson; - - @JsonProperty - Long timestamp; - - /** - * Default constructor, required for Jackson. - */ - public JSONAlterIndexMessage() {} - - public JSONAlterIndexMessage(String server, String servicePrincipal, Index before, Index after, - Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.db = after.getDbName(); - this.timestamp = timestamp; - try { - this.beforeIndexObjJson = JSONMessageFactory.createIndexObjJson(before); - this.afterIndexObjJson = JSONMessageFactory.createIndexObjJson(after); - } catch (TException ex) { - throw new IllegalArgumentException("Could not serialize Index object", ex); - } - - checkValid(); - } - - @Override - public String getDB() { return db; } - - @Override - public String getServer() { return server; } - - @Override - public String getServicePrincipal() { return servicePrincipal; } - - @Override - public Long getTimestamp() { return timestamp; } - - public String getBeforeIndexObjJson() { - return beforeIndexObjJson; - } - - public String getAfterIndexObjJson() { - return afterIndexObjJson; - } - - @Override - public Index getIndexObjBefore() throws Exception { - return (Index) JSONMessageFactory.getTObj(beforeIndexObjJson, Index.class); - } - - @Override - public Index getIndexObjAfter() throws Exception { - return (Index) JSONMessageFactory.getTObj(afterIndexObjJson, Index.class); - } - - @Override - public String toString() { - try { - return JSONMessageDeserializer.mapper.writeValueAsString(this); - } - catch (Exception exception) { - throw new IllegalArgumentException("Could not serialize: ", exception); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateIndexMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateIndexMessage.java deleted file mode 100644 index a40e524..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateIndexMessage.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; - -import org.apache.hadoop.hive.metastore.api.Index; -import org.apache.hadoop.hive.metastore.messaging.CreateIndexMessage; -import org.apache.thrift.TException; -import org.codehaus.jackson.annotate.JsonProperty; - -/** - * JSON Implementation of CreateIndexMessage. - */ -public class JSONCreateIndexMessage extends CreateIndexMessage { - - @JsonProperty - String server, servicePrincipal, db, indexObjJson; - - @JsonProperty - Long timestamp; - - /** - * Default constructor, required for Jackson. - */ - public JSONCreateIndexMessage() {} - - public JSONCreateIndexMessage(String server, String servicePrincipal, Index index, Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.db = index.getDbName(); - try { - this.indexObjJson = JSONMessageFactory.createIndexObjJson(index); - } catch (TException ex) { - throw new IllegalArgumentException("Could not serialize Index object", ex); - } - - this.timestamp = timestamp; - checkValid(); - } - - @Override - public String getDB() { return db; } - - @Override - public String getServer() { return server; } - - @Override - public String getServicePrincipal() { return servicePrincipal; } - - @Override - public Long getTimestamp() { return timestamp; } - - public String getIndexObjJson() { - return indexObjJson; - } - - @Override - public Index getIndexObj() throws Exception { - return (Index) JSONMessageFactory.getTObj(indexObjJson, Index.class); - } - - @Override - public String toString() { - try { - return JSONMessageDeserializer.mapper.writeValueAsString(this); - } - catch (Exception exception) { - throw new IllegalArgumentException("Could not serialize: ", exception); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropIndexMessage.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropIndexMessage.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropIndexMessage.java deleted file mode 100644 index fb719c2..0000000 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropIndexMessage.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.hadoop.hive.metastore.messaging.json; - -import org.apache.hadoop.hive.metastore.api.Index; -import org.apache.hadoop.hive.metastore.messaging.DropIndexMessage; -import org.codehaus.jackson.annotate.JsonProperty; - -/** - * JSON Implementation of DropIndexMessage. - */ -public class JSONDropIndexMessage extends DropIndexMessage { - - @JsonProperty - String server, servicePrincipal, db, indexName, origTableName, indexTableName; - - @JsonProperty - Long timestamp; - - /** - * Default constructor, required for Jackson. - */ - public JSONDropIndexMessage() {} - - public JSONDropIndexMessage(String server, String servicePrincipal, Index index, Long timestamp) { - this.server = server; - this.servicePrincipal = servicePrincipal; - this.db = index.getDbName(); - this.indexName = index.getIndexName(); - this.origTableName = index.getOrigTableName(); - this.indexTableName = index.getIndexTableName(); - - this.timestamp = timestamp; - checkValid(); - } - - @Override - public String getDB() { return db; } - - @Override - public String getServer() { return server; } - - @Override - public String getServicePrincipal() { return servicePrincipal; } - - @Override - public Long getTimestamp() { return timestamp; } - - @Override - public String getIndexName() { - return indexName; - } - - @Override - public String getOrigTableName() { - return origTableName; - } - - @Override - public String getIndexTableName() { - return indexTableName; - } - - @Override - public String toString() { - try { - return JSONMessageDeserializer.mapper.writeValueAsString(this); - } - catch (Exception exception) { - throw new IllegalArgumentException("Could not serialize: ", exception); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageDeserializer.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageDeserializer.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageDeserializer.java index 34b62e6..a8ee691 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageDeserializer.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageDeserializer.java @@ -25,17 +25,14 @@ import org.apache.hadoop.hive.metastore.messaging.AddPartitionMessage; import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage; import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage; import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage; -import org.apache.hadoop.hive.metastore.messaging.AlterIndexMessage; import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage; import org.apache.hadoop.hive.metastore.messaging.AlterTableMessage; import org.apache.hadoop.hive.metastore.messaging.CreateDatabaseMessage; import org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage; -import org.apache.hadoop.hive.metastore.messaging.CreateIndexMessage; import org.apache.hadoop.hive.metastore.messaging.CreateTableMessage; import org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage; import org.apache.hadoop.hive.metastore.messaging.DropDatabaseMessage; import org.apache.hadoop.hive.metastore.messaging.DropFunctionMessage; -import org.apache.hadoop.hive.metastore.messaging.DropIndexMessage; import org.apache.hadoop.hive.metastore.messaging.DropPartitionMessage; import org.apache.hadoop.hive.metastore.messaging.DropTableMessage; import org.apache.hadoop.hive.metastore.messaging.InsertMessage; @@ -171,36 +168,6 @@ public class JSONMessageDeserializer extends MessageDeserializer { } @Override - public CreateIndexMessage getCreateIndexMessage(String messageBody) { - try { - return mapper.readValue(messageBody, JSONCreateIndexMessage.class); - } - catch (Exception exception) { - throw new IllegalArgumentException("Could not construct JSONCreateIndexMessage.", exception); - } - } - - @Override - public DropIndexMessage getDropIndexMessage(String messageBody) { - try { - return mapper.readValue(messageBody, JSONDropIndexMessage.class); - } - catch (Exception exception) { - throw new IllegalArgumentException("Could not construct JSONDropIndexMessage.", exception); - } - } - - @Override - public AlterIndexMessage getAlterIndexMessage(String messageBody) { - try { - return mapper.readValue(messageBody, JSONAlterIndexMessage.class); - } - catch (Exception exception) { - throw new IllegalArgumentException("Could not construct JSONAlterIndexMessage.", exception); - } - } - - @Override public InsertMessage getInsertMessage(String messageBody) { try { return mapper.readValue(messageBody, JSONInsertMessage.class); http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java index 7f46d07..4f03a27 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java @@ -30,7 +30,6 @@ import com.google.common.collect.Iterables; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.Function; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.NotificationEvent; import org.apache.hadoop.hive.metastore.api.Partition; import org.apache.hadoop.hive.metastore.api.SQLForeignKey; @@ -44,17 +43,14 @@ import org.apache.hadoop.hive.metastore.messaging.AddPartitionMessage; import org.apache.hadoop.hive.metastore.messaging.AddPrimaryKeyMessage; import org.apache.hadoop.hive.metastore.messaging.AddUniqueConstraintMessage; import org.apache.hadoop.hive.metastore.messaging.AlterDatabaseMessage; -import org.apache.hadoop.hive.metastore.messaging.AlterIndexMessage; import org.apache.hadoop.hive.metastore.messaging.AlterPartitionMessage; import org.apache.hadoop.hive.metastore.messaging.AlterTableMessage; import org.apache.hadoop.hive.metastore.messaging.CreateDatabaseMessage; import org.apache.hadoop.hive.metastore.messaging.CreateFunctionMessage; -import org.apache.hadoop.hive.metastore.messaging.CreateIndexMessage; import org.apache.hadoop.hive.metastore.messaging.CreateTableMessage; import org.apache.hadoop.hive.metastore.messaging.DropConstraintMessage; import org.apache.hadoop.hive.metastore.messaging.DropDatabaseMessage; import org.apache.hadoop.hive.metastore.messaging.DropFunctionMessage; -import org.apache.hadoop.hive.metastore.messaging.DropIndexMessage; import org.apache.hadoop.hive.metastore.messaging.DropPartitionMessage; import org.apache.hadoop.hive.metastore.messaging.DropTableMessage; import org.apache.hadoop.hive.metastore.messaging.InsertMessage; @@ -161,21 +157,6 @@ public class JSONMessageFactory extends MessageFactory { } @Override - public CreateIndexMessage buildCreateIndexMessage(Index idx) { - return new JSONCreateIndexMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, idx, now()); - } - - @Override - public DropIndexMessage buildDropIndexMessage(Index idx) { - return new JSONDropIndexMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, idx, now()); - } - - @Override - public AlterIndexMessage buildAlterIndexMessage(Index before, Index after) { - return new JSONAlterIndexMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, before, after, now()); - } - - @Override public InsertMessage buildInsertMessage(Table tableObj, Partition partObj, boolean replace, Iterator<String> fileIter) { return new JSONInsertMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, @@ -215,8 +196,9 @@ public class JSONMessageFactory extends MessageFactory { static Map<String, String> getPartitionKeyValues(Table table, Partition partition) { Map<String, String> partitionKeys = new LinkedHashMap<>(); - for (int i = 0; i < table.getPartitionKeysSize(); ++i) + for (int i = 0; i < table.getPartitionKeysSize(); ++i) { partitionKeys.put(table.getPartitionKeys().get(i).getName(), partition.getValues().get(i)); + } return partitionKeys; } @@ -271,11 +253,6 @@ public class JSONMessageFactory extends MessageFactory { return serializer.toString(functionObj, "UTF-8"); } - static String createIndexObjJson(Index indexObj) throws TException { - TSerializer serializer = new TSerializer(new TJSONProtocol.Factory()); - return serializer.toString(indexObj, "UTF-8"); - } - public static ObjectNode getJsonTree(NotificationEvent event) throws Exception { return getJsonTree(event.getMessage()); } http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java index 50f873a..b051961 100644 --- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java +++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java @@ -305,14 +305,6 @@ public class MetaStoreUtils { return new BigDecimal(new BigInteger(decimal.getUnscaled()), decimal.getScale()).doubleValue(); } - public static String[] getQualifiedName(String defaultDbName, String tableName) { - String[] names = tableName.split("\\."); - if (names.length == 1) { - return new String[] { defaultDbName, tableName}; - } - return names; - } - public static void validatePartitionNameCharacters(List<String> partVals, Pattern partitionValidationPattern) throws MetaException { @@ -355,7 +347,9 @@ public class MetaStoreUtils { for (FieldSchema fs : sd.getCols()) { md.update(fs.getName().getBytes(ENCODING)); md.update(fs.getType().getBytes(ENCODING)); - if (fs.getComment() != null) md.update(fs.getComment().getBytes(ENCODING)); + if (fs.getComment() != null) { + md.update(fs.getComment().getBytes(ENCODING)); + } } } if (sd.getInputFormat() != null) { @@ -384,7 +378,9 @@ public class MetaStoreUtils { } if (sd.getBucketCols() != null) { List<String> bucketCols = new ArrayList<>(sd.getBucketCols()); - for (String bucket : bucketCols) md.update(bucket.getBytes(ENCODING)); + for (String bucket : bucketCols) { + md.update(bucket.getBytes(ENCODING)); + } } if (sd.getSortCols() != null) { SortedSet<Order> orders = new TreeSet<>(sd.getSortCols()); @@ -397,7 +393,9 @@ public class MetaStoreUtils { SkewedInfo skewed = sd.getSkewedInfo(); if (skewed.getSkewedColNames() != null) { SortedSet<String> colnames = new TreeSet<>(skewed.getSkewedColNames()); - for (String colname : colnames) md.update(colname.getBytes(ENCODING)); + for (String colname : colnames) { + md.update(colname.getBytes(ENCODING)); + } } if (skewed.getSkewedColValues() != null) { SortedSet<String> sortedOuterList = new TreeSet<>(); @@ -405,7 +403,9 @@ public class MetaStoreUtils { SortedSet<String> sortedInnerList = new TreeSet<>(innerList); sortedOuterList.add(org.apache.commons.lang.StringUtils.join(sortedInnerList, ".")); } - for (String colval : sortedOuterList) md.update(colval.getBytes(ENCODING)); + for (String colval : sortedOuterList) { + md.update(colval.getBytes(ENCODING)); + } } if (skewed.getSkewedColValueLocationMaps() != null) { SortedMap<String, String> sortedMap = new TreeMap<>(); @@ -485,7 +485,9 @@ public class MetaStoreUtils { } private static String validateColumnType(String type) { - if (type.equals(TYPE_FROM_DESERIALIZER)) return null; + if (type.equals(TYPE_FROM_DESERIALIZER)) { + return null; + } int last = 0; boolean lastAlphaDigit = isValidTypeChar(type.charAt(last)); for (int i = 1; i <= type.length(); i++) { @@ -871,13 +873,6 @@ public class MetaStoreUtils { return (table.getParameters().get(hive_metastoreConstants.META_TABLE_STORAGE) != null); } - public static boolean isIndexTable(Table table) { - if (table == null) { - return false; - } - return TableType.INDEX_TABLE.toString().equals(table.getTableType()); - } - /** * Given a list of partition columns and a partial mapping from * some partition columns to values the function returns the values @@ -1593,9 +1588,13 @@ public class MetaStoreUtils { } public static WMPoolSchedulingPolicy parseSchedulingPolicy(String schedulingPolicy) { - if (schedulingPolicy == null) return WMPoolSchedulingPolicy.FAIR; + if (schedulingPolicy == null) { + return WMPoolSchedulingPolicy.FAIR; + } schedulingPolicy = schedulingPolicy.trim().toUpperCase(); - if ("DEFAULT".equals(schedulingPolicy)) return WMPoolSchedulingPolicy.FAIR; + if ("DEFAULT".equals(schedulingPolicy)) { + return WMPoolSchedulingPolicy.FAIR; + } return Enum.valueOf(WMPoolSchedulingPolicy.class, schedulingPolicy); } http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/main/thrift/hive_metastore.thrift ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/main/thrift/hive_metastore.thrift b/standalone-metastore/src/main/thrift/hive_metastore.thrift index e95014a..65e2f78 100644 --- a/standalone-metastore/src/main/thrift/hive_metastore.thrift +++ b/standalone-metastore/src/main/thrift/hive_metastore.thrift @@ -378,19 +378,6 @@ struct PartitionSpec { 5: optional PartitionListComposingSpec partitionList } -struct Index { - 1: string indexName, // unique with in the whole database namespace - 2: string indexHandlerClass, // reserved - 3: string dbName, - 4: string origTableName, - 5: i32 createTime, - 6: i32 lastAccessTime, - 7: string indexTableName, - 8: StorageDescriptor sd, - 9: map<string, string> parameters, - 10: bool deferredRebuild -} - // column statistics struct BooleanColumnStatsData { 1: required i64 numTrues, @@ -1365,10 +1352,6 @@ exception NoSuchObjectException { 1: string message } -exception IndexAlreadyExistsException { - 1: string message -} - exception InvalidOperationException { 1: string message } @@ -1699,21 +1682,6 @@ service ThriftHiveMetastore extends fb303.FacebookService 3: UnknownDBException o3, 4: UnknownTableException o4, 5: UnknownPartitionException o5, 6: InvalidPartitionException o6) - //index - Index add_index(1:Index new_index, 2: Table index_table) - throws(1:InvalidObjectException o1, 2:AlreadyExistsException o2, 3:MetaException o3) - void alter_index(1:string dbname, 2:string base_tbl_name, 3:string idx_name, 4:Index new_idx) - throws (1:InvalidOperationException o1, 2:MetaException o2) - bool drop_index_by_name(1:string db_name, 2:string tbl_name, 3:string index_name, 4:bool deleteData) - throws(1:NoSuchObjectException o1, 2:MetaException o2) - Index get_index_by_name(1:string db_name 2:string tbl_name, 3:string index_name) - throws(1:MetaException o1, 2:NoSuchObjectException o2) - - list<Index> get_indexes(1:string db_name, 2:string tbl_name, 3:i16 max_indexes=-1) - throws(1:NoSuchObjectException o1, 2:MetaException o2) - list<string> get_index_names(1:string db_name, 2:string tbl_name, 3:i16 max_indexes=-1) - throws(1:MetaException o2) - //primary keys and foreign keys PrimaryKeysResponse get_primary_keys(1:PrimaryKeysRequest request) throws(1:MetaException o1, 2:NoSuchObjectException o2) http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyListener.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyListener.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyListener.java index baecd12..570379d 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyListener.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyListener.java @@ -23,9 +23,7 @@ import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.api.MetaException; -import org.apache.hadoop.hive.metastore.events.AddIndexEvent; import org.apache.hadoop.hive.metastore.events.AddPartitionEvent; -import org.apache.hadoop.hive.metastore.events.AlterIndexEvent; import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterTableEvent; import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent; @@ -34,7 +32,6 @@ import org.apache.hadoop.hive.metastore.events.CreateFunctionEvent; import org.apache.hadoop.hive.metastore.events.CreateTableEvent; import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent; import org.apache.hadoop.hive.metastore.events.DropFunctionEvent; -import org.apache.hadoop.hive.metastore.events.DropIndexEvent; import org.apache.hadoop.hive.metastore.events.DropPartitionEvent; import org.apache.hadoop.hive.metastore.events.DropTableEvent; import org.apache.hadoop.hive.metastore.events.ListenerEvent; @@ -114,21 +111,6 @@ public class DummyListener extends MetaStoreEventListener{ } @Override - public void onAddIndex(AddIndexEvent indexEvent) throws MetaException { - addEvent(indexEvent); - } - - @Override - public void onDropIndex(DropIndexEvent indexEvent) throws MetaException { - addEvent(indexEvent); - } - - @Override - public void onAlterIndex(AlterIndexEvent indexEvent) throws MetaException { - addEvent(indexEvent); - } - - @Override public void onCreateFunction (CreateFunctionEvent fnEvent) throws MetaException { addEvent(fnEvent); } http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java index 8c0cc26..1c0eafd 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreControlledCommit.java @@ -38,7 +38,6 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.FileMetadataExprType; import org.apache.hadoop.hive.metastore.api.Function; import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; import org.apache.hadoop.hive.metastore.api.InvalidOperationException; @@ -318,41 +317,6 @@ public class DummyRawStoreControlledCommit implements RawStore, Configurable { } @Override - public boolean addIndex(Index index) throws InvalidObjectException, MetaException { - return objectStore.addIndex(index); - } - - @Override - public Index getIndex(String dbName, String origTableName, String indexName) - throws MetaException { - return objectStore.getIndex(dbName, origTableName, indexName); - } - - @Override - public boolean dropIndex(String dbName, String origTableName, String indexName) - throws MetaException { - return objectStore.dropIndex(dbName, origTableName, indexName); - } - - @Override - public List<Index> getIndexes(String dbName, String origTableName, int max) - throws MetaException { - return objectStore.getIndexes(dbName, origTableName, max); - } - - @Override - public List<String> listIndexNames(String dbName, String origTableName, short max) - throws MetaException { - return objectStore.listIndexNames(dbName, origTableName, max); - } - - @Override - public void alterIndex(String dbName, String baseTblName, String name, Index newIndex) - throws InvalidObjectException, MetaException { - objectStore.alterIndex(dbName, baseTblName, name, newIndex); - } - - @Override public List<Partition> getPartitionsByFilter(String dbName, String tblName, String filter, short maxParts) throws MetaException, NoSuchObjectException { return objectStore.getPartitionsByFilter(dbName, tblName, filter, maxParts); http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java index a0b2f98..cbd8678 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/DummyRawStoreForJdoConnection.java @@ -36,7 +36,6 @@ import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.FileMetadataExprType; import org.apache.hadoop.hive.metastore.api.Function; import org.apache.hadoop.hive.metastore.api.HiveObjectPrivilege; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.InvalidInputException; import org.apache.hadoop.hive.metastore.api.InvalidObjectException; import org.apache.hadoop.hive.metastore.api.InvalidOperationException; @@ -311,57 +310,11 @@ public class DummyRawStoreForJdoConnection implements RawStore { @Override public void alterPartition(String db_name, String tbl_name, List<String> part_vals, Partition new_part) throws InvalidObjectException, MetaException { - - } @Override public void alterPartitions(String db_name, String tbl_name, List<List<String>> part_vals_list, List<Partition> new_parts) throws InvalidObjectException, MetaException { - - - } - - - @Override - public boolean addIndex(Index index) throws InvalidObjectException, MetaException { - - return false; - } - - @Override - public Index getIndex(String dbName, String origTableName, String indexName) - throws MetaException { - - return null; - } - - @Override - public boolean dropIndex(String dbName, String origTableName, String indexName) - throws MetaException { - - return false; - } - - @Override - public List<Index> getIndexes(String dbName, String origTableName, int max) - throws MetaException { - - return null; - } - - @Override - public List<String> listIndexNames(String dbName, String origTableName, short max) - throws MetaException { - - return Collections.emptyList(); - } - - @Override - public void alterIndex(String dbname, String baseTblName, String name, Index newIndex) - throws InvalidObjectException, MetaException { - - } @Override @@ -842,6 +795,7 @@ public class DummyRawStoreForJdoConnection implements RawStore { return null; } + @Override public void flushCache() { } @@ -953,6 +907,7 @@ public class DummyRawStoreForJdoConnection implements RawStore { return null; } + @Override public List<String> addUniqueConstraints(List<SQLUniqueConstraint> uks) throws InvalidObjectException, MetaException { // TODO Auto-generated method stub http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java index 45a65e0..13ed743 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestFilterHooks.java @@ -27,14 +27,12 @@ import java.util.List; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest; import org.apache.hadoop.hive.metastore.api.Database; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.MetaException; import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; import org.apache.hadoop.hive.metastore.api.Partition; import org.apache.hadoop.hive.metastore.api.PartitionSpec; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder; -import org.apache.hadoop.hive.metastore.client.builder.IndexBuilder; import org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder; import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.conf.MetastoreConf; @@ -134,37 +132,12 @@ public class TestFilterHooks { return super.filterPartitionNames(dbName, tblName, partitionNames); } - @Override - public Index filterIndex(Index index) throws NoSuchObjectException { - if (blockResults) { - throw new NoSuchObjectException("Blocked access"); - } - return super.filterIndex(index); - } - - @Override - public List<String> filterIndexNames(String dbName, String tblName, - List<String> indexList) throws MetaException { - if (blockResults) { - return new ArrayList<>(); - } - return super.filterIndexNames(dbName, tblName, indexList); - } - - @Override - public List<Index> filterIndexes(List<Index> indexeList) throws MetaException { - if (blockResults) { - return new ArrayList<>(); - } - return super.filterIndexes(indexeList); - } } private static final String DBNAME1 = "testdb1"; private static final String DBNAME2 = "testdb2"; private static final String TAB1 = "tab1"; private static final String TAB2 = "tab2"; - private static final String INDEX1 = "idx1"; private static Configuration conf; private static HiveMetaStoreClient msc; @@ -217,13 +190,6 @@ public class TestFilterHooks { .addValue("value2") .build(); msc.add_partition(part2); - Index index = new IndexBuilder() - .setDbAndTableName(tab1) - .setIndexName(INDEX1) - .setDeferredRebuild(true) - .addCol("id", "int") - .build(); - msc.createIndex(index, new TableBuilder().fromIndex(index).build()); } @AfterClass @@ -234,8 +200,8 @@ public class TestFilterHooks { @Test public void testDefaultFilter() throws Exception { assertNotNull(msc.getTable(DBNAME1, TAB1)); - assertEquals(3, msc.getTables(DBNAME1, "*").size()); - assertEquals(3, msc.getAllTables(DBNAME1).size()); + assertEquals(2, msc.getTables(DBNAME1, "*").size()); + assertEquals(2, msc.getAllTables(DBNAME1).size()); assertEquals(1, msc.getTables(DBNAME1, TAB2).size()); assertEquals(0, msc.getAllTables(DBNAME2).size()); @@ -246,8 +212,6 @@ public class TestFilterHooks { assertNotNull(msc.getPartition(DBNAME1, TAB2, "name=value1")); assertEquals(1, msc.getPartitionsByNames(DBNAME1, TAB2, Lists.newArrayList("name=value1")).size()); - - assertNotNull(msc.getIndex(DBNAME1, TAB1, INDEX1)); } @Test @@ -291,15 +255,4 @@ public class TestFilterHooks { Lists.newArrayList("name=value1")).size()); } - @Test - public void testDummyFilterForIndex() throws Exception { - DummyMetaStoreFilterHookImpl.blockResults = true; - try { - assertNotNull(msc.getIndex(DBNAME1, TAB1, INDEX1)); - fail("getPartition() should fail with blocking mode"); - } catch (NoSuchObjectException e) { - // Excepted - } - } - } http://git-wip-us.apache.org/repos/asf/hive/blob/7c22d74c/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java ---------------------------------------------------------------------- diff --git a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java index 879e611..2a0b5b6 100644 --- a/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java +++ b/standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEventListener.java @@ -30,39 +30,31 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.FieldSchema; -import org.apache.hadoop.hive.metastore.api.Index; import org.apache.hadoop.hive.metastore.api.Partition; import org.apache.hadoop.hive.metastore.api.PartitionEventType; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder; -import org.apache.hadoop.hive.metastore.client.builder.IndexBuilder; import org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder; import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; import org.apache.hadoop.hive.metastore.conf.MetastoreConf; import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; -import org.apache.hadoop.hive.metastore.events.AddIndexEvent; import org.apache.hadoop.hive.metastore.events.AddPartitionEvent; -import org.apache.hadoop.hive.metastore.events.AlterIndexEvent; import org.apache.hadoop.hive.metastore.events.AlterPartitionEvent; import org.apache.hadoop.hive.metastore.events.AlterTableEvent; import org.apache.hadoop.hive.metastore.events.ConfigChangeEvent; import org.apache.hadoop.hive.metastore.events.CreateDatabaseEvent; import org.apache.hadoop.hive.metastore.events.CreateTableEvent; import org.apache.hadoop.hive.metastore.events.DropDatabaseEvent; -import org.apache.hadoop.hive.metastore.events.DropIndexEvent; import org.apache.hadoop.hive.metastore.events.DropPartitionEvent; import org.apache.hadoop.hive.metastore.events.DropTableEvent; import org.apache.hadoop.hive.metastore.events.ListenerEvent; import org.apache.hadoop.hive.metastore.events.LoadPartitionDoneEvent; -import org.apache.hadoop.hive.metastore.events.PreAddIndexEvent; import org.apache.hadoop.hive.metastore.events.PreAddPartitionEvent; -import org.apache.hadoop.hive.metastore.events.PreAlterIndexEvent; import org.apache.hadoop.hive.metastore.events.PreAlterPartitionEvent; import org.apache.hadoop.hive.metastore.events.PreAlterTableEvent; import org.apache.hadoop.hive.metastore.events.PreCreateDatabaseEvent; import org.apache.hadoop.hive.metastore.events.PreCreateTableEvent; import org.apache.hadoop.hive.metastore.events.PreDropDatabaseEvent; -import org.apache.hadoop.hive.metastore.events.PreDropIndexEvent; import org.apache.hadoop.hive.metastore.events.PreDropPartitionEvent; import org.apache.hadoop.hive.metastore.events.PreDropTableEvent; import org.apache.hadoop.hive.metastore.events.PreEventContext; @@ -79,7 +71,6 @@ import static org.junit.Assert.assertTrue; import com.google.common.collect.Lists; -import junit.framework.TestCase; import org.junit.experimental.categories.Category; /** @@ -202,29 +193,6 @@ public class TestMetaStoreEventListener { assertEquals(expectedDb, actualDb); } - private void validateIndex(Index expectedIndex, Index actualIndex) { - assertEquals(expectedIndex.getDbName(), actualIndex.getDbName()); - assertEquals(expectedIndex.getIndexName(), actualIndex.getIndexName()); - assertEquals(expectedIndex.getIndexHandlerClass(), actualIndex.getIndexHandlerClass()); - assertEquals(expectedIndex.getOrigTableName(), actualIndex.getOrigTableName()); - assertEquals(expectedIndex.getIndexTableName(), actualIndex.getIndexTableName()); - assertEquals(expectedIndex.getSd().getLocation(), actualIndex.getSd().getLocation()); - } - - private void validateAddIndex(Index expectedIndex, Index actualIndex) { - validateIndex(expectedIndex, actualIndex); - } - - private void validateAlterIndex(Index expectedOldIndex, Index actualOldIndex, - Index expectedNewIndex, Index actualNewIndex) { - validateIndex(expectedOldIndex, actualOldIndex); - validateIndex(expectedNewIndex, actualNewIndex); - } - - private void validateDropIndex(Index expectedIndex, Index actualIndex) { - validateIndex(expectedIndex, actualIndex); - } - @Test public void testListener() throws Exception { int listSize = 0; @@ -266,59 +234,6 @@ public class TestMetaStoreEventListener { Assert.assertTrue(tblEvent.getStatus()); validateCreateTable(tbl, tblEvent.getTable()); - String indexName = "tmptbl_i"; - Index index = new IndexBuilder() - .setDbAndTableName(table) - .setIndexName(indexName) - .addCol("a", "string") - .setDeferredRebuild(true) - .addIndexParam("prop1", "val1") - .addIndexParam("prop2", "val2") - .build(); - Table indexTable = new TableBuilder() - .fromIndex(index) - .build(); - msc.createIndex(index, indexTable); - listSize += 2; // creates index table internally - assertEquals(notifyList.size(), listSize); - - AddIndexEvent addIndexEvent = (AddIndexEvent)notifyList.get(listSize - 1); - Assert.assertTrue(addIndexEvent.getStatus()); - PreAddIndexEvent preAddIndexEvent = (PreAddIndexEvent)(preNotifyList.get(preNotifyList.size() - 2)); - - Index oldIndex = msc.getIndex(dbName, tblName, indexName); - - validateAddIndex(oldIndex, addIndexEvent.getIndex()); - - validateAddIndex(oldIndex, preAddIndexEvent.getIndex()); - - Index alteredIndex = new Index(oldIndex); - alteredIndex.getParameters().put("prop3", "val3"); - msc.alter_index(dbName, tblName, indexName, alteredIndex); - listSize++; - assertEquals(notifyList.size(), listSize); - - Index newIndex = msc.getIndex(dbName, tblName, indexName); - - AlterIndexEvent alterIndexEvent = (AlterIndexEvent) notifyList.get(listSize - 1); - Assert.assertTrue(alterIndexEvent.getStatus()); - validateAlterIndex(oldIndex, alterIndexEvent.getOldIndex(), - newIndex, alterIndexEvent.getNewIndex()); - - PreAlterIndexEvent preAlterIndexEvent = (PreAlterIndexEvent) (preNotifyList.get(preNotifyList.size() - 1)); - validateAlterIndex(oldIndex, preAlterIndexEvent.getOldIndex(), - newIndex, preAlterIndexEvent.getNewIndex()); - - msc.dropIndex(dbName, tblName, indexName, true); - listSize++; - assertEquals(notifyList.size(), listSize); - - DropIndexEvent dropIndexEvent = (DropIndexEvent) notifyList.get(listSize - 1); - Assert.assertTrue(dropIndexEvent.getStatus()); - validateDropIndex(newIndex, dropIndexEvent.getIndex()); - - PreDropIndexEvent preDropIndexEvent = (PreDropIndexEvent) (preNotifyList.get(preNotifyList.size() - 1)); - validateDropIndex(newIndex, preDropIndexEvent.getIndex()); Partition part = new PartitionBuilder() .fromTable(table)