From: <one...@us...> - 2003-04-10 09:49:22
|
Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl In directory sc8-pr-cvs1:/tmp/cvs-serv4460/hibernate/impl Modified Files: SessionFactoryImpl.java Log Message: improvements to: * USE_REFLECTION_OPTIMIZER * Nonstrict cache * javadoc fixed bug in collection filter cache Index: SessionFactoryImpl.java =================================================================== RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/impl/SessionFactoryImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** SessionFactoryImpl.java 8 Apr 2003 14:26:40 -0000 1.17 --- SessionFactoryImpl.java 10 Apr 2003 09:49:16 -0000 1.18 *************** *** 97,101 **** private transient final boolean showSql; private transient final boolean useOuterJoin; - private transient final boolean useReflectionOptimizer; private transient final boolean supportsLocking; private transient final Templates templates; --- 97,100 ---- *************** *** 133,137 **** //temp.putAll( Environment.getProperties() ); temp.putAll( dl.getDefaultProperties() ); - temp.put(Environment.USE_REFLECTION_OPTIMIZER, Boolean.TRUE); temp.putAll(properties); properties = temp; // add the dialects default properties --- 132,135 ---- *************** *** 155,160 **** log.info("Use outer join fetching: " + useOuterJoin); - useReflectionOptimizer = PropertiesHelper.getBoolean(Environment.USE_REFLECTION_OPTIMIZER, properties); - boolean usrs = PropertiesHelper.getBoolean(Environment.USE_SCROLLABLE_RESULTSET, properties); int batchSize = PropertiesHelper.getInt(Environment.STATEMENT_BATCH_SIZE, properties, 0); --- 153,156 ---- *************** *** 294,298 **** // Emulates constant time LRU/MRU algorithms for cache // It is better to hold strong refernces on some (LRU/MRU) queries ! private transient final int MAX_STRONG_REF_COUNT = 128; //TODO: configurable? private transient final Object strongRefs[] = new Object[MAX_STRONG_REF_COUNT]; //strong reference to MRU queries private transient int strongRefIndex = 0; --- 290,294 ---- // Emulates constant time LRU/MRU algorithms for cache // It is better to hold strong refernces on some (LRU/MRU) queries ! private static transient final int MAX_STRONG_REF_COUNT = 128; //TODO: configurable? private transient final Object strongRefs[] = new Object[MAX_STRONG_REF_COUNT]; //strong reference to MRU queries private transient int strongRefIndex = 0; *************** *** 300,313 **** // both keys and values may be soft since value keeps a hard ref to the key (and there is a hard ref to MRU values) - private static QueryCacheKeyFactory keyFactory = (QueryCacheKeyFactory) KeyFactory.create( - QueryCacheKeyFactory.class, QueryCacheKeyFactory.class.getClassLoader() - ); - //returns generated class instance ! interface QueryCacheKeyFactory { //Will not recalculate hashKey for constant queries Object newInstance(String query, boolean scalar); } //TODO: this stuff can be implemented in separate class to reuse soft MRU/LRU caching private synchronized Object get(Object key) { --- 296,321 ---- // both keys and values may be soft since value keeps a hard ref to the key (and there is a hard ref to MRU values) //returns generated class instance ! private static final QueryCacheKeyFactory QUERY_KEY_FACTORY; ! private static final FilterCacheKeyFactory FILTER_KEY_FACTORY; ! static { ! QUERY_KEY_FACTORY = (QueryCacheKeyFactory) KeyFactory.create( ! QueryCacheKeyFactory.class, QueryCacheKeyFactory.class.getClassLoader() ! ); ! FILTER_KEY_FACTORY = (FilterCacheKeyFactory) KeyFactory.create( ! FilterCacheKeyFactory.class, FilterCacheKeyFactory.class.getClassLoader() ! ); ! } ! ! static interface QueryCacheKeyFactory { //Will not recalculate hashKey for constant queries Object newInstance(String query, boolean scalar); } + static interface FilterCacheKeyFactory { + //Will not recalculate hashKey for constant queries + Object newInstance(String role, String query, boolean scalar); + } + //TODO: this stuff can be implemented in separate class to reuse soft MRU/LRU caching private synchronized Object get(Object key) { *************** *** 335,339 **** private QueryTranslator getQuery(String query, boolean shallow) throws QueryException, MappingException { ! Object cacheKey = keyFactory.newInstance(query, shallow); // have to be careful to ensure that if the JVM does out-of-order execution --- 343,347 ---- private QueryTranslator getQuery(String query, boolean shallow) throws QueryException, MappingException { ! Object cacheKey = QUERY_KEY_FACTORY.newInstance(query, shallow); // have to be careful to ensure that if the JVM does out-of-order execution *************** *** 355,359 **** public FilterTranslator getFilter(String query, String collectionRole, boolean scalar) throws QueryException, MappingException { ! Object cacheKey = keyFactory.newInstance(query, scalar); FilterTranslator q = (FilterTranslator) get(cacheKey); --- 363,367 ---- public FilterTranslator getFilter(String query, String collectionRole, boolean scalar) throws QueryException, MappingException { ! Object cacheKey = FILTER_KEY_FACTORY.newInstance(collectionRole, query, scalar); FilterTranslator q = (FilterTranslator) get(cacheKey); *************** *** 697,704 **** if (statementCache!=null) statementCache.close(); connections.close(); - } - - public boolean useReflectionOptimizer() { - return useReflectionOptimizer; } --- 705,708 ---- |