ottobackwards commented on a change in pull request #257: URL: https://github.com/apache/plc4x/pull/257#discussion_r664037340
########## File path: plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java ########## @@ -0,0 +1,130 @@ +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) Review comment: So the logic would have to be (pseudo code): ``` // IF YOU ARE GOING TO JUST CACHE ONE currentValue = property.evaluateexpressions.getvalue if ( cachedSchema current key != currentValue) { // this is not the same, the cached object doesn't match // if we just cache the last schema we just dump the old on // and build a new one, setting it as the cached schema now cleanupCachedSchema() buildCachedSchema() cachedSchema current key = currentValue } // IF YOU ARE GOING TO CACHE MORE THAN ONE // if this is going to change a lot, and maybe the user configures it we *could* keep the // schema in a map based on the key ( let's say the value switches between 20 things ) currentValue = property.evaluateexpressions.getvalue if ( cached map does not contain current value ) { cached map add current value buildCachedSchema() } return cached map get current value ``` -- 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-unsubscr...@plc4x.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org