Search in sources :

Example 1 with RDDCustomColumnsSortPartitioner

use of org.apache.hudi.execution.bulkinsert.RDDCustomColumnsSortPartitioner in project hudi by apache.

the class TestHoodieClientOnCopyOnWriteStorage method testBulkInsertWithCustomPartitioner.

@Test
public void testBulkInsertWithCustomPartitioner() {
    HoodieWriteConfig config = getConfigBuilder().withRollbackUsingMarkers(true).build();
    try (SparkRDDWriteClient client = getHoodieWriteClient(config)) {
        final String commitTime1 = "001";
        client.startCommitWithTime(commitTime1);
        List<HoodieRecord> inserts1 = dataGen.generateInserts(commitTime1, 100);
        JavaRDD<HoodieRecord> insertRecordsRDD1 = jsc.parallelize(inserts1, 10);
        BulkInsertPartitioner<JavaRDD<HoodieRecord>> partitioner = new RDDCustomColumnsSortPartitioner(new String[] { "rider" }, HoodieTestDataGenerator.AVRO_SCHEMA, false);
        List<WriteStatus> statuses = client.bulkInsert(insertRecordsRDD1, commitTime1, Option.of(partitioner)).collect();
        assertNoWriteErrors(statuses);
    }
}
Also used : SparkRDDWriteClient(org.apache.hudi.client.SparkRDDWriteClient) RDDCustomColumnsSortPartitioner(org.apache.hudi.execution.bulkinsert.RDDCustomColumnsSortPartitioner) HoodieRecord(org.apache.hudi.common.model.HoodieRecord) HoodieWriteConfig(org.apache.hudi.config.HoodieWriteConfig) WriteStatus(org.apache.hudi.client.WriteStatus) JavaRDD(org.apache.spark.api.java.JavaRDD) HoodieJavaRDD(org.apache.hudi.data.HoodieJavaRDD) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

SparkRDDWriteClient (org.apache.hudi.client.SparkRDDWriteClient)1 WriteStatus (org.apache.hudi.client.WriteStatus)1 HoodieRecord (org.apache.hudi.common.model.HoodieRecord)1 HoodieWriteConfig (org.apache.hudi.config.HoodieWriteConfig)1 HoodieJavaRDD (org.apache.hudi.data.HoodieJavaRDD)1 RDDCustomColumnsSortPartitioner (org.apache.hudi.execution.bulkinsert.RDDCustomColumnsSortPartitioner)1 JavaRDD (org.apache.spark.api.java.JavaRDD)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1