HHH-8878 Avoid hot allocation in PooledLoOptimizer

This commit is contained in:
Sanne Grinovero 2014-02-26 00:35:43 +00:00 committed by Brett Meyer
parent 03fa305667
commit b644b515ef
1 changed files with 3 additions and 1 deletions

View File

@ -507,6 +507,7 @@ public class OptimizerFactory {
public static class PooledLoOptimizer extends OptimizerSupport {
private IntegralDataTypeHolder lastSourceValue; // last value read from db source
private IntegralDataTypeHolder value; // the current generator value
private IntegralDataTypeHolder upperLimitValue; // the value at which we'll hit the db again
public PooledLoOptimizer(Class returnClass, int incrementSize) {
super( returnClass, incrementSize );
@ -518,8 +519,9 @@ public class OptimizerFactory {
@Override
public synchronized Serializable generate(AccessCallback callback) {
if ( lastSourceValue == null || ! value.lt( lastSourceValue.copy().add( incrementSize ) ) ) {
if ( lastSourceValue == null || ! value.lt( upperLimitValue ) ) {
lastSourceValue = callback.getNextValue();
upperLimitValue = lastSourceValue.copy().add( incrementSize );
value = lastSourceValue.copy();
// handle cases where initial-value is less that one (hsqldb for instance).
while ( value.lt( 1 ) ) {