sebwrede commented on a change in pull request #946: URL: https://github.com/apache/systemml/pull/946#discussion_r441438074
########## File path: src/main/java/org/apache/sysds/runtime/privacy/PrivacyMonitor.java ########## @@ -30,23 +30,33 @@ import org.apache.sysds.runtime.privacy.PrivacyConstraint.PrivacyLevel; public class PrivacyMonitor -{ - //TODO maybe maintain a log of checked constaints for transfers - // in order to provide 'privacy explanations' similar to our stats - private static ConcurrentHashMap<PrivacyLevel,LongAdder> checkedConstraints = new ConcurrentHashMap<PrivacyLevel,LongAdder>(); +{ + private static HashMap<PrivacyLevel,LongAdder> checkedConstraints; + + static { + checkedConstraints = new HashMap<PrivacyLevel,LongAdder>(); + for ( PrivacyLevel level : PrivacyLevel.values() ){ + checkedConstraints.put(level, new LongAdder()); + } + } + private static boolean checkPrivacy = false; - public static ConcurrentHashMap<PrivacyLevel,LongAdder> getCheckedConstraints(){ + public static HashMap<PrivacyLevel,LongAdder> getCheckedConstraints(){ return checkedConstraints; } private static void incrementCheckedConstraints(PrivacyLevel privacyLevel){ - if ( checkPrivacy ) - checkedConstraints.computeIfAbsent(privacyLevel, k -> new LongAdder()).increment(); + if ( checkPrivacy ){ + if ( privacyLevel == null ) + throw new NullPointerException("Cannot increment checked constraints log: Privacy level is null."); + checkedConstraints.get(privacyLevel).increment(); + } + } public static void clearCheckedConstraints(){ - checkedConstraints.clear(); + checkedConstraints.replaceAll((k,v)->new LongAdder()); Review comment: What is being duplicated? One of them creates the initial key-value pairs the other one resets them. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org