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


##########
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();

Review Comment:
   I think we can change the object mapper as a class variable.



##########
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:
   If the code is working, I would remove this comment before we merge it. Is 
there a way we can unit test it? I think in the current version of this class 
this will be hard. But maybe we can open another issue to implement unit tests 
for this class and then refactor it. What do you think?



##########
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);

Review Comment:
   One more generic comment. We started to switch to the new `var` syntax. 
Could you please do the same when you make changes to the code. I know we have 
not yet implemented this consistently everywhere, but we want to adapt it bit 
by bit. 



-- 
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