You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/01/29 18:51:55 UTC

[GitHub] [incubator-hudi] n3nash commented on a change in pull request #1286: [HUDI-564] Added new test cases for HoodieLogFormat and HoodieLogFormatVersion.

n3nash 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_r372566780
 
 

 ##########
 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:
   nit : s/scheme/schema/

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services