Skip to content

Commit b4db097

Browse files
committed
Remove usage of CustomKeyGenerator
1 parent 5b6839e commit b4db097

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/factory/HoodieAvroKeyGeneratorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static KeyGenerator createKeyGenerator(TypedProperties props) throws IOEx
5454
return Objects.isNull(keyGenerator) ? createAvroKeyGeneratorByType(props) : keyGenerator;
5555
}
5656

57-
private static KeyGenerator createAvroKeyGeneratorByType(TypedProperties props) throws IOException {
57+
public static KeyGenerator createAvroKeyGeneratorByType(TypedProperties props) throws IOException {
5858
// Use KeyGeneratorType.SIMPLE as default keyGeneratorType
5959
String keyGeneratorType =
6060
props.getString(HoodieWriteConfig.KEYGENERATOR_TYPE.key(), null);

hudi-kafka-connect/src/main/java/org/apache/hudi/connect/utils/KafkaConnectUtils.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
package org.apache.hudi.connect.utils;
2020

21-
import com.google.protobuf.ByteString;
22-
import org.apache.hadoop.conf.Configuration;
2321
import org.apache.hudi.client.WriteStatus;
2422
import org.apache.hudi.common.config.TypedProperties;
2523
import org.apache.hudi.common.model.HoodieCommitMetadata;
@@ -36,9 +34,11 @@
3634
import org.apache.hudi.exception.HoodieException;
3735
import org.apache.hudi.keygen.BaseKeyGenerator;
3836
import org.apache.hudi.keygen.CustomAvroKeyGenerator;
39-
import org.apache.hudi.keygen.CustomKeyGenerator;
4037
import org.apache.hudi.keygen.KeyGenerator;
4138
import org.apache.hudi.keygen.constant.KeyGeneratorOptions;
39+
40+
import com.google.protobuf.ByteString;
41+
import org.apache.hadoop.conf.Configuration;
4242
import org.apache.kafka.clients.admin.AdminClient;
4343
import org.apache.kafka.clients.admin.DescribeTopicsResult;
4444
import org.apache.kafka.clients.admin.TopicDescription;
@@ -185,8 +185,7 @@ public static String getRecordKeyColumns(KeyGenerator keyGenerator) {
185185
* @return partition columns Returns the partition columns separated by comma.
186186
*/
187187
public static String getPartitionColumns(KeyGenerator keyGenerator, TypedProperties typedProperties) {
188-
189-
if (keyGenerator instanceof CustomKeyGenerator || keyGenerator instanceof CustomAvroKeyGenerator) {
188+
if (keyGenerator instanceof CustomAvroKeyGenerator) {
190189
return ((BaseKeyGenerator) keyGenerator).getPartitionPathFields().stream().map(
191190
pathField -> Arrays.stream(pathField.split(CustomAvroKeyGenerator.SPLIT_REGEX))
192191
.findFirst().orElse("Illegal partition path field format: '$pathField' for ${c.getClass.getSimpleName}"))
@@ -200,7 +199,6 @@ public static String getPartitionColumns(KeyGenerator keyGenerator, TypedPropert
200199
return typedProperties.getString(KeyGeneratorOptions.PARTITIONPATH_FIELD_NAME.key());
201200
}
202201

203-
204202
/**
205203
* Get the Metadata from the latest commit file.
206204
*

hudi-kafka-connect/src/main/java/org/apache/hudi/connect/writers/KafkaConnectTransactionServices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public KafkaConnectTransactionServices(KafkaConnectConfigs connectConfigs) throw
8484
context = new HoodieJavaEngineContext(hadoopConf);
8585

8686
try {
87-
KeyGenerator keyGenerator = HoodieAvroKeyGeneratorFactory.createKeyGenerator(
87+
KeyGenerator keyGenerator = HoodieAvroKeyGeneratorFactory.createAvroKeyGeneratorByType(
8888
new TypedProperties(connectConfigs.getProps()));
8989
String recordKeyFields = KafkaConnectUtils.getRecordKeyColumns(keyGenerator);
9090
String partitionColumns = KafkaConnectUtils.getPartitionColumns(keyGenerator,

0 commit comments

Comments
 (0)