All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jpmml.model.visitors.DoubleInterner Maven / Gradle / Ivy

/*
 * Copyright (c) 2016 Villu Ruusmann
 */
package org.jpmml.model.visitors;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import org.dmg.pmml.RealSparseArray;
import org.dmg.pmml.VisitorAction;

/**
 * 

* A Visitor that interns {@link Double} attribute values. *

*/ public class DoubleInterner extends NumberInterner { public DoubleInterner(){ super(Double.class, DoubleInterner.CACHE_PROVIDER.get()); } @Override public Double canonicalize(Double value){ return value; } @Override public VisitorAction visit(RealSparseArray realSparseArray){ if(realSparseArray.hasEntries()){ internAll(realSparseArray.getEntries()); } return super.visit(realSparseArray); } static public void clear(){ DoubleInterner.cache.clear(); } private static final ConcurrentMap cache = new ConcurrentHashMap<>(); public static final ThreadLocal> CACHE_PROVIDER = new ThreadLocal>(){ @Override public ConcurrentMap initialValue(){ return DoubleInterner.cache; } }; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy