Skip to content

Commit 9e723ee

Browse files
Steven Willistomwhite
authored andcommitted
Test for filtering records across multiple blocks
1 parent 9ad5485 commit 9e723ee

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

parquet-avro/src/test/java/parquet/avro/TestSpecificReadWrite.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ public void testFilterMatchesMultiple() throws IOException {
7676
assertNull(reader.read());
7777
}
7878

79+
@Test
80+
public void testFilterMatchesMultipleBlocks() throws IOException {
81+
Path path = writeCarsToParquetFile(10000, CompressionCodecName.UNCOMPRESSED, false, DEFAULT_BLOCK_SIZE/64, DEFAULT_PAGE_SIZE/64);
82+
ParquetReader<Car> reader = new AvroParquetReader<Car>(path, column("make", equalTo("Volkswagen")));
83+
for (int i = 0; i < 10000; i++) {
84+
assertEquals(getVwPolo().toString(), reader.read().toString());
85+
assertEquals(getVwPassat().toString(), reader.read().toString());
86+
}
87+
assertNull(reader.read());
88+
}
89+
7990
@Test
8091
public void testFilterWithDictionary() throws IOException {
8192
Path path = writeCarsToParquetFile(1,CompressionCodecName.UNCOMPRESSED,true);
@@ -159,6 +170,10 @@ public void testAvroReadSchema() throws IOException {
159170
}
160171

161172
private Path writeCarsToParquetFile( int num, CompressionCodecName compression, boolean enableDictionary) throws IOException {
173+
return writeCarsToParquetFile(num, compression, enableDictionary, DEFAULT_BLOCK_SIZE, DEFAULT_PAGE_SIZE);
174+
}
175+
176+
private Path writeCarsToParquetFile( int num, CompressionCodecName compression, boolean enableDictionary, int blockSize, int pageSize) throws IOException {
162177
File tmp = File.createTempFile(getClass().getSimpleName(), ".tmp");
163178
tmp.deleteOnExit();
164179
tmp.delete();
@@ -169,7 +184,7 @@ private Path writeCarsToParquetFile( int num, CompressionCodecName compression,
169184
Car bmwMini = getBmwMini();
170185

171186
ParquetWriter<Car> writer = new AvroParquetWriter<Car>(path,Car.SCHEMA$, compression,
172-
DEFAULT_BLOCK_SIZE, DEFAULT_PAGE_SIZE, enableDictionary);
187+
blockSize, pageSize, enableDictionary);
173188
for (int i = 0; i < num; i++) {
174189
writer.write(vwPolo);
175190
writer.write(vwPassat);

0 commit comments

Comments
 (0)