From faa3a55794b1c2b2b59e6299a9e8c2ccac8e0bc5 Mon Sep 17 00:00:00 2001 From: Reetika Agrawal Date: Wed, 22 May 2024 00:41:32 +0530 Subject: [PATCH] Add entry to parquet metadata cache on file modificationTime --- .../presto/hive/parquet/AbstractTestParquetReader.java | 4 ++-- .../parquet/cache/CachingParquetMetadataSource.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/presto-hive/src/test/java/com/facebook/presto/hive/parquet/AbstractTestParquetReader.java b/presto-hive/src/test/java/com/facebook/presto/hive/parquet/AbstractTestParquetReader.java index 231c7c5208db..5ce1b0b12183 100644 --- a/presto-hive/src/test/java/com/facebook/presto/hive/parquet/AbstractTestParquetReader.java +++ b/presto-hive/src/test/java/com/facebook/presto/hive/parquet/AbstractTestParquetReader.java @@ -1701,8 +1701,8 @@ public void testCaching() parquetMetadataSource, tempFile.getFile(), tempFileModificationTime); - assertEquals(parquetFileMetadataCache.stats().missCount(), 3); - assertEquals(parquetFileMetadataCache.stats().hitCount(), 4); + assertEquals(parquetFileMetadataCache.stats().missCount(), 2); + assertEquals(parquetFileMetadataCache.stats().hitCount(), 5); } } diff --git a/presto-parquet/src/main/java/com/facebook/presto/parquet/cache/CachingParquetMetadataSource.java b/presto-parquet/src/main/java/com/facebook/presto/parquet/cache/CachingParquetMetadataSource.java index b7c84093525b..9f1fe5018347 100644 --- a/presto-parquet/src/main/java/com/facebook/presto/parquet/cache/CachingParquetMetadataSource.java +++ b/presto-parquet/src/main/java/com/facebook/presto/parquet/cache/CachingParquetMetadataSource.java @@ -54,12 +54,12 @@ public ParquetFileMetadata getParquetMetadata( ParquetFileMetadata fileMetadataCache = cache.get( parquetDataSource.getId(), () -> delegate.getParquetMetadata(parquetDataSource, fileSize, cacheable, modificationTime, fileDecryptor, readMaskedValue)); - if (fileMetadataCache.getModificationTime() == modificationTime) { - return fileMetadataCache; - } - else { + if (fileMetadataCache.getModificationTime() != modificationTime) { cache.invalidate(parquetDataSource.getId()); + fileMetadataCache = delegate.getParquetMetadata(parquetDataSource, fileSize, cacheable, modificationTime, fileDecryptor, readMaskedValue); + cache.put(parquetDataSource.getId(), fileMetadataCache); } + return fileMetadataCache; } return delegate.getParquetMetadata(parquetDataSource, fileSize, cacheable, modificationTime, fileDecryptor, readMaskedValue); }