private ParquetInputFormat.FootersCacheValue getDummyCacheValue(File file, FileSystem fs) throws IOException { Path path = new Path(file.getPath()); FileStatus status = fs.getFileStatus(path); ParquetInputFormat.FileStatusWrapper statusWrapper = new ParquetInputFormat.FileStatusWrapper(status); ParquetMetadata mockMetadata = mock(ParquetMetadata.class); ParquetInputFormat.FootersCacheValue cacheValue = new ParquetInputFormat.FootersCacheValue(statusWrapper, new Footer(path, mockMetadata)); assertTrue(cacheValue.isCurrent(statusWrapper)); return cacheValue; }
@Test public void testFooterCacheValueIsCurrent() throws IOException, InterruptedException { File tempFile = getTempFile(); FileSystem fs = FileSystem.getLocal(new Configuration()); ParquetInputFormat.FootersCacheValue cacheValue = getDummyCacheValue(tempFile, fs); assertTrue(tempFile.setLastModified(tempFile.lastModified() + 5000)); assertFalse( cacheValue.isCurrent( new ParquetInputFormat.FileStatusWrapper( fs.getFileStatus(new Path(tempFile.getAbsolutePath()))))); }
@Test public void testFooterCacheValueIsNewer() throws IOException { File tempFile = getTempFile(); FileSystem fs = FileSystem.getLocal(new Configuration()); ParquetInputFormat.FootersCacheValue cacheValue = getDummyCacheValue(tempFile, fs); assertTrue(cacheValue.isNewerThan(null)); assertFalse(cacheValue.isNewerThan(cacheValue)); assertTrue(tempFile.setLastModified(tempFile.lastModified() + 5000)); ParquetInputFormat.FootersCacheValue newerCacheValue = getDummyCacheValue(tempFile, fs); assertTrue(newerCacheValue.isNewerThan(cacheValue)); assertFalse(cacheValue.isNewerThan(newerCacheValue)); }