This is an automated email from the ASF dual-hosted git repository.

smarthi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new cf0a4c1  [HUDI-670] Added test cases for TestDiskBasedMap. (#1379)
cf0a4c1 is described below

commit cf0a4c19bc4ed850172e6ac938f57a0bf7e96353
Author: Prashant Wason <pwa...@uber.com>
AuthorDate: Wed Mar 11 05:03:03 2020 -0700

    [HUDI-670] Added test cases for TestDiskBasedMap. (#1379)
    
    * [HUDI-670] Added test cases for TestDiskBasedMap.
    
    * Update TestDiskBasedMap.java
    
    Co-authored-by: Suneel Marthi <smar...@apache.org>
---
 .../common/util/collection/TestDiskBasedMap.java   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git 
a/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestDiskBasedMap.java
 
b/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestDiskBasedMap.java
old mode 100644
new mode 100755
index 2cc726e..3fcfab5
--- 
a/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestDiskBasedMap.java
+++ 
b/hudi-common/src/test/java/org/apache/hudi/common/util/collection/TestDiskBasedMap.java
@@ -20,6 +20,7 @@ package org.apache.hudi.common.util.collection;
 
 import org.apache.hudi.common.HoodieCommonTestHarness;
 import org.apache.hudi.common.model.AvroBinaryTestPayload;
+import org.apache.hudi.common.model.HoodieAvroPayload;
 import org.apache.hudi.common.model.HoodieKey;
 import org.apache.hudi.common.model.HoodieRecord;
 import org.apache.hudi.common.model.HoodieRecordPayload;
@@ -42,9 +43,11 @@ import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 import java.util.stream.Collectors;
@@ -184,6 +187,28 @@ public class TestDiskBasedMap extends 
HoodieCommonTestHarness {
     assertTrue(payloadSize > 0);
   }
 
+  @Test
+  public void testPutAll() throws IOException, URISyntaxException {
+    DiskBasedMap<String, HoodieRecord> records = new DiskBasedMap<>(basePath);
+    List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 
100);
+    Map<String, HoodieRecord> recordMap = new HashMap<>();
+    iRecords.forEach(r -> {
+      String key = ((GenericRecord) 
r).get(HoodieRecord.RECORD_KEY_METADATA_FIELD).toString();
+      String partitionPath = ((GenericRecord) 
r).get(HoodieRecord.PARTITION_PATH_METADATA_FIELD).toString();
+      HoodieRecord value = new HoodieRecord<>(new HoodieKey(key, 
partitionPath), new HoodieAvroPayload(Option.of((GenericRecord) r)));
+      recordMap.put(key, value);
+    });
+
+    records.putAll(recordMap);
+    // make sure records have spilled to disk
+    assertTrue(records.sizeOfFileOnDiskInBytes() > 0);
+
+    // make sure all added records are present
+    for (Map.Entry<String, HoodieRecord> entry : records.entrySet()) {
+      assertTrue(recordMap.containsKey(entry.getKey()));
+    }
+  }
+
   /**
    * @na: Leaving this test here for a quick performance test
    */

Reply via email to