Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
sunxiaojian committed Mar 27, 2024
1 parent 036366f commit dd5d186
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.SerializerProvider;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.module.SimpleModule;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.node.ArrayNode;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.paimon.shade.jackson2.com.fasterxml.jackson.databind.ser.std.StdSerializer;

Expand All @@ -44,7 +43,6 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -131,13 +129,10 @@ public static <T> T fromJson(String json, TypeReference<T> typeReference) {
}
}

public static ObjectNode appendArrayNode(
ObjectNode node, String fieldName, List<String> elememts) {
ArrayNode arrayNode = OBJECT_MAPPER_INSTANCE.createArrayNode();
for (String element : elememts) {
arrayNode.add(element);
}
node.set(fieldName, arrayNode);
public static <T> ObjectNode setNode(ObjectNode node, String fieldName, T value) {
ObjectMapper mapper = new ObjectMapper();
JsonNode nodeValue = OBJECT_MAPPER_INSTANCE.valueToTree(value);
node.set(fieldName, nodeValue);
return node;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static String extractPrimaryKeys(Pair<String, String> record) {
ObjectNode valueNode = JsonSerdeUtil.fromJson(record.getValue(), ObjectNode.class);

// append primary keys
JsonSerdeUtil.appendArrayNode(valueNode, FIELD_PRIMARY, primaryKeys);
JsonSerdeUtil.setNode(valueNode, FIELD_PRIMARY, primaryKeys);
return JsonSerdeUtil.writeValueAsString(valueNode);
} catch (JsonProcessingException e) {
throw new RuntimeException(
Expand Down

0 comments on commit dd5d186

Please sign in to comment.