
com.avaje.ebeaninternal.server.query.LoadedPropertiesCache Maven / Gradle / Ivy
package com.avaje.ebeaninternal.server.query;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import com.avaje.ebeaninternal.server.deploy.BeanDescriptor;
public class LoadedPropertiesCache {
static ConcurrentHashMap> cache = new ConcurrentHashMap>(250, 0.75f, 16);
public static Set get(int partialHash, Set partialProps, BeanDescriptor> desc){
int manyHash = desc.getNamesOfManyPropsHash();
int totalHash = 37*partialHash + manyHash;
Integer key = Integer.valueOf(totalHash);
Set includedProps = cache.get(key);
if (includedProps == null){
// its not in the cache so build it
LinkedHashSet mergeNames = new LinkedHashSet();
mergeNames.addAll(partialProps);
if (manyHash != 0){
mergeNames.addAll(desc.getNamesOfManyProps());
}
// we want it to be immutable and cache it
includedProps = Collections.unmodifiableSet(mergeNames);
cache.put(key, includedProps);
}
return includedProps;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy