Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix enum name in CountingAccessHiveMetastore #17244

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@
public class CountingAccessMetadata
implements Metadata
{
public enum Methods
public enum Method
{
GET_TABLE_STATISTICS,
}

private final Metadata delegate;
private final ConcurrentHashMultiset<Methods> methodInvocations = ConcurrentHashMultiset.create();
private final ConcurrentHashMultiset<Method> methodInvocations = ConcurrentHashMultiset.create();

public CountingAccessMetadata(Metadata delegate)
{
this.delegate = delegate;
}

public Multiset<Methods> getMethodInvocations()
public Multiset<Method> getMethodInvocations()
{
return ImmutableMultiset.copyOf(methodInvocations);
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public TableMetadata getTableMetadata(Session session, TableHandle tableHandle)
@Override
public TableStatistics getTableStatistics(Session session, TableHandle tableHandle)
{
methodInvocations.add(Methods.GET_TABLE_STATISTICS);
methodInvocations.add(Method.GET_TABLE_STATISTICS);
return delegate.getTableStatistics(session, tableHandle);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import java.util.Optional;

import static io.trino.plugin.deltalake.DeltaLakeQueryRunner.DELTA_CATALOG;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE;
import static io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.testing.TestingSession.testSessionBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import java.io.File;
import java.util.Optional;

import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.CREATE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.DROP_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.CREATE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.DROP_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE;
import static io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static java.util.Objects.requireNonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@
import java.util.Set;
import java.util.function.Function;

import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_ALL_TABLES_FROM_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_ALL_VIEWS_FROM_DATABASE;

@ThreadSafe
public class CountingAccessHiveMetastore
implements HiveMetastore
{
public enum Methods
public enum Method
{
CREATE_DATABASE,
CREATE_TABLE,
Expand All @@ -63,14 +60,14 @@ public enum Methods
}

private final HiveMetastore delegate;
private final ConcurrentHashMultiset<Methods> methodInvocations = ConcurrentHashMultiset.create();
private final ConcurrentHashMultiset<Method> methodInvocations = ConcurrentHashMultiset.create();

public CountingAccessHiveMetastore(HiveMetastore delegate)
{
this.delegate = delegate;
}

public Multiset<Methods> getMethodInvocations()
public Multiset<Method> getMethodInvocations()
{
return ImmutableMultiset.copyOf(methodInvocations);
}
Expand All @@ -83,7 +80,7 @@ public void resetCounters()
@Override
public Optional<Table> getTable(String databaseName, String tableName)
{
methodInvocations.add(Methods.GET_TABLE);
methodInvocations.add(Method.GET_TABLE);
return delegate.getTable(databaseName, tableName);
}

Expand All @@ -97,35 +94,35 @@ public Set<HiveColumnStatisticType> getSupportedColumnStatistics(Type type)
@Override
public List<String> getAllDatabases()
{
methodInvocations.add(Methods.GET_ALL_DATABASES);
methodInvocations.add(Method.GET_ALL_DATABASES);
return delegate.getAllDatabases();
}

@Override
public Optional<Database> getDatabase(String databaseName)
{
methodInvocations.add(Methods.GET_DATABASE);
methodInvocations.add(Method.GET_DATABASE);
return delegate.getDatabase(databaseName);
}

@Override
public List<String> getTablesWithParameter(String databaseName, String parameterKey, String parameterValue)
{
methodInvocations.add(Methods.GET_TABLE_WITH_PARAMETER);
methodInvocations.add(Method.GET_TABLE_WITH_PARAMETER);
return delegate.getTablesWithParameter(databaseName, parameterKey, parameterValue);
}

@Override
public List<String> getAllViews(String databaseName)
{
methodInvocations.add(GET_ALL_VIEWS_FROM_DATABASE);
methodInvocations.add(Method.GET_ALL_VIEWS_FROM_DATABASE);
return delegate.getAllViews(databaseName);
}

@Override
public void createDatabase(Database database)
{
methodInvocations.add(Methods.CREATE_DATABASE);
methodInvocations.add(Method.CREATE_DATABASE);
delegate.createDatabase(database);
}

Expand All @@ -150,21 +147,21 @@ public void setDatabaseOwner(String databaseName, HivePrincipal principal)
@Override
public void createTable(Table table, PrincipalPrivileges principalPrivileges)
{
methodInvocations.add(Methods.CREATE_TABLE);
methodInvocations.add(Method.CREATE_TABLE);
delegate.createTable(table, principalPrivileges);
}

@Override
public void dropTable(String databaseName, String tableName, boolean deleteData)
{
methodInvocations.add(Methods.DROP_TABLE);
methodInvocations.add(Method.DROP_TABLE);
delegate.dropTable(databaseName, tableName, deleteData);
}

@Override
public void replaceTable(String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges)
{
methodInvocations.add(Methods.REPLACE_TABLE);
methodInvocations.add(Method.REPLACE_TABLE);
delegate.replaceTable(databaseName, tableName, newTable, principalPrivileges);
}

Expand Down Expand Up @@ -213,7 +210,7 @@ public void dropColumn(String databaseName, String tableName, String columnName)
@Override
public Optional<Partition> getPartition(Table table, List<String> partitionValues)
{
methodInvocations.add(Methods.GET_PARTITION);
methodInvocations.add(Method.GET_PARTITION);
return delegate.getPartition(table, partitionValues);
}

Expand All @@ -223,21 +220,21 @@ public Optional<List<String>> getPartitionNamesByFilter(String databaseName,
List<String> columnNames,
TupleDomain<String> partitionKeysFilter)
{
methodInvocations.add(Methods.GET_PARTITION_NAMES_BY_FILTER);
methodInvocations.add(Method.GET_PARTITION_NAMES_BY_FILTER);
return delegate.getPartitionNamesByFilter(databaseName, tableName, columnNames, partitionKeysFilter);
}

@Override
public Map<String, Optional<Partition>> getPartitionsByNames(Table table, List<String> partitionNames)
{
methodInvocations.add(Methods.GET_PARTITIONS_BY_NAMES);
methodInvocations.add(Method.GET_PARTITIONS_BY_NAMES);
return delegate.getPartitionsByNames(table, partitionNames);
}

@Override
public void addPartitions(String databaseName, String tableName, List<PartitionWithStatistics> partitions)
{
methodInvocations.add(Methods.ADD_PARTITIONS);
methodInvocations.add(Method.ADD_PARTITIONS);
delegate.addPartitions(databaseName, tableName, partitions);
}

Expand Down Expand Up @@ -316,14 +313,14 @@ public Set<HivePrivilegeInfo> listTablePrivileges(String databaseName, String ta
@Override
public PartitionStatistics getTableStatistics(Table table)
{
methodInvocations.add(Methods.GET_TABLE_STATISTICS);
methodInvocations.add(Method.GET_TABLE_STATISTICS);
return delegate.getTableStatistics(table);
}

@Override
public Map<String, PartitionStatistics> getPartitionStatistics(Table table, List<Partition> partitions)
{
methodInvocations.add(Methods.GET_PARTITION_STATISTICS);
methodInvocations.add(Method.GET_PARTITION_STATISTICS);
return delegate.getPartitionStatistics(table, partitions);
}

Expand All @@ -333,21 +330,21 @@ public void updateTableStatistics(String databaseName,
AcidTransaction transaction,
Function<PartitionStatistics, PartitionStatistics> update)
{
methodInvocations.add(Methods.UPDATE_TABLE_STATISTICS);
methodInvocations.add(Method.UPDATE_TABLE_STATISTICS);
delegate.updateTableStatistics(databaseName, tableName, transaction, update);
}

@Override
public void updatePartitionStatistics(Table table, Map<String, Function<PartitionStatistics, PartitionStatistics>> updates)
{
methodInvocations.add(Methods.UPDATE_PARTITION_STATISTICS);
methodInvocations.add(Method.UPDATE_PARTITION_STATISTICS);
delegate.updatePartitionStatistics(table, updates);
}

@Override
public List<String> getAllTables(String databaseName)
{
methodInvocations.add(GET_ALL_TABLES_FROM_DATABASE);
methodInvocations.add(Method.GET_ALL_TABLES_FROM_DATABASE);
return delegate.getAllTables(databaseName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void assertMetastoreInvocations(
{
metastore.resetCounters();
queryRunner.execute(session, query);
Multiset<CountingAccessHiveMetastore.Methods> actualInvocations = metastore.getMethodInvocations();
Multiset<CountingAccessHiveMetastore.Method> actualInvocations = metastore.getMethodInvocations();

if (expectedInvocations.equals(actualInvocations)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@

import java.io.File;

import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.CREATE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_PARTITIONS_BY_NAMES;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_PARTITION_NAMES_BY_FILTER;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_PARTITION_STATISTICS;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_TABLE_STATISTICS;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.UPDATE_PARTITION_STATISTICS;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.UPDATE_TABLE_STATISTICS;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.CREATE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_PARTITIONS_BY_NAMES;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_PARTITION_NAMES_BY_FILTER;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_PARTITION_STATISTICS;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE_STATISTICS;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.UPDATE_PARTITION_STATISTICS;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.UPDATE_TABLE_STATISTICS;
import static io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore;
import static io.trino.testing.TestingSession.testSessionBuilder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.trino.plugin.hive.TestingHivePlugin;
import io.trino.plugin.hive.metastore.Column;
import io.trino.plugin.hive.metastore.CountingAccessHiveMetastore;
import io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods;
import io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method;
import io.trino.plugin.hive.metastore.CountingAccessHiveMetastoreUtil;
import io.trino.plugin.hive.metastore.Database;
import io.trino.plugin.hive.metastore.Table;
Expand All @@ -39,10 +39,10 @@
import static io.trino.connector.informationschema.InformationSchemaMetadata.MAX_PREFIXES_COUNT;
import static io.trino.plugin.hive.HiveStorageFormat.ORC;
import static io.trino.plugin.hive.TableType.MANAGED_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_ALL_DATABASES;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_ALL_TABLES_FROM_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_ALL_VIEWS_FROM_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_ALL_DATABASES;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_ALL_TABLES_FROM_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_ALL_VIEWS_FROM_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE;
import static io.trino.plugin.hive.metastore.PrincipalPrivileges.NO_PRIVILEGES;
import static io.trino.plugin.hive.metastore.StorageFormat.fromHiveStorageFormat;
import static io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore;
Expand Down Expand Up @@ -374,7 +374,7 @@ public void testSelectColumnsFilterByTableName()
{
metastore.resetCounters();
computeActual("SELECT * FROM information_schema.columns WHERE table_name = 'test_table_0'");
Multiset<Methods> invocations = metastore.getMethodInvocations();
Multiset<Method> invocations = metastore.getMethodInvocations();

assertThat(invocations.count(GET_TABLE)).as("GET_TABLE invocations")
// some lengthy explanatory comment why variable count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public void testTwoWayJoin()
"FROM iceberg.tiny.orders o, iceberg.tiny.lineitem l " +
"WHERE o.orderkey = l.orderkey");
assertThat(metadata.getMethodInvocations()).containsExactlyInAnyOrderElementsOf(
ImmutableMultiset.<CountingAccessMetadata.Methods>builder()
.addCopies(CountingAccessMetadata.Methods.GET_TABLE_STATISTICS, 2)
ImmutableMultiset.<CountingAccessMetadata.Method>builder()
.addCopies(CountingAccessMetadata.Method.GET_TABLE_STATISTICS, 2)
.build());
}

Expand All @@ -128,8 +128,8 @@ public void testThreeWayJoin()
"FROM iceberg.tiny.customer c, iceberg.tiny.orders o, iceberg.tiny.lineitem l " +
"WHERE o.orderkey = l.orderkey AND c.custkey = o.custkey");
assertThat(metadata.getMethodInvocations()).containsExactlyInAnyOrderElementsOf(
ImmutableMultiset.<CountingAccessMetadata.Methods>builder()
.addCopies(CountingAccessMetadata.Methods.GET_TABLE_STATISTICS, 3)
ImmutableMultiset.<CountingAccessMetadata.Method>builder()
.addCopies(CountingAccessMetadata.Method.GET_TABLE_STATISTICS, 3)
.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import java.util.Optional;

import static com.google.inject.util.Modules.EMPTY_MODULE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.CREATE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.DROP_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Methods.REPLACE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.CREATE_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.DROP_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_DATABASE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.GET_TABLE;
import static io.trino.plugin.hive.metastore.CountingAccessHiveMetastore.Method.REPLACE_TABLE;
import static io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore;
import static io.trino.plugin.iceberg.IcebergSessionProperties.COLLECT_EXTENDED_STATISTICS_ON_WRITE;
import static io.trino.plugin.iceberg.TableType.DATA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void testTwoWayJoin()
"FROM tpch.tiny.orders o, tpch.tiny.lineitem l " +
"WHERE o.orderkey = l.orderkey");
assertThat(metadata.getMethodInvocations()).containsExactlyInAnyOrderElementsOf(
ImmutableMultiset.<CountingAccessMetadata.Methods>builder()
.addCopies(CountingAccessMetadata.Methods.GET_TABLE_STATISTICS, 2)
ImmutableMultiset.<CountingAccessMetadata.Method>builder()
.addCopies(CountingAccessMetadata.Method.GET_TABLE_STATISTICS, 2)
.build());
}

Expand All @@ -87,8 +87,8 @@ public void testThreeWayJoin()
"FROM tpch.tiny.customer c, tpch.tiny.orders o, tpch.tiny.lineitem l " +
"WHERE o.orderkey = l.orderkey AND c.custkey = o.custkey");
assertThat(metadata.getMethodInvocations()).containsExactlyInAnyOrderElementsOf(
ImmutableMultiset.<CountingAccessMetadata.Methods>builder()
.addCopies(CountingAccessMetadata.Methods.GET_TABLE_STATISTICS, 3)
ImmutableMultiset.<CountingAccessMetadata.Method>builder()
.addCopies(CountingAccessMetadata.Method.GET_TABLE_STATISTICS, 3)
.build());
}

Expand Down