Search in sources :

Example 1 with BootstrapRegexModeSelector

use of org.apache.hudi.client.bootstrap.selector.BootstrapRegexModeSelector in project hudi by apache.

the class TestBootstrapRegexModeSelector method testModeSelector.

@Test
public void testModeSelector() {
    List<String> partitionPaths = Arrays.asList("2020/05/01", "2020/05/02", "2020/05/10", "2020/05/11");
    List<Pair<String, List<HoodieFileStatus>>> input = partitionPaths.stream().map(p -> Pair.<String, List<HoodieFileStatus>>of(p, new ArrayList<>())).collect(Collectors.toList());
    String regex = "2020/05/1[0-9]";
    BootstrapRegexModeSelector regexModeSelector = new BootstrapRegexModeSelector(getConfig(regex, BootstrapMode.FULL_RECORD));
    Map<BootstrapMode, List<String>> result = regexModeSelector.select(input);
    assertTrue(result.get(BootstrapMode.METADATA_ONLY).contains("2020/05/01"));
    assertTrue(result.get(BootstrapMode.METADATA_ONLY).contains("2020/05/02"));
    assertTrue(result.get(BootstrapMode.FULL_RECORD).contains("2020/05/10"));
    assertTrue(result.get(BootstrapMode.FULL_RECORD).contains("2020/05/11"));
    assertEquals(2, result.get(BootstrapMode.METADATA_ONLY).size());
    assertEquals(2, result.get(BootstrapMode.FULL_RECORD).size());
    regexModeSelector = new BootstrapRegexModeSelector(getConfig(regex, BootstrapMode.METADATA_ONLY));
    result = regexModeSelector.select(input);
    assertTrue(result.get(BootstrapMode.FULL_RECORD).contains("2020/05/01"));
    assertTrue(result.get(BootstrapMode.FULL_RECORD).contains("2020/05/02"));
    assertTrue(result.get(BootstrapMode.METADATA_ONLY).contains("2020/05/10"));
    assertTrue(result.get(BootstrapMode.METADATA_ONLY).contains("2020/05/11"));
    assertEquals(2, result.get(BootstrapMode.METADATA_ONLY).size());
    assertEquals(2, result.get(BootstrapMode.FULL_RECORD).size());
}
Also used : Arrays(java.util.Arrays) HoodieWriteConfig(org.apache.hudi.config.HoodieWriteConfig) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) BootstrapRegexModeSelector(org.apache.hudi.client.bootstrap.selector.BootstrapRegexModeSelector) List(java.util.List) HoodieFileStatus(org.apache.hudi.avro.model.HoodieFileStatus) Map(java.util.Map) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Pair(org.apache.hudi.common.util.collection.Pair) HoodieBootstrapConfig(org.apache.hudi.config.HoodieBootstrapConfig) HoodieFileStatus(org.apache.hudi.avro.model.HoodieFileStatus) ArrayList(java.util.ArrayList) List(java.util.List) BootstrapRegexModeSelector(org.apache.hudi.client.bootstrap.selector.BootstrapRegexModeSelector) Pair(org.apache.hudi.common.util.collection.Pair) Test(org.junit.jupiter.api.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 HoodieFileStatus (org.apache.hudi.avro.model.HoodieFileStatus)1 BootstrapRegexModeSelector (org.apache.hudi.client.bootstrap.selector.BootstrapRegexModeSelector)1 Pair (org.apache.hudi.common.util.collection.Pair)1 HoodieBootstrapConfig (org.apache.hudi.config.HoodieBootstrapConfig)1 HoodieWriteConfig (org.apache.hudi.config.HoodieWriteConfig)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Test (org.junit.jupiter.api.Test)1