Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import static org.apache.parquet.hadoop.ParquetFileWriter.Mode.OVERWRITE;
import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT64;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
Expand All @@ -44,9 +44,8 @@
import org.apache.parquet.io.InputFile;
import org.apache.parquet.schema.MessageType;
import org.apache.parquet.schema.Types;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

/**
* Tests for GH-3487: Verify that PageReadStore buffers are properly released when
Expand All @@ -69,8 +68,8 @@ public class TestParquetFileReaderBufferLeak {

private static final Configuration CONF = new Configuration();

@Rule
public final TemporaryFolder temp = new TemporaryFolder();
@TempDir
private java.nio.file.Path tempDir;

/**
* Helper: write a parquet file with multiple row groups using the high-level writer API.
Expand All @@ -80,8 +79,7 @@ public class TestParquetFileReaderBufferLeak {
private Path writeMultiRowGroupFile(int numRecords) throws IOException {
GroupWriteSupport.setSchema(SCHEMA, CONF);

File testFile = temp.newFile();
testFile.delete();
File testFile = tempDir.resolve("test.parquet").toFile();
Path path = new Path(testFile.toURI());

try (TrackingByteBufferAllocator writeAllocator =
Expand Down Expand Up @@ -123,7 +121,7 @@ private int getRowGroupCount(Path path) throws IOException {
public void testReadNextRowGroupReleasesBuffersOfPreviousRowGroup() throws Exception {
Path path = writeMultiRowGroupFile(500);
int expectedRowGroups = getRowGroupCount(path);
assertTrue("Expected multiple row groups but got " + expectedRowGroups, expectedRowGroups > 1);
assertTrue(expectedRowGroups > 1, "Expected multiple row groups but got " + expectedRowGroups);

try (TrackingByteBufferAllocator readAllocator =
TrackingByteBufferAllocator.wrap(new HeapByteBufferAllocator())) {
Expand Down Expand Up @@ -153,7 +151,7 @@ public void testReadNextRowGroupReleasesBuffersOfPreviousRowGroup() throws Excep
public void testCloseReleasesCurrentRowGroupBuffers() throws Exception {
Path path = writeMultiRowGroupFile(500);
int expectedRowGroups = getRowGroupCount(path);
assertTrue("Expected multiple row groups but got " + expectedRowGroups, expectedRowGroups > 1);
assertTrue(expectedRowGroups > 1, "Expected multiple row groups but got " + expectedRowGroups);

try (TrackingByteBufferAllocator readAllocator =
TrackingByteBufferAllocator.wrap(new HeapByteBufferAllocator())) {
Expand All @@ -179,7 +177,7 @@ public void testCloseReleasesCurrentRowGroupBuffers() throws Exception {
public void testReadNextFilteredRowGroupReleasesBuffersWhenNoFilter() throws Exception {
Path path = writeMultiRowGroupFile(500);
int expectedRowGroups = getRowGroupCount(path);
assertTrue("Expected multiple row groups but got " + expectedRowGroups, expectedRowGroups > 1);
assertTrue(expectedRowGroups > 1, "Expected multiple row groups but got " + expectedRowGroups);

try (TrackingByteBufferAllocator readAllocator =
TrackingByteBufferAllocator.wrap(new HeapByteBufferAllocator())) {
Expand Down Expand Up @@ -209,7 +207,7 @@ public void testReadNextFilteredRowGroupReleasesBuffersWhenNoFilter() throws Exc
public void testReadNextFilteredRowGroupReleasesBuffersWithFilter() throws Exception {
Path path = writeMultiRowGroupFile(500);
int expectedRowGroups = getRowGroupCount(path);
assertTrue("Expected multiple row groups but got " + expectedRowGroups, expectedRowGroups > 1);
assertTrue(expectedRowGroups > 1, "Expected multiple row groups but got " + expectedRowGroups);

try (TrackingByteBufferAllocator readAllocator =
TrackingByteBufferAllocator.wrap(new HeapByteBufferAllocator())) {
Expand Down Expand Up @@ -245,7 +243,7 @@ public void testReadNextFilteredRowGroupReleasesBuffersWithFilter() throws Excep
public void testReadNextFilteredRowGroupWithColumnIndexFilteringReleasesBuffers() throws Exception {
Path path = writeMultiRowGroupFile(500);
int totalRowGroups = getRowGroupCount(path);
assertTrue("Expected multiple row groups but got " + totalRowGroups, totalRowGroups > 1);
assertTrue(totalRowGroups > 1, "Expected multiple row groups but got " + totalRowGroups);

try (TrackingByteBufferAllocator readAllocator =
TrackingByteBufferAllocator.wrap(new HeapByteBufferAllocator())) {
Expand All @@ -269,7 +267,7 @@ public void testReadNextFilteredRowGroupWithColumnIndexFilteringReleasesBuffers(
rowGroupCount++;
}
// At least some row groups should be returned (those containing id < 10)
assertTrue("Expected at least 1 row group returned", rowGroupCount >= 1);
assertTrue(rowGroupCount >= 1, "Expected at least 1 row group returned");
}
}
}
Expand All @@ -282,7 +280,7 @@ public void testReadNextFilteredRowGroupWithColumnIndexFilteringReleasesBuffers(
public void testPartialReadThenCloseReleasesBuffers() throws Exception {
Path path = writeMultiRowGroupFile(500);
int expectedRowGroups = getRowGroupCount(path);
assertTrue("Expected at least 3 row groups but got " + expectedRowGroups, expectedRowGroups >= 3);
assertTrue(expectedRowGroups >= 3, "Expected at least 3 row groups but got " + expectedRowGroups);

try (TrackingByteBufferAllocator readAllocator =
TrackingByteBufferAllocator.wrap(new HeapByteBufferAllocator())) {
Expand Down
Loading