ottobackwards commented on code in PR #755: URL: https://github.com/apache/plc4x/pull/755#discussion_r1088235056
########## plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java: ########## @@ -58,9 +58,10 @@ public Plc4xReadResponseRecordSet(final PlcReadResponse readResponse) throws IOE rsColumnNames = responseDataStructure.keySet(); if (recordSchema == null) { Review Comment: Could we not cache here as well? ########## plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/Plc4xReadResponseRecordSet.java: ########## @@ -47,9 +47,9 @@ public class Plc4xReadResponseRecordSet implements RecordSet, Closeable { Review Comment: Are these TODO's still valid? ########## plc4j/integrations/apache-nifi/nifi-plc4x-processors/src/main/java/org/apache/plc4x/nifi/record/SchemaCache.java: ########## @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.plc4x.nifi.record; + +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReferenceArray; + +import org.apache.nifi.serialization.record.RecordSchema; +import org.apache.plc4x.java.api.model.PlcTag; + +public class SchemaCache { + private ConcurrentMap<String, SchemaContainer> schemaMap = new ConcurrentHashMap<>(); + private AtomicReferenceArray<String> schemaAppendOrder = new AtomicReferenceArray<>(0); + private final AtomicInteger lastSchemaPosition = new AtomicInteger(0); + private final AtomicInteger cacheSize = new AtomicInteger(0); + + public SchemaCache(int cacheSize) { + this.cacheSize.set(cacheSize); + } + + public void setCacheSize(int cacheSize) { + this.cacheSize.set(cacheSize); + schemaAppendOrder = new AtomicReferenceArray<>(cacheSize); + schemaMap = new ConcurrentHashMap<>(); + } + Review Comment: We need tests for this class to ensure it works properly. Some JavaDoc would be nice here too. Also it would be nice if there were some logging here or elsewhere of cache misses etc, in DEBUG mode/level -- 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