Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Licensed 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 com.facebook.presto.hive.metastore;
import com.facebook.presto.common.NotSupportedException;
import com.facebook.presto.common.predicate.Domain;
import com.facebook.presto.common.type.Type;
import com.facebook.presto.hive.HiveTableHandle;
import com.facebook.presto.hive.HiveType;
import com.facebook.presto.hive.PartitionNameWithVersion;
import com.facebook.presto.spi.constraints.TableConstraint;
import com.facebook.presto.spi.security.PrestoPrincipal;
import com.facebook.presto.spi.security.RoleGrant;
import com.facebook.presto.spi.statistics.ColumnStatisticType;
import com.google.common.collect.ImmutableList;
import io.airlift.units.Duration;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
public interface ExtendedHiveMetastore
{
Optional getDatabase(MetastoreContext metastoreContext, String databaseName);
List getAllDatabases(MetastoreContext metastoreContext);
Optional
getTable(MetastoreContext metastoreContext, String databaseName, String tableName);
/*
If some extended hiveMetastore wants to get additional information available in the HiveTableHandle
they can override this method to get the additional information.
*/
default Optional
getTable(MetastoreContext metastoreContext, HiveTableHandle hiveTableHandle)
{
return getTable(metastoreContext, hiveTableHandle.getSchemaName(), hiveTableHandle.getTableName());
}
Set getSupportedColumnStatistics(MetastoreContext metastoreContext, Type type);
PartitionStatistics getTableStatistics(MetastoreContext metastoreContext, String databaseName, String tableName);
Map getPartitionStatistics(MetastoreContext metastoreContext, String databaseName, String tableName, Set partitionNames);
void updateTableStatistics(MetastoreContext metastoreContext, String databaseName, String tableName, Function update);
void updatePartitionStatistics(MetastoreContext metastoreContext, String databaseName, String tableName, String partitionName, Function update);
Optional> getAllTables(MetastoreContext metastoreContext, String databaseName);
Optional> getAllViews(MetastoreContext metastoreContext, String databaseName);
void createDatabase(MetastoreContext metastoreContext, Database database);
void dropDatabase(MetastoreContext metastoreContext, String databaseName);
void renameDatabase(MetastoreContext metastoreContext, String databaseName, String newDatabaseName);
MetastoreOperationResult createTable(MetastoreContext metastoreContext, Table table, PrincipalPrivileges principalPrivileges, List> constraints);
void dropTable(MetastoreContext metastoreContext, String databaseName, String tableName, boolean deleteData);
/**
* Drop table from the metastore, but preserve the data. If no override
* is available, default to dropTable with deleteData set to false.
*/
default void dropTableFromMetastore(MetastoreContext metastoreContext, String databaseName, String tableName)
{
dropTable(metastoreContext, databaseName, tableName, false);
}
/**
* This should only be used if the semantic here is drop and add. Trying to
* alter one field of a table object previously acquired from getTable is
* probably not what you want.
*/
MetastoreOperationResult replaceTable(MetastoreContext metastoreContext, String databaseName, String tableName, Table newTable, PrincipalPrivileges principalPrivileges);
MetastoreOperationResult renameTable(MetastoreContext metastoreContext, String databaseName, String tableName, String newDatabaseName, String newTableName);
MetastoreOperationResult addColumn(MetastoreContext metastoreContext, String databaseName, String tableName, String columnName, HiveType columnType, String columnComment);
MetastoreOperationResult renameColumn(MetastoreContext metastoreContext, String databaseName, String tableName, String oldColumnName, String newColumnName);
MetastoreOperationResult dropColumn(MetastoreContext metastoreContext, String databaseName, String tableName, String columnName);
Optional getPartition(MetastoreContext metastoreContext, String databaseName, String tableName, List partitionValues);
Optional> getPartitionNames(MetastoreContext metastoreContext, String databaseName, String tableName);
List getPartitionNamesByFilter(
MetastoreContext metastoreContext,
String databaseName,
String tableName,
Map partitionPredicates);
List getPartitionNamesWithVersionByFilter(
MetastoreContext metastoreContext,
String databaseName,
String tableName,
Map partitionPredicates);
Map> getPartitionsByNames(MetastoreContext metastoreContext, String databaseName, String tableName, List partitionNames);
MetastoreOperationResult addPartitions(MetastoreContext metastoreContext, String databaseName, String tableName, List partitions);
void dropPartition(MetastoreContext metastoreContext, String databaseName, String tableName, List parts, boolean deleteData);
MetastoreOperationResult alterPartition(MetastoreContext metastoreContext, String databaseName, String tableName, PartitionWithStatistics partition);
void createRole(MetastoreContext metastoreContext, String role, String grantor);
void dropRole(MetastoreContext metastoreContext, String role);
Set listRoles(MetastoreContext metastoreContext);
void grantRoles(MetastoreContext metastoreContext, Set roles, Set grantees, boolean withAdminOption, PrestoPrincipal grantor);
void revokeRoles(MetastoreContext metastoreContext, Set roles, Set grantees, boolean adminOptionFor, PrestoPrincipal grantor);
Set listRoleGrants(MetastoreContext metastoreContext, PrestoPrincipal principal);
void grantTablePrivileges(MetastoreContext metastoreContext, String databaseName, String tableName, PrestoPrincipal grantee, Set privileges);
void revokeTablePrivileges(MetastoreContext metastoreContext, String databaseName, String tableName, PrestoPrincipal grantee, Set privileges);
Set listTablePrivileges(MetastoreContext metastoreContext, String databaseName, String tableName, PrestoPrincipal principal);
void setPartitionLeases(MetastoreContext metastoreContext, String databaseName, String tableName, Map partitionNameToLocation, Duration leaseDuration);
default Optional lock(MetastoreContext metastoreContext, String databaseName, String tableName)
{
throw new NotSupportedException("Lock is not supported by default");
}
default void unlock(MetastoreContext metastoreContext, long lockId)
{
throw new NotSupportedException("Unlock is not supported by default");
}
default List> getTableConstraints(MetastoreContext metastoreContext, String schemaName, String tableName)
{
return ImmutableList.of();
}
// Different metastore systems could implement this commit batch size differently based on different underlying database capacity.
// Default batch partition commit size is set to 10.
default int getPartitionCommitBatchSize()
{
return 10;
}
MetastoreOperationResult dropConstraint(MetastoreContext metastoreContext, String databaseName, String tableName, String constraintName);
MetastoreOperationResult addConstraint(MetastoreContext metastoreContext, String databaseName, String tableName, TableConstraint tableConstraint);
}