[HUDI-1252] Remove unused class NoOpBulkInsertPartitioner in DataSourceTestUtils (#2054)
This commit is contained in:
@@ -18,16 +18,9 @@
|
|||||||
|
|
||||||
package org.apache.hudi.testutils;
|
package org.apache.hudi.testutils;
|
||||||
|
|
||||||
import org.apache.hudi.common.model.HoodieKey;
|
|
||||||
import org.apache.hudi.common.model.HoodieRecord;
|
|
||||||
import org.apache.hudi.common.model.HoodieRecordPayload;
|
|
||||||
import org.apache.hudi.common.testutils.RawTripTestPayload;
|
|
||||||
import org.apache.hudi.common.util.FileIOUtils;
|
import org.apache.hudi.common.util.FileIOUtils;
|
||||||
import org.apache.hudi.common.util.Option;
|
|
||||||
import org.apache.hudi.table.BulkInsertPartitioner;
|
|
||||||
|
|
||||||
import org.apache.avro.Schema;
|
import org.apache.avro.Schema;
|
||||||
import org.apache.spark.api.java.JavaRDD;
|
|
||||||
import org.apache.spark.sql.Row;
|
import org.apache.spark.sql.Row;
|
||||||
import org.apache.spark.sql.RowFactory;
|
import org.apache.spark.sql.RowFactory;
|
||||||
|
|
||||||
@@ -38,7 +31,6 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static org.apache.hudi.common.testutils.HoodieTestDataGenerator.DEFAULT_FIRST_PARTITION_PATH;
|
import static org.apache.hudi.common.testutils.HoodieTestDataGenerator.DEFAULT_FIRST_PARTITION_PATH;
|
||||||
import static org.apache.hudi.common.testutils.HoodieTestDataGenerator.DEFAULT_SECOND_PARTITION_PATH;
|
import static org.apache.hudi.common.testutils.HoodieTestDataGenerator.DEFAULT_SECOND_PARTITION_PATH;
|
||||||
@@ -49,43 +41,6 @@ import static org.apache.hudi.common.testutils.HoodieTestDataGenerator.DEFAULT_T
|
|||||||
*/
|
*/
|
||||||
public class DataSourceTestUtils {
|
public class DataSourceTestUtils {
|
||||||
|
|
||||||
public static Option<String> convertToString(HoodieRecord record) {
|
|
||||||
try {
|
|
||||||
String str = ((RawTripTestPayload) record.getData()).getJsonData();
|
|
||||||
str = "{" + str.substring(str.indexOf("\"timestamp\":"));
|
|
||||||
// Remove the last } bracket
|
|
||||||
str = str.substring(0, str.length() - 1);
|
|
||||||
return Option.of(str + ", \"partition\": \"" + record.getPartitionPath() + "\"}");
|
|
||||||
} catch (IOException e) {
|
|
||||||
return Option.empty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> convertToStringList(List<HoodieRecord> records) {
|
|
||||||
return records.stream().map(DataSourceTestUtils::convertToString).filter(Option::isPresent).map(Option::get)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> convertKeysToStringList(List<HoodieKey> keys) {
|
|
||||||
return keys.stream()
|
|
||||||
.map(hr -> "{\"_row_key\":\"" + hr.getRecordKey() + "\",\"partition\":\"" + hr.getPartitionPath() + "\"}")
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class NoOpBulkInsertPartitioner<T extends HoodieRecordPayload>
|
|
||||||
implements BulkInsertPartitioner<T> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaRDD<HoodieRecord<T>> repartitionRecords(JavaRDD<HoodieRecord<T>> records, int outputSparkPartitions) {
|
|
||||||
return records;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean arePartitionRecordsSorted() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Schema getStructTypeExampleSchema() throws IOException {
|
public static Schema getStructTypeExampleSchema() throws IOException {
|
||||||
return new Schema.Parser().parse(FileIOUtils.readAsUTFString(DataSourceTestUtils.class.getResourceAsStream("/exampleSchema.txt")));
|
return new Schema.Parser().parse(FileIOUtils.readAsUTFString(DataSourceTestUtils.class.getResourceAsStream("/exampleSchema.txt")));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user