diff --git a/presto-hive-hadoop2/src/test/java/com/facebook/presto/hive/s3select/S3SelectTestHelper.java b/presto-hive-hadoop2/src/test/java/com/facebook/presto/hive/s3select/S3SelectTestHelper.java index 7b9e4dc481216..96e94bbac65da 100644 --- a/presto-hive-hadoop2/src/test/java/com/facebook/presto/hive/s3select/S3SelectTestHelper.java +++ b/presto-hive-hadoop2/src/test/java/com/facebook/presto/hive/s3select/S3SelectTestHelper.java @@ -176,7 +176,7 @@ public S3SelectTestHelper(String host, new HivePartitionStats(), new HiveFileRenamer(), columnConverterProvider, - new QuickStatsProvider(hdfsEnvironment, DO_NOTHING_DIRECTORY_LISTER, new HiveClientConfig(), new NamenodeStats(), ImmutableList.of()), + new QuickStatsProvider(metastoreClient, hdfsEnvironment, DO_NOTHING_DIRECTORY_LISTER, new HiveClientConfig(), new NamenodeStats(), ImmutableList.of()), new HiveTableWritabilityChecker(config)); transactionManager = new HiveTransactionManager(); splitManager = new HiveSplitManager( diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/HiveClientModule.java b/presto-hive/src/main/java/com/facebook/presto/hive/HiveClientModule.java index c4b7af083a20f..23cd40cb39594 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/HiveClientModule.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/HiveClientModule.java @@ -24,6 +24,7 @@ import com.facebook.presto.hive.cache.HiveCachingHdfsConfiguration; import com.facebook.presto.hive.datasink.DataSinkFactory; import com.facebook.presto.hive.datasink.OutputStreamDataSinkFactory; +import com.facebook.presto.hive.metastore.ExtendedHiveMetastore; import com.facebook.presto.hive.metastore.HiveMetastoreCacheStats; import com.facebook.presto.hive.metastore.HivePartitionMutator; import com.facebook.presto.hive.metastore.MetastoreCacheStats; @@ -377,7 +378,9 @@ public ParquetMetadataSource createParquetMetadataSource(ParquetCacheConfig parq @Singleton @Provides - public QuickStatsProvider createQuickStatsProvider(HdfsEnvironment hdfsEnvironment, + public QuickStatsProvider createQuickStatsProvider( + ExtendedHiveMetastore metastore, + HdfsEnvironment hdfsEnvironment, DirectoryLister directoryLister, HiveClientConfig hiveClientConfig, NamenodeStats nameNodeStats, @@ -385,7 +388,8 @@ public QuickStatsProvider createQuickStatsProvider(HdfsEnvironment hdfsEnvironme MBeanExporter exporter) { ParquetQuickStatsBuilder parquetQuickStatsBuilder = new ParquetQuickStatsBuilder(fileFormatDataSourceStats, hdfsEnvironment, hiveClientConfig); - QuickStatsProvider quickStatsProvider = new QuickStatsProvider(hdfsEnvironment, + QuickStatsProvider quickStatsProvider = new QuickStatsProvider(metastore, + hdfsEnvironment, directoryLister, hiveClientConfig, nameNodeStats, diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/MetastoreHiveStatisticsProvider.java b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/MetastoreHiveStatisticsProvider.java index f27ccfc26b9f7..b1d50bd556281 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/MetastoreHiveStatisticsProvider.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/MetastoreHiveStatisticsProvider.java @@ -140,7 +140,7 @@ private Map getPartitionsStatistics(ConnectorSessio PartitionStatistics tableStatistics = metastore.getTableStatistics(metastoreContext, table.getSchemaName(), table.getTableName()); if (isQuickStatsEnabled(session) && (tableStatistics.equals(empty()) || tableStatistics.getColumnStatistics().isEmpty())) { - tableStatistics = quickStatsProvider.getQuickStats(session, metastore, table, metastoreContext, UNPARTITIONED_ID.getPartitionName()); + tableStatistics = quickStatsProvider.getQuickStats(session, table, metastoreContext, UNPARTITIONED_ID.getPartitionName()); } return ImmutableMap.of(UNPARTITIONED_ID.getPartitionName(), tableStatistics); } @@ -156,7 +156,7 @@ private Map getPartitionsStatistics(ConnectorSessio .map(Map.Entry::getKey) .collect(toImmutableList()); - Map partitionQuickStats = quickStatsProvider.getQuickStats(session, metastore, table, metastoreContext, partitionsWithNoStats); + Map partitionQuickStats = quickStatsProvider.getQuickStats(session, table, metastoreContext, partitionsWithNoStats); HashMap mergedMap = new HashMap<>(partitionStatistics); mergedMap.putAll(partitionQuickStats); diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/ParquetQuickStatsBuilder.java b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/ParquetQuickStatsBuilder.java index 8ed20d43a54e6..a101f8b8919d7 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/ParquetQuickStatsBuilder.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/ParquetQuickStatsBuilder.java @@ -27,9 +27,9 @@ import com.facebook.presto.hive.HiveFileContext; import com.facebook.presto.hive.HiveFileInfo; import com.facebook.presto.hive.PartitionNameWithVersion; +import com.facebook.presto.hive.metastore.ExtendedHiveMetastore; import com.facebook.presto.hive.metastore.MetastoreContext; import com.facebook.presto.hive.metastore.Partition; -import com.facebook.presto.hive.metastore.SemiTransactionalHiveMetastore; import com.facebook.presto.hive.metastore.StorageFormat; import com.facebook.presto.hive.metastore.Table; import com.facebook.presto.parquet.ParquetDataSource; @@ -283,7 +283,7 @@ public ThreadPoolExecutorMBean getExecutor() } @Override - public PartitionQuickStats buildQuickStats(ConnectorSession session, SemiTransactionalHiveMetastore metastore, + public PartitionQuickStats buildQuickStats(ConnectorSession session, ExtendedHiveMetastore metastore, SchemaTableName table, MetastoreContext metastoreContext, String partitionId, Iterator files) { requireNonNull(session); diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsBuilder.java b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsBuilder.java index e6a4ba06166f2..5cfa7c9f96495 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsBuilder.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsBuilder.java @@ -15,8 +15,8 @@ package com.facebook.presto.hive.statistics; import com.facebook.presto.hive.HiveFileInfo; +import com.facebook.presto.hive.metastore.ExtendedHiveMetastore; import com.facebook.presto.hive.metastore.MetastoreContext; -import com.facebook.presto.hive.metastore.SemiTransactionalHiveMetastore; import com.facebook.presto.spi.ConnectorSession; import com.facebook.presto.spi.SchemaTableName; @@ -25,6 +25,6 @@ @FunctionalInterface public interface QuickStatsBuilder { - PartitionQuickStats buildQuickStats(ConnectorSession session, SemiTransactionalHiveMetastore metastore, SchemaTableName table, + PartitionQuickStats buildQuickStats(ConnectorSession session, ExtendedHiveMetastore metastore, SchemaTableName table, MetastoreContext metastoreContext, String partitionId, Iterator files); } diff --git a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsProvider.java b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsProvider.java index 65c64bc00d54f..fff00dd53f654 100644 --- a/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsProvider.java +++ b/presto-hive/src/main/java/com/facebook/presto/hive/statistics/QuickStatsProvider.java @@ -28,10 +28,10 @@ import com.facebook.presto.hive.NamenodeStats; import com.facebook.presto.hive.PartitionNameWithVersion; import com.facebook.presto.hive.filesystem.ExtendedFileSystem; +import com.facebook.presto.hive.metastore.ExtendedHiveMetastore; import com.facebook.presto.hive.metastore.MetastoreContext; import com.facebook.presto.hive.metastore.Partition; import com.facebook.presto.hive.metastore.PartitionStatistics; -import com.facebook.presto.hive.metastore.SemiTransactionalHiveMetastore; import com.facebook.presto.hive.metastore.Table; import com.facebook.presto.spi.ConnectorSession; import com.facebook.presto.spi.SchemaTableName; @@ -101,10 +101,16 @@ public class QuickStatsProvider private final Cache partitionToStatsCache; private final NamenodeStats nameNodeStats; private final TimeStat buildDuration = new TimeStat(MILLISECONDS); + private final ExtendedHiveMetastore metastore; - public QuickStatsProvider(HdfsEnvironment hdfsEnvironment, DirectoryLister directoryLister, HiveClientConfig hiveClientConfig, NamenodeStats nameNodeStats, + public QuickStatsProvider(ExtendedHiveMetastore metastore, + HdfsEnvironment hdfsEnvironment, + DirectoryLister directoryLister, + HiveClientConfig hiveClientConfig, + NamenodeStats nameNodeStats, List statsBuilderStrategies) { + this.metastore = metastore; this.hdfsEnvironment = hdfsEnvironment; this.directoryLister = directoryLister; this.recursiveDirWalkerEnabled = hiveClientConfig.getRecursiveDirWalkerEnabled(); @@ -151,7 +157,7 @@ public Map getInProgressBuildsSnapshot() return inProgressBuilds.entrySet().stream().collect(toImmutableMap(Map.Entry::getKey, v -> v.getValue().getBuildStart())); } - public Map getQuickStats(ConnectorSession session, SemiTransactionalHiveMetastore metastore, SchemaTableName table, + public Map getQuickStats(ConnectorSession session, SchemaTableName table, MetastoreContext metastoreContext, List partitionIds) { if (!isQuickStatsEnabled(session)) { @@ -161,7 +167,7 @@ public Map getQuickStats(ConnectorSession session, CompletableFuture[] partitionQuickStatCompletableFutures = new CompletableFuture[partitionIds.size()]; for (int counter = 0; counter < partitionIds.size(); counter++) { String partitionId = partitionIds.get(counter); - partitionQuickStatCompletableFutures[counter] = supplyAsync(() -> getQuickStats(session, metastore, table, metastoreContext, partitionId), backgroundFetchExecutor); + partitionQuickStatCompletableFutures[counter] = supplyAsync(() -> getQuickStats(session, table, metastoreContext, partitionId), backgroundFetchExecutor); } try { @@ -203,7 +209,7 @@ public Map getQuickStats(ConnectorSession session, return result.build(); } - public PartitionStatistics getQuickStats(ConnectorSession session, SemiTransactionalHiveMetastore metastore, SchemaTableName table, + public PartitionStatistics getQuickStats(ConnectorSession session, SchemaTableName table, MetastoreContext metastoreContext, String partitionId) { if (!isQuickStatsEnabled(session)) { @@ -236,7 +242,7 @@ public PartitionStatistics getQuickStats(ConnectorSession session, SemiTransacti // If not, atomically initiate a call to build quick stats in a background thread AtomicReference> partitionStatisticsCompletableFuture = new AtomicReference<>(); inProgressBuilds.computeIfAbsent(partitionKey, (key) -> { - CompletableFuture fetchFuture = supplyAsync(() -> buildQuickStats(partitionKey, partitionId, session, metastore, table, metastoreContext), backgroundFetchExecutor); + CompletableFuture fetchFuture = supplyAsync(() -> buildQuickStats(partitionKey, partitionId, session, table, metastoreContext), backgroundFetchExecutor); partitionStatisticsCompletableFuture.set(fetchFuture); return new InProgressBuildInfo(fetchFuture, Instant.now()); @@ -282,7 +288,7 @@ public PartitionStatistics getQuickStats(ConnectorSession session, SemiTransacti else { // The quick stats inline fetch was pre-empted by another thread // We get the up-to-date value by calling getQuickStats again - return getQuickStats(session, metastore, table, metastoreContext, partitionId); + return getQuickStats(session, table, metastoreContext, partitionId); } } @@ -311,7 +317,7 @@ private long getQuickStatsInlineBuildTimeoutMillis(ConnectorSession session) return getQuickStatsInlineBuildTimeout(session).toMillis(); } - private PartitionStatistics buildQuickStats(String partitionKey, String partitionId, ConnectorSession session, SemiTransactionalHiveMetastore metastore, SchemaTableName table, + private PartitionStatistics buildQuickStats(String partitionKey, String partitionId, ConnectorSession session, SchemaTableName table, MetastoreContext metastoreContext) { Table resolvedTable = metastore.getTable(metastoreContext, table.getSchemaName(), table.getTableName()).get(); diff --git a/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java b/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java index c4f1f468b544f..d622e36da67e5 100644 --- a/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java +++ b/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java @@ -1042,7 +1042,7 @@ protected final void setup(String databaseName, HiveClientConfig hiveClientConfi new HivePartitionStats(), new HiveFileRenamer(), DEFAULT_COLUMN_CONVERTER_PROVIDER, - new QuickStatsProvider(HDFS_ENVIRONMENT, DO_NOTHING_DIRECTORY_LISTER, new HiveClientConfig(), new NamenodeStats(), ImmutableList.of()), + new QuickStatsProvider(metastoreClient, HDFS_ENVIRONMENT, DO_NOTHING_DIRECTORY_LISTER, new HiveClientConfig(), new NamenodeStats(), ImmutableList.of()), new HiveTableWritabilityChecker(false)); transactionManager = new HiveTransactionManager(); diff --git a/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveFileSystem.java b/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveFileSystem.java index a692ba3d9ee44..14aec5fbdb822 100644 --- a/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveFileSystem.java +++ b/presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveFileSystem.java @@ -224,7 +224,7 @@ protected void setup(String host, int port, String databaseName, BiFunction emptyIterator(); @@ -210,12 +197,12 @@ public void testReadThruCaching() { QuickStatsBuilder quickStatsBuilderMock = (session, metastore, table, metastoreContext, partitionId, files) -> mockPartitionQuickStats; - QuickStatsProvider quickStatsProvider = new QuickStatsProvider(hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), + QuickStatsProvider quickStatsProvider = new QuickStatsProvider(metastoreMock, hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), ImmutableList.of(quickStatsBuilderMock)); // Execute ImmutableList testPartitions1 = ImmutableList.of("partition1", "partition2", "partition3"); - Map quickStats = quickStatsProvider.getQuickStats(SESSION, metastoreMock, + Map quickStats = quickStatsProvider.getQuickStats(SESSION, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions1); // Verify only one call was made for each test partition @@ -224,14 +211,14 @@ public void testReadThruCaching() quickStats.values().forEach(ps -> assertEquals(ps, expectedPartitionStats)); // For subsequent calls for the same partitions that are already cached, no new calls are mode to the quick stats builder - quickStatsProvider.getQuickStats(SESSION, metastoreMock, + quickStatsProvider.getQuickStats(SESSION, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions1); // For subsequent calls with a mix of old and new partitions, we only see calls to the quick stats builder for the new partitions ImmutableList testPartitions2 = ImmutableList.of("partition4", "partition5", "partition6"); ImmutableList testPartitionsMix = ImmutableList.builder().addAll(testPartitions1).addAll(testPartitions2).build(); - quickStats = quickStatsProvider.getQuickStats(SESSION, metastoreMock, + quickStats = quickStatsProvider.getQuickStats(SESSION, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitionsMix); assertEquals(quickStats.entrySet().size(), testPartitionsMix.size()); assertTrue(quickStats.keySet().containsAll(testPartitionsMix)); @@ -254,7 +241,7 @@ public void testConcurrentFetchForSamePartition() return mockPartitionQuickStats; }; - QuickStatsProvider quickStatsProvider = new QuickStatsProvider(hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), + QuickStatsProvider quickStatsProvider = new QuickStatsProvider(metastoreMock, hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), ImmutableList.of(longRunningQuickStatsBuilderMock)); List testPartitions = ImmutableList.of("partition1", "partition2", "partition3"); @@ -265,10 +252,10 @@ public void testConcurrentFetchForSamePartition() ConnectorSession session = getSession("600ms", "0ms"); // Execute two concurrent calls for the same partitions; wait for them to complete - CompletableFuture> future1 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, metastoreMock, + CompletableFuture> future1 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions), commonPool()); - CompletableFuture> future2 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, metastoreMock, + CompletableFuture> future2 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions), commonPool()); allOf(future1, future2).join(); @@ -300,7 +287,7 @@ else if (partitionStatistics2.equals(empty())) { } // Future calls for the same partitions will return from cached partition stats with valid values - Map quickStats = quickStatsProvider.getQuickStats(session, metastoreMock, + Map quickStats = quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions); // Verify only one call was made for each test partition @@ -315,10 +302,10 @@ else if (partitionStatistics2.equals(empty())) { ConnectorSession session = getSession("300ms", "300ms"); // Execute two concurrent calls for the same partitions; wait for them to complete - CompletableFuture> future1 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, metastoreMock, + CompletableFuture> future1 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions), commonPool()); - CompletableFuture> future2 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, metastoreMock, + CompletableFuture> future2 = supplyAsync(() -> quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions), commonPool()); allOf(future1, future2).join(); @@ -350,12 +337,12 @@ public void quickStatsBuildTimeIsBounded() }; { - QuickStatsProvider quickStatsProvider = new QuickStatsProvider(hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), + QuickStatsProvider quickStatsProvider = new QuickStatsProvider(metastoreMock, hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), ImmutableList.of(longRunningQuickStatsBuilderMock)); // Create a session where an inline build will occur for any newly requested partition ConnectorSession session = getSession("300ms", "0ms"); List testPartitions = ImmutableList.copyOf(mockPerPartitionStatsFetchTimes.keySet()); - Map quickStats = quickStatsProvider.getQuickStats(session, metastoreMock, + Map quickStats = quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, testPartitions); Map inProgressBuildsSnapshot = quickStatsProvider.getInProgressBuildsSnapshot(); @@ -376,10 +363,10 @@ public void quickStatsBuildTimeIsBounded() // Create a session where no inline builds will occur for any requested partition; empty() quick stats will be returned ConnectorSession session = getSession("0ms", "0ms"); - QuickStatsProvider quickStatsProvider = new QuickStatsProvider(hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), + QuickStatsProvider quickStatsProvider = new QuickStatsProvider(metastoreMock, hdfsEnvironment, directoryListerMock, hiveClientConfig, new NamenodeStats(), ImmutableList.of((session1, metastore, table, metastoreContext, partitionId, files) -> mockPartitionQuickStats)); - Map quickStats = quickStatsProvider.getQuickStats(session, metastoreMock, + Map quickStats = quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, ImmutableList.of("p5", "p6")); assertEquals(quickStats.size(), 2); @@ -392,7 +379,7 @@ public void quickStatsBuildTimeIsBounded() .maxAttempts(10) .exponentialBackoff(new Duration(20D, MILLISECONDS), new Duration(500D, MILLISECONDS), new Duration(2, SECONDS), 2.0) .run("waitForQuickStatsBuild", () -> { - Map quickStatsAfter = quickStatsProvider.getQuickStats(session, metastoreMock, + Map quickStatsAfter = quickStatsProvider.getQuickStats(session, new SchemaTableName(TEST_SCHEMA, TEST_TABLE), metastoreContext, ImmutableList.of("p5", "p6")); try { @@ -407,61 +394,4 @@ public void quickStatsBuildTimeIsBounded() }); } } - - public static class MockSemiTransactionalHiveMetastore - extends SemiTransactionalHiveMetastore - { - private final Table mockTable; - private final Partition mockPartition; - - private MockSemiTransactionalHiveMetastore(HdfsEnvironment hdfsEnvironment, - ExtendedHiveMetastore delegate, - ListeningExecutorService renameExecutor, - boolean skipDeletionForAlter, - boolean skipTargetCleanupOnRollback, - boolean undoMetastoreOperationsEnabled, - ColumnConverterProvider columnConverterProvider, - Table mockTable, Partition mockPartition) - { - super(hdfsEnvironment, delegate, renameExecutor, skipDeletionForAlter, skipTargetCleanupOnRollback, undoMetastoreOperationsEnabled, columnConverterProvider); - this.mockPartition = mockPartition; - this.mockTable = mockTable; - } - - public static MockSemiTransactionalHiveMetastore create(Table mockTable, Partition mockPartition) - { - // none of these values matter, as we never use them - HiveClientConfig config = new HiveClientConfig(); - MetastoreClientConfig metastoreClientConfig = new MetastoreClientConfig(); - HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(config, metastoreClientConfig), ImmutableSet.of(), config); - HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, metastoreClientConfig, new NoHdfsAuthentication()); - HiveCluster hiveCluster = new TestingHiveCluster(metastoreClientConfig, "dummy", 1000); - ColumnConverterProvider columnConverterProvider = HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER; - ExtendedHiveMetastore delegate = new BridgingHiveMetastore(new ThriftHiveMetastore(hiveCluster, metastoreClientConfig, hdfsEnvironment), new HivePartitionMutator()); - ExecutorService executor = newCachedThreadPool(daemonThreadsNamed("hive-%s")); - ListeningExecutorService renameExecutor = listeningDecorator(executor); - - return new MockSemiTransactionalHiveMetastore(hdfsEnvironment, delegate, renameExecutor, false, false, true, - columnConverterProvider, mockTable, mockPartition); - } - - @Override - public synchronized Optional getPartition(MetastoreContext metastoreContext, String databaseName, String tableName, List partitionValues) - { - return Optional.of(mockPartition); - } - - @Override - public synchronized Map> getPartitionsByNames(MetastoreContext metastoreContext, String databaseName, String tableName, List partitionNames) - { - checkArgument(partitionNames.size() == 1, "Expected caller to only pass in a single partition to fetch"); - return ImmutableMap.of(partitionNames.get(0).getPartitionName(), Optional.of(mockPartition)); - } - - @Override - public Optional getTable(MetastoreContext metastoreContext, String databaseName, String tableName) - { - return Optional.of(mockTable); - } - } }