prashantwason commented on a change in pull request #1286: [HUDI-564] Added new
test cases for HoodieLogFormat and HoodieLogFormatVersion.
URL: https://github.com/apache/incubator-hudi/pull/1286#discussion_r372571648
##########
File path:
hudi-common/src/test/java/org/apache/hudi/common/table/log/TestHoodieLogFormat.java
##########
@@ -1296,4 +1297,36 @@ public void testBasicAppendAndTraverseInReverse()
throws IOException, URISyntaxE
assertFalse(reader.hasPrev());
reader.close();
}
+
+ @Test
+ public void testV0Format() throws IOException, InterruptedException,
URISyntaxException {
+ // HoodieLogFormatVersion.DEFAULT_VERSION has been deprecated so we cannot
+ // create a writer for it. So these tests are only for the
HoodieAvroDataBlock
+ // of older version.
+ Schema schema = getSimpleSchema();
+ List<IndexedRecord> records = SchemaTestUtil.generateTestRecords(0, 100);
+ List<IndexedRecord> recordsCopy = new ArrayList<>(records);
+ assertEquals(records.size(), 100);
+ assertEquals(recordsCopy.size(), 100);
+ HoodieAvroDataBlock dataBlock = new HoodieAvroDataBlock(records, schema);
+ byte[] content = dataBlock.getBytes(schema);
+ assertTrue(content.length > 0);
+
+ HoodieLogBlock logBlock = HoodieAvroDataBlock.getBlock(content, schema);
+ assertEquals(logBlock.getBlockType(), HoodieLogBlockType.AVRO_DATA_BLOCK);
+ List<IndexedRecord> readRecords =
((HoodieAvroDataBlock)logBlock).getRecords();
+ assertEquals(readRecords.size(), recordsCopy.size());
+ for (int i = 0; i < recordsCopy.size(); ++i) {
+ assertEquals(recordsCopy.get(i), readRecords.get(i));
+ }
+
+ // Reader scheme is optional if it is same as write schema
Review comment:
Fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services