1
0

[HUDI-3701] Flink bulk_insert support bucket hash index (#5118)

This commit is contained in:
Danny Chan
2022-03-25 09:01:42 +08:00
committed by GitHub
parent 608d4bf32d
commit 5e86cdd1e9
12 changed files with 169 additions and 27 deletions

View File

@@ -38,11 +38,15 @@ public class BucketIdentifier {
}
public static int getBucketId(HoodieKey hoodieKey, String indexKeyFields, int numBuckets) {
return getBucketId(hoodieKey.getRecordKey(), indexKeyFields, numBuckets);
}
public static int getBucketId(String recordKey, String indexKeyFields, int numBuckets) {
List<String> hashKeyFields;
if (!hoodieKey.getRecordKey().contains(":")) {
hashKeyFields = Collections.singletonList(hoodieKey.getRecordKey());
if (!recordKey.contains(":")) {
hashKeyFields = Collections.singletonList(recordKey);
} else {
Map<String, String> recordKeyPairs = Arrays.stream(hoodieKey.getRecordKey().split(","))
Map<String, String> recordKeyPairs = Arrays.stream(recordKey.split(","))
.map(p -> p.split(":"))
.collect(Collectors.toMap(p -> p[0], p -> p[1]));
hashKeyFields = Arrays.stream(indexKeyFields.split(","))