You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@plc4x.apache.org by GitBox <gi...@apache.org> on 2022/08/02 19:39:14 UTC

[GitHub] [plc4x] chrisdutz commented on a diff in pull request #439: feature/nifi-record-2

chrisdutz commented on code in PR #439:
URL: https://github.com/apache/plc4x/pull/439#discussion_r935960455


##########
plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java:
##########
@@ -0,0 +1,128 @@
+package org.apache.plc4x.nifi.record;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.serialization.record.MapRecord;
+import org.apache.nifi.serialization.record.Record;
+import org.apache.nifi.serialization.record.RecordField;
+import org.apache.nifi.serialization.record.RecordSchema;
+import org.apache.nifi.serialization.record.RecordSet;
+import org.apache.plc4x.java.api.messages.PlcReadResponse;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.nifi.util.Plc4xCommon;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class Plc4xReadResponseRecordSet implements RecordSet, Closeable {
+    private static final Logger logger = LoggerFactory.getLogger(Plc4xReadResponseRecordSet.class);
+    private final PlcReadResponse readResponse;
+    private final Set<String> rsColumnNames;
+    private boolean moreRows;
+
+    // TODO: review this AtomicReference?
+	// TODO: this could be enhanced checking if record schema should be updated (via a cache boolean, checking property values is a nifi expression language, etc)
+  	private AtomicReference<RecordSchema> recordSchema;
+  	// inigo private AtomicReference<Map<String, RecordSchema>> map 
+
+    public Plc4xReadResponseRecordSet(final PlcReadResponse readResponse) throws IOException {
+        this.readResponse = readResponse;
+        moreRows = true;
+        
+        logger.debug("Creating record schema from PlcReadResponse");
+        Map<String, ? extends PlcValue> responseDataStructure = readResponse.getAsPlcValue().getStruct();
+        rsColumnNames = responseDataStructure.keySet();
+        

Review Comment:
   Which word in this is not english?



-- 
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: dev-unsubscribe@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org