You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/05/18 02:12:18 UTC
[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4138: [INLONG-4137][Manager] Add complex type (array, map, struct) for Hive sink
healchow commented on code in PR #4138:
URL: https://github.com/apache/incubator-inlong/pull/4138#discussion_r875405393
##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSinkTransfer.java:
##########
@@ -150,15 +151,23 @@ private static StreamSink parseClickHouseSink(ClickHouseSinkResponse sinkRespons
}
private static List<SinkField> convertToSinkFields(List<SinkFieldResponse> sinkFieldResponses) {
Review Comment:
Please add Java doc for the static method, thanks.
##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSinkTransfer.java:
##########
@@ -150,15 +151,23 @@ private static StreamSink parseClickHouseSink(ClickHouseSinkResponse sinkRespons
}
private static List<SinkField> convertToSinkFields(List<SinkFieldResponse> sinkFieldResponses) {
- return sinkFieldResponses.stream().map(sinkFieldResponse -> new SinkField(sinkFieldResponse.getId(),
- FieldType.forName(sinkFieldResponse.getFieldType()),
- sinkFieldResponse.getFieldName(),
- sinkFieldResponse.getFieldComment(),
- null, sinkFieldResponse.getSourceFieldName(),
- StringUtils.isBlank(sinkFieldResponse.getSourceFieldType()) ? null :
- FieldType.forName(sinkFieldResponse.getSourceFieldType()),
- sinkFieldResponse.getIsMetaField(),
- sinkFieldResponse.getFieldFormat())).collect(Collectors.toList());
+ List<SinkField> sinkFields = Lists.newArrayList();
+ for (SinkFieldResponse sinkFieldResponse : sinkFieldResponses) {
+ SinkField sinkField = new SinkField();
+ sinkField.setFieldType(transferfromstring(sinkFieldResponse.getFieldType()).getKey());
+ sinkField.setComplexSubType((String) transferfromstring(sinkFieldResponse.getFieldType()).getValue());
+ sinkField.setId(sinkFieldResponse.getId());
+ sinkField.setFieldName(sinkFieldResponse.getFieldName());
+ sinkField.setFieldComment(sinkFieldResponse.getFieldComment());
+ sinkField.setFieldValue(null);
+ sinkField.setSourceFieldName(sinkFieldResponse.getSourceFieldName());
+ sinkField.setSourceFieldType(StringUtils.isBlank(sinkFieldResponse.getSourceFieldType()) ? null :
+ FieldType.forName(sinkFieldResponse.getSourceFieldType()));
+ sinkField.setIsMetaField(sinkFieldResponse.getIsMetaField());
+ sinkField.setFieldFormat(sinkFieldResponse.getFieldFormat());
+ sinkFields.add(sinkField);
+ }
+ return sinkFields;
Review Comment:
Remove the unused blank line at the end of the method, thanks.
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/FieldInfoUtils.java:
##########
@@ -205,6 +222,24 @@ public static FormatInfo convertFieldFormat(String type) {
* @return Sort field format instance
*/
public static FormatInfo convertFieldFormat(String type, String format) {
+ String baseType = type.contains("<") ? type.substring(0, type.indexOf("<")) : type;
+ if (isComplexType(baseType)) {
+ Map<String, String> complexType = Maps.newHashMap();
+ complexType.put(baseType, type.substring(type.indexOf("<") + 1, type.length() - 1));
+ return transferComplexType(complexType);
+ } else {
+ return transferSimpleType(baseType, format);
+ }
+ }
+
+ /**
+ * Get the FieldFormat of Sort according to simple type string
+ *
+ * @param type
Review Comment:
If there are no comments for params, please remove them.
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/FieldInfoUtils.java:
##########
@@ -205,6 +222,24 @@ public static FormatInfo convertFieldFormat(String type) {
* @return Sort field format instance
*/
public static FormatInfo convertFieldFormat(String type, String format) {
Review Comment:
Java doc, please.
##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSinkTransfer.java:
##########
@@ -299,4 +312,12 @@ private static HiveSink parseHiveSink(HiveSinkResponse sinkResponse, StreamSink
return hiveSink;
}
+ public static Pair<FieldType, Object> transferfromstring(String type) {
Review Comment:
Java doc, please.
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/FieldInfoUtils.java:
##########
@@ -95,8 +105,15 @@ public static FieldInfo parseStreamFieldInfo(InlongStreamFieldInfo streamField,
public static FieldInfo parseStreamField(StreamField streamField) {
Review Comment:
Java doc, please.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org