use of org.apache.hudi.keygen.SimpleAvroKeyGenerator in project hudi by apache.
the class HoodieAvroKeyGeneratorFactory method createAvroKeyGeneratorByType.
private static KeyGenerator createAvroKeyGeneratorByType(TypedProperties props) throws IOException {
// Use KeyGeneratorType.SIMPLE as default keyGeneratorType
String keyGeneratorType = props.getString(HoodieWriteConfig.KEYGENERATOR_TYPE.key(), null);
if (StringUtils.isNullOrEmpty(keyGeneratorType)) {
LOG.info("The value of {} is empty, using SIMPLE", HoodieWriteConfig.KEYGENERATOR_TYPE.key());
keyGeneratorType = KeyGeneratorType.SIMPLE.name();
}
KeyGeneratorType keyGeneratorTypeEnum;
try {
keyGeneratorTypeEnum = KeyGeneratorType.valueOf(keyGeneratorType.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
throw new HoodieKeyGeneratorException("Unsupported keyGenerator Type " + keyGeneratorType);
}
switch(keyGeneratorTypeEnum) {
case SIMPLE:
return new SimpleAvroKeyGenerator(props);
case COMPLEX:
return new ComplexAvroKeyGenerator(props);
case TIMESTAMP:
return new TimestampBasedAvroKeyGenerator(props);
case CUSTOM:
return new CustomAvroKeyGenerator(props);
case NON_PARTITION:
return new NonpartitionedAvroKeyGenerator(props);
case GLOBAL_DELETE:
return new GlobalAvroDeleteKeyGenerator(props);
default:
throw new HoodieKeyGeneratorException("Unsupported keyGenerator Type " + keyGeneratorType);
}
}
Aggregations