@@ -100,7 +100,9 @@ private static class PrimitiveCase {
100
100
}
101
101
}
102
102
103
- // Convert a string to a Decimal that can be written using Avro.
103
+ /**
104
+ * Convert a string to a Decimal that can be written using Avro.
105
+ */
104
106
private static Object avroDecimalValue (String s ) {
105
107
BigDecimal v = new BigDecimal (s );
106
108
int precision = v .precision ();
@@ -1847,8 +1849,7 @@ public void testArrayWithElementValueTypedValueConflict() {
1847
1849
* This is a custom Parquet writer builder that injects a specific Parquet schema and then uses
1848
1850
* the Avro object model. This ensures that the Parquet file's schema is exactly what was passed.
1849
1851
*/
1850
- private static class TestWriterBuilder
1851
- extends ParquetWriter .Builder <GenericRecord , TestWriterBuilder > {
1852
+ private static class TestWriterBuilder extends ParquetWriter .Builder <GenericRecord , TestWriterBuilder > {
1852
1853
private TestSchema schema = null ;
1853
1854
1854
1855
protected TestWriterBuilder (Path path ) {
@@ -1867,20 +1868,21 @@ protected TestWriterBuilder self() {
1867
1868
1868
1869
@ Override
1869
1870
protected WriteSupport <GenericRecord > getWriteSupport (Configuration conf ) {
1870
- return new AvroWriteSupport <>(schema .parquetSchema , avroSchema (schema .unannotatedParquetSchema ), GenericData .get ());
1871
+ return new AvroWriteSupport <>(
1872
+ schema .parquetSchema ,
1873
+ avroSchema (schema .unannotatedParquetSchema ),
1874
+ GenericData .get ());
1871
1875
}
1872
1876
}
1873
1877
1874
- GenericRecord writeAndRead (TestSchema testSchema , GenericRecord record )
1875
- throws IOException {
1878
+ GenericRecord writeAndRead (TestSchema testSchema , GenericRecord record ) throws IOException {
1876
1879
List <GenericRecord > result = writeAndRead (testSchema , Arrays .asList (record ));
1877
1880
assert (result .size () == 1 );
1878
1881
return result .get (0 );
1879
1882
}
1880
1883
1881
- List <GenericRecord > writeAndRead (TestSchema testSchema , List <GenericRecord > records )
1882
- throws IOException {
1883
- // Copied from TestSpecificReadWrite.java. Why does it do these weird things?
1884
+ List <GenericRecord > writeAndRead (TestSchema testSchema , List <GenericRecord > records ) throws IOException {
1885
+ // Create a temporary file for testing
1884
1886
File tmp = File .createTempFile (getClass ().getSimpleName (), ".tmp" );
1885
1887
tmp .deleteOnExit ();
1886
1888
tmp .delete ();
@@ -1894,9 +1896,9 @@ List<GenericRecord> writeAndRead(TestSchema testSchema, List<GenericRecord> reco
1894
1896
}
1895
1897
1896
1898
Configuration conf = new Configuration ();
1897
- // We need to set an explicit read schema, because Avro wrote the shredding schema as the Avro schema in the
1898
- // write, and it will use that by default. If we write using a proper shredding writer, the Avro schema
1899
- // should just contain a <metadata, value> record, and we won't need this.
1899
+ // We need to set an explicit read schema because Avro wrote the shredding schema as the Avro
1900
+ // schema in the write, and it will use that by default. If we write using a proper shredding
1901
+ // writer, the Avro schema should just contain a <metadata, value> record, and we won't need this.
1900
1902
AvroReadSupport .setAvroReadSchema (conf , avroSchema (testSchema .parquetSchema ));
1901
1903
AvroParquetReader <GenericRecord > reader = new AvroParquetReader (conf , path );
1902
1904
@@ -2124,7 +2126,9 @@ private static void checkShreddedType(Type shreddedType) {
2124
2126
shreddedType .getRepetition ());
2125
2127
}
2126
2128
2127
- // Check for the given excpetion with message, possibly wrapped by a ParquetDecodingException
2129
+ /**
2130
+ * Check for the given exception with message, possibly wrapped by a ParquetDecodingException.
2131
+ */
2128
2132
void assertThrows (Callable callable , Class <? extends Exception > exception , String msg ) {
2129
2133
try {
2130
2134
callable .call ();
@@ -2145,12 +2149,15 @@ void assertThrows(Callable callable, Class<? extends Exception> exception, Strin
2145
2149
}
2146
2150
}
2147
2151
2148
- // Assert that metadata contains identical bytes to expected, and value is logically equivalent.
2149
- // E.g. object fields may be ordered differently in the binary.
2152
+ /**
2153
+ * Assert that metadata contains identical bytes to expected, and value is logically equivalent.
2154
+ * E.g. object fields may be ordered differently in the binary.
2155
+ */
2150
2156
void assertEquivalent (ByteBuffer expectedMetadata , ByteBuffer expectedValue , GenericRecord actual ) {
2151
2157
assertEquals (expectedMetadata , (ByteBuffer ) actual .get ("metadata" ));
2152
2158
assertEquals (expectedMetadata , (ByteBuffer ) actual .get ("metadata" ));
2153
- assertEquivalent (new Variant (expectedValue , expectedMetadata ),
2159
+ assertEquivalent (
2160
+ new Variant (expectedValue , expectedMetadata ),
2154
2161
new Variant (((ByteBuffer ) actual .get ("value" )), expectedMetadata ));
2155
2162
}
2156
2163
0 commit comments