Skip to content

Commit

Permalink
refactor: remove computeIfAbsent
Browse files Browse the repository at this point in the history
  • Loading branch information
ekawinataa committed Dec 11, 2024
1 parent 811d1ab commit a10ec22
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ public MaxComputeProtobufConverterCache(MaxComputeSinkConfig maxComputeSinkConfi
}

public TypeInfo getOrCreateTypeInfo(Descriptors.FieldDescriptor fieldDescriptor) {
return typeInfoCache.computeIfAbsent(fieldDescriptor.getFullName(), key -> {
ProtobufMaxComputeConverter protobufMaxComputeConverter = getConverter(fieldDescriptor);
return protobufMaxComputeConverter.convertTypeInfo(fieldDescriptor);
});
if (typeInfoCache.containsKey(fieldDescriptor.getFullName())) {
return typeInfoCache.get(fieldDescriptor.getFullName());
}
ProtobufMaxComputeConverter protobufMaxComputeConverter = getConverter(fieldDescriptor);
TypeInfo typeInfo = protobufMaxComputeConverter.convertTypeInfo(fieldDescriptor);
typeInfoCache.put(fieldDescriptor.getFullName(), typeInfo);
return typeInfo;
}

public TypeInfo getOrCreateTypeInfo(Descriptors.FieldDescriptor fieldDescriptor, Supplier<TypeInfo> supplier) {
Expand Down

0 comments on commit a10ec22

Please sign in to comment.