|
1 | 1 | package io.delta.sharing.java.format.parquet; |
2 | 2 |
|
3 | | -import org.apache.parquet.io.SeekableInputStream; |
4 | | -import org.junit.jupiter.api.Assertions; |
5 | | -import org.junit.jupiter.api.Test; |
6 | | - |
7 | 3 | import java.io.IOException; |
8 | 4 | import java.nio.ByteBuffer; |
9 | 5 | import java.nio.file.Path; |
10 | 6 | import java.nio.file.Paths; |
| 7 | +import org.apache.parquet.io.SeekableInputStream; |
| 8 | +import org.junit.jupiter.api.Assertions; |
| 9 | +import org.junit.jupiter.api.Test; |
11 | 10 |
|
| 11 | +/** |
| 12 | + * Test cases for local Input File. |
| 13 | + * |
| 14 | + * @throws IOException for all IO problems |
| 15 | + */ |
12 | 16 | public class LocalInputFileTestCase { |
13 | 17 |
|
14 | 18 | @Test |
15 | 19 | public void testRead() throws IOException { |
16 | | - Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
| 20 | + Path filePath = |
| 21 | + Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
17 | 22 | LocalInputFile localInputFile = new LocalInputFile(filePath); |
18 | 23 |
|
19 | 24 | byte[] b = new byte[1024]; |
20 | 25 | SeekableInputStream stream = localInputFile.newStream(); |
21 | 26 |
|
22 | | - Assertions.assertDoesNotThrow( |
23 | | - () -> stream.read(b), |
24 | | - "assert no exception for read with buffer" |
25 | | - ); |
26 | | - |
27 | | - Assertions.assertDoesNotThrow( |
28 | | - () -> stream.read(), |
29 | | - "assert no exception for read without buffer" |
30 | | - ); |
31 | | - |
32 | | - Assertions.assertDoesNotThrow( |
33 | | - () -> stream.read(b, 100, 100), |
34 | | - "assert no exception for read with offset using a buffer" |
35 | | - ); |
36 | | - |
37 | | - Assertions.assertDoesNotThrow( |
38 | | - () -> stream.readFully(b, 100, 100), |
39 | | - "assert no exception for read with offset using a buffer" |
40 | | - ); |
| 27 | + Assertions.assertDoesNotThrow(() -> stream.read(b), "assert no exception for read with buffer"); |
| 28 | + |
| 29 | + Assertions.assertDoesNotThrow(() -> stream.read(), |
| 30 | + "assert no exception for read without buffer"); |
| 31 | + |
| 32 | + Assertions.assertDoesNotThrow(() -> stream.read(b, 100, 100), |
| 33 | + "assert no exception for read with offset using a buffer"); |
| 34 | + |
| 35 | + Assertions.assertDoesNotThrow(() -> stream.readFully(b, 100, 100), |
| 36 | + "assert no exception for read with offset using a buffer"); |
41 | 37 | } |
42 | 38 |
|
43 | 39 | @Test |
44 | 40 | public void testSkip() throws IOException { |
45 | | - Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
| 41 | + Path filePath = |
| 42 | + Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
46 | 43 | LocalInputFile localInputFile = new LocalInputFile(filePath); |
47 | 44 |
|
48 | 45 | byte[] b = new byte[1024]; |
49 | 46 | SeekableInputStream stream = localInputFile.newStream(); |
50 | 47 |
|
51 | | - Assertions.assertDoesNotThrow( |
52 | | - () -> stream.skip(100) + stream.read(b), |
53 | | - "assert no exception for read after a skip" |
54 | | - ); |
| 48 | + Assertions.assertDoesNotThrow(() -> stream.skip(100) + stream.read(b), |
| 49 | + "assert no exception for read after a skip"); |
55 | 50 | } |
56 | 51 |
|
57 | 52 | @Test |
58 | 53 | public void testReadByteBuffers() throws IOException { |
59 | | - Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
| 54 | + Path filePath = |
| 55 | + Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
60 | 56 | LocalInputFile localInputFile = new LocalInputFile(filePath); |
61 | 57 |
|
62 | | - //8192 is page size constant inside the LocalInputFile |
| 58 | + // 8192 is page size constant inside the LocalInputFile |
63 | 59 | ByteBuffer byteBuffer = ByteBuffer.allocateDirect(8192 * 4); |
64 | 60 | SeekableInputStream stream = localInputFile.newStream(); |
65 | 61 |
|
66 | | - Assertions.assertDoesNotThrow( |
67 | | - () -> stream.read(byteBuffer), |
68 | | - "assert no exception for read with byte buffer" |
69 | | - ); |
| 62 | + Assertions.assertDoesNotThrow(() -> stream.read(byteBuffer), |
| 63 | + "assert no exception for read with byte buffer"); |
70 | 64 |
|
71 | | - Assertions.assertDoesNotThrow( |
72 | | - () -> stream.readFully(byteBuffer), |
73 | | - "assert no exception for readFully with byte buffer" |
74 | | - ); |
| 65 | + Assertions.assertDoesNotThrow(() -> stream.readFully(byteBuffer), |
| 66 | + "assert no exception for readFully with byte buffer"); |
75 | 67 | } |
76 | 68 |
|
77 | 69 | @Test |
78 | 70 | public void testPointers() throws IOException { |
79 | | - Path filePath = Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
| 71 | + Path filePath = |
| 72 | + Paths.get("src", "test", "resources", "table_reader_test_data.parquet").toAbsolutePath(); |
80 | 73 | LocalInputFile localInputFile = new LocalInputFile(filePath); |
81 | 74 |
|
82 | | - //8192 is page size constant inside the LocalInputFile |
| 75 | + // 8192 is page size constant inside the LocalInputFile |
83 | 76 | SeekableInputStream stream = localInputFile.newStream(); |
84 | 77 |
|
85 | 78 | Assertions.assertTrue(stream.markSupported()); |
86 | 79 | Assertions.assertEquals(stream.available(), 0); |
87 | 80 |
|
88 | | - Assertions.assertDoesNotThrow( |
89 | | - () -> stream.mark(0), |
90 | | - "assert mark operation doesnt throw an exception" |
91 | | - ); |
| 81 | + Assertions.assertDoesNotThrow(() -> stream.mark(0), |
| 82 | + "assert mark operation doesnt throw an exception"); |
92 | 83 |
|
93 | | - Assertions.assertDoesNotThrow( |
94 | | - () -> stream.mark(0), |
95 | | - "assert mark operation doesnt throw an exception" |
96 | | - ); |
| 84 | + Assertions.assertDoesNotThrow(() -> stream.mark(0), |
| 85 | + "assert mark operation doesnt throw an exception"); |
97 | 86 | } |
98 | 87 | } |
0 commit comments