Search in sources :

Example 1 with SimpleAvroKeyGenerator

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);
    }
}
Also used : HoodieKeyGeneratorException(org.apache.hudi.exception.HoodieKeyGeneratorException) TimestampBasedAvroKeyGenerator(org.apache.hudi.keygen.TimestampBasedAvroKeyGenerator) CustomAvroKeyGenerator(org.apache.hudi.keygen.CustomAvroKeyGenerator) ComplexAvroKeyGenerator(org.apache.hudi.keygen.ComplexAvroKeyGenerator) NonpartitionedAvroKeyGenerator(org.apache.hudi.keygen.NonpartitionedAvroKeyGenerator) SimpleAvroKeyGenerator(org.apache.hudi.keygen.SimpleAvroKeyGenerator) KeyGeneratorType(org.apache.hudi.keygen.constant.KeyGeneratorType) GlobalAvroDeleteKeyGenerator(org.apache.hudi.keygen.GlobalAvroDeleteKeyGenerator)

Aggregations

HoodieKeyGeneratorException (org.apache.hudi.exception.HoodieKeyGeneratorException)1 ComplexAvroKeyGenerator (org.apache.hudi.keygen.ComplexAvroKeyGenerator)1 CustomAvroKeyGenerator (org.apache.hudi.keygen.CustomAvroKeyGenerator)1 GlobalAvroDeleteKeyGenerator (org.apache.hudi.keygen.GlobalAvroDeleteKeyGenerator)1 NonpartitionedAvroKeyGenerator (org.apache.hudi.keygen.NonpartitionedAvroKeyGenerator)1 SimpleAvroKeyGenerator (org.apache.hudi.keygen.SimpleAvroKeyGenerator)1 TimestampBasedAvroKeyGenerator (org.apache.hudi.keygen.TimestampBasedAvroKeyGenerator)1 KeyGeneratorType (org.apache.hudi.keygen.constant.KeyGeneratorType)1