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

Revert "Reduce redundant code in procedure declarations" #18619

Merged
merged 1 commit into from
Aug 10, 2023
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@
import java.lang.invoke.MethodHandle;
import java.util.Optional;

import static io.trino.plugin.base.util.Reflection.methodHandle;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class FlushJdbcMetadataCacheProcedure
implements Provider<Procedure>
{
private static final MethodHandle FLUSH_JDBC_METADATA_CACHE = methodHandle(FlushJdbcMetadataCacheProcedure.class, "flushMetadataCache");
private static final MethodHandle FLUSH_JDBC_METADATA_CACHE;

static {
try {
FLUSH_JDBC_METADATA_CACHE = lookup().unreflect(FlushJdbcMetadataCacheProcedure.class.getMethod("flushMetadataCache"));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final CachingJdbcClient cachingJdbcClient;
private final Optional<CachingIdentifierMapping> cachingIdentifierMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,25 @@
import java.util.List;

import static io.trino.plugin.base.util.Procedures.checkProcedureArgument;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.spi.StandardErrorCode.INVALID_PROCEDURE_ARGUMENT;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class DropExtendedStatsProcedure
implements Provider<Procedure>
{
private static final MethodHandle PROCEDURE_METHOD = methodHandle(DropExtendedStatsProcedure.class, "dropStats", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class);
private static final MethodHandle PROCEDURE_METHOD;

static {
try {
PROCEDURE_METHOD = lookup().unreflect(DropExtendedStatsProcedure.class.getMethod("dropStats", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final DeltaLakeMetadataFactory metadataFactory;
private final ExtendedStatisticsAccess statsAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import java.lang.invoke.MethodHandle;
import java.util.Optional;

import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.spi.StandardErrorCode.INVALID_PROCEDURE_ARGUMENT;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class FlushMetadataCacheProcedure
Expand All @@ -40,7 +40,16 @@ public class FlushMetadataCacheProcedure
private static final String PARAM_SCHEMA_NAME = "SCHEMA_NAME";
private static final String PARAM_TABLE_NAME = "TABLE_NAME";

private static final MethodHandle FLUSH_METADATA_CACHE = methodHandle(FlushMetadataCacheProcedure.class, "flushMetadataCache", String.class, String.class);
private static final MethodHandle FLUSH_METADATA_CACHE;

static {
try {
FLUSH_METADATA_CACHE = lookup().unreflect(FlushMetadataCacheProcedure.class.getMethod("flushMetadataCache", String.class, String.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final Optional<CachingHiveMetastore> cachingHiveMetastore;
private final TransactionLogAccess transactionLogAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

import static com.google.common.base.Strings.isNullOrEmpty;
import static io.trino.plugin.base.util.Procedures.checkProcedureArgument;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.plugin.deltalake.DeltaLakeErrorCode.DELTA_LAKE_FILESYSTEM_ERROR;
import static io.trino.plugin.deltalake.DeltaLakeErrorCode.DELTA_LAKE_INVALID_TABLE;
import static io.trino.plugin.deltalake.DeltaLakeMetadata.buildTable;
Expand All @@ -50,12 +49,13 @@
import static io.trino.spi.StandardErrorCode.PERMISSION_DENIED;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class RegisterTableProcedure
implements Provider<Procedure>
{
private static final MethodHandle REGISTER_TABLE = methodHandle(RegisterTableProcedure.class, "registerTable", ConnectorSession.class, String.class, String.class, String.class);
private static final MethodHandle REGISTER_TABLE;

private static final String PROCEDURE_NAME = "register_table";
private static final String SYSTEM_SCHEMA = "system";
Expand All @@ -64,6 +64,15 @@ public class RegisterTableProcedure
private static final String TABLE_NAME = "TABLE_NAME";
private static final String TABLE_LOCATION = "TABLE_LOCATION";

static {
try {
REGISTER_TABLE = lookup().unreflect(RegisterTableProcedure.class.getMethod("registerTable", ConnectorSession.class, String.class, String.class, String.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final DeltaLakeMetadataFactory metadataFactory;
private final TransactionLogAccess transactionLogAccess;
private final CachingExtendedStatisticsAccess statisticsAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,30 @@

import static com.google.common.base.Strings.isNullOrEmpty;
import static io.trino.plugin.base.util.Procedures.checkProcedureArgument;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class UnregisterTableProcedure
implements Provider<Procedure>
{
private static final MethodHandle UNREGISTER_TABLE = methodHandle(UnregisterTableProcedure.class, "unregisterTable", ConnectorAccessControl.class, ConnectorSession.class, String.class, String.class);
private static final MethodHandle UNREGISTER_TABLE;

private static final String PROCEDURE_NAME = "unregister_table";
private static final String SYSTEM_SCHEMA = "system";

private static final String SCHEMA_NAME = "SCHEMA_NAME";
private static final String TABLE_NAME = "TABLE_NAME";

static {
try {
UNREGISTER_TABLE = lookup().unreflect(UnregisterTableProcedure.class.getMethod("unregisterTable", ConnectorAccessControl.class, ConnectorSession.class, String.class, String.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final DeltaLakeMetadataFactory metadataFactory;
private final TransactionLogAccess transactionLogAccess;
private final CachingExtendedStatisticsAccess statisticsAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static io.trino.plugin.base.util.Procedures.checkProcedureArgument;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.plugin.deltalake.DeltaLakeMetadata.MAX_WRITER_VERSION;
import static io.trino.plugin.deltalake.DeltaLakeMetadata.checkValidTableHandle;
import static io.trino.plugin.deltalake.DeltaLakeSessionProperties.getVacuumMinRetention;
Expand All @@ -66,6 +65,7 @@
import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Comparator.naturalOrder;
import static java.util.Objects.requireNonNull;

Expand All @@ -75,7 +75,16 @@ public class VacuumProcedure
private static final Logger log = Logger.get(VacuumProcedure.class);
private static final int DELETE_BATCH_SIZE = 1000;

private static final MethodHandle VACUUM = methodHandle(VacuumProcedure.class, "vacuum", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, String.class);
private static final MethodHandle VACUUM;

static {
try {
VACUUM = lookup().unreflect(VacuumProcedure.class.getMethod("vacuum", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, String.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final CatalogName catalogName;
private final TrinoFileSystemFactory fileSystemFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import java.util.Optional;

import static com.google.common.base.Preconditions.checkState;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -69,8 +69,17 @@ public class FlushMetadataCacheProcedure
PARAM_PARTITION_COLUMN.toLowerCase(ENGLISH),
PARAM_PARTITION_VALUE.toLowerCase(ENGLISH));

private static final MethodHandle FLUSH_HIVE_METASTORE_CACHE = methodHandle(FlushMetadataCacheProcedure.class,
"flushMetadataCache", String.class, String.class, List.class, List.class, List.class, List.class);
private static final MethodHandle FLUSH_HIVE_METASTORE_CACHE;

static {
try {
FLUSH_HIVE_METASTORE_CACHE = lookup().unreflect(FlushMetadataCacheProcedure.class.getMethod(
"flushMetadataCache", String.class, String.class, List.class, List.class, List.class, List.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final Optional<CachingHiveMetastore> cachingHiveMetastore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@
import java.io.IOException;
import java.lang.invoke.MethodHandle;

import static io.trino.plugin.base.util.Reflection.methodHandle;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class WriteHiveMetastoreRecordingProcedure
implements Provider<Procedure>
{
private static final MethodHandle WRITE_HIVE_METASTORE_RECORDING = methodHandle(WriteHiveMetastoreRecordingProcedure.class, "writeHiveMetastoreRecording");
private static final MethodHandle WRITE_HIVE_METASTORE_RECORDING;

static {
try {
WRITE_HIVE_METASTORE_RECORDING = lookup().unreflect(WriteHiveMetastoreRecordingProcedure.class.getMethod("writeHiveMetastoreRecording"));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final RateLimiter rateLimiter = RateLimiter.create(0.2);
private final HiveMetastoreRecording hiveMetastoreRecording;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,28 @@

import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.plugin.base.util.Procedures.checkProcedureArgument;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.plugin.hive.util.HiveUtil.makePartName;
import static io.trino.spi.StandardErrorCode.ALREADY_EXISTS;
import static io.trino.spi.StandardErrorCode.INVALID_PROCEDURE_ARGUMENT;
import static io.trino.spi.connector.RetryMode.NO_RETRIES;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class CreateEmptyPartitionProcedure
implements Provider<Procedure>
{
private static final MethodHandle CREATE_EMPTY_PARTITION = methodHandle(CreateEmptyPartitionProcedure.class, "createEmptyPartition", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, List.class, List.class);
private static final MethodHandle CREATE_EMPTY_PARTITION;

static {
try {
CREATE_EMPTY_PARTITION = lookup().unreflect(CreateEmptyPartitionProcedure.class.getMethod("createEmptyPartition", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, List.class, List.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final TransactionalMetadataFactory hiveMetadataFactory;
private final LocationService locationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@

import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.plugin.base.util.Procedures.checkProcedureArgument;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.plugin.hive.acid.AcidTransaction.NO_ACID_TRANSACTION;
import static io.trino.plugin.hive.util.HiveUtil.makePartName;
import static io.trino.spi.StandardErrorCode.INVALID_PROCEDURE_ARGUMENT;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

/**
Expand All @@ -55,7 +55,16 @@
public class DropStatsProcedure
implements Provider<Procedure>
{
private static final MethodHandle DROP_STATS = methodHandle(DropStatsProcedure.class, "dropStats", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, List.class);
private static final MethodHandle DROP_STATS;

static {
try {
DROP_STATS = lookup().unreflect(DropStatsProcedure.class.getMethod("dropStats", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, List.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final TransactionalMetadataFactory hiveMetadataFactory;

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

import static io.trino.plugin.base.util.Procedures.checkProcedureArgument;
import static io.trino.plugin.base.util.Reflection.methodHandle;
import static io.trino.plugin.hive.HiveMetadata.PRESTO_QUERY_ID_NAME;
import static io.trino.plugin.hive.procedure.Procedures.checkIsPartitionedTable;
import static io.trino.plugin.hive.procedure.Procedures.checkPartitionColumns;
Expand All @@ -52,12 +51,22 @@
import static io.trino.spi.StandardErrorCode.PERMISSION_DENIED;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Objects.requireNonNull;

public class RegisterPartitionProcedure
implements Provider<Procedure>
{
private static final MethodHandle REGISTER_PARTITION = methodHandle(RegisterPartitionProcedure.class, "registerPartition", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, List.class, List.class, String.class);
private static final MethodHandle REGISTER_PARTITION;

static {
try {
REGISTER_PARTITION = lookup().unreflect(RegisterPartitionProcedure.class.getMethod("registerPartition", ConnectorSession.class, ConnectorAccessControl.class, String.class, String.class, List.class, List.class, String.class));
}
catch (ReflectiveOperationException e) {
throw new AssertionError(e);
}
}

private final boolean allowRegisterPartition;
private final TransactionalMetadataFactory hiveMetadataFactory;
Expand Down
Loading