muyangye commented on code in PR #2196:
URL: https://github.com/apache/streampipes/pull/2196#discussion_r1403095559


##########
streampipes-data-explorer-commons/src/main/java/org/apache/streampipes/dataexplorer/commons/influx/InfluxStore.java:
##########
@@ -218,6 +226,21 @@ private void handleMeasurementProperty(Point.Builder p,
     }
   }
 
+  private void handleNonPrimitiveMeasurementProperty(Point.Builder p, Event 
event, String preparedRuntimeName) {
+    var field = event.getRaw().get(preparedRuntimeName);
+    ObjectMapper mapper = new ObjectMapper();
+    try {
+      String json = mapper.writeValueAsString(field);
+      p.addField(preparedRuntimeName, json);
+      // Deserialize in this way, tested the primitive types can be correctly 
deducted from Object
+//      TypeFactory typeFactory = mapper.getTypeFactory();

Review Comment:
   I agree, probably we should refactor the serialization/deserialization logic 
into a class called `FieldSerializer`, in which the `Serialize` method takes an 
`AbstractField` and returns a `String` and the `Deserialize` method takes a 
`String` and return a `Map<string, deserialized type (as opposed to Object in 
my comments)>`. For deserialization, I plan to write a recursive function in 
which the base case is when the value is primitive or List. Do you want me to 
write all that logic in this PR?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to