HHH-8878 Avoid hot allocation in PooledLoOptimizer
This commit is contained in:
parent
03fa305667
commit
b644b515ef
|
@ -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 ) ) {
|
||||
|
|
Loading…
Reference in New Issue