HHH-8878 Avoid hot allocation in PooledLoOptimizer

Conflicts:
	hibernate-core/src/main/java/org/hibernate/id/enhanced/OptimizerFactory.java
This commit is contained in:
Sanne Grinovero 2014-02-26 18:51:27 -05:00 committed by Brett Meyer
parent a34d740eba
commit 2798e9d8e3
1 changed files with 4 additions and 1 deletions

View File

@ -51,6 +51,8 @@ public class PooledLoOptimizer extends AbstractOptimizer {
private IntegralDataTypeHolder lastSourceValue;
// the current generator value
private IntegralDataTypeHolder value;
// the value at which we'll hit the db again
private IntegralDataTypeHolder upperLimitValue;
}
/**
@ -72,8 +74,9 @@ public class PooledLoOptimizer extends AbstractOptimizer {
final GenerationState generationState = locateGenerationState( callback.getTenantIdentifier() );
if ( generationState.lastSourceValue == null
|| ! generationState.value.lt( generationState.lastSourceValue.copy().add( incrementSize ) ) ) {
|| ! generationState.value.lt( generationState.upperLimitValue ) ) {
generationState.lastSourceValue = callback.getNextValue();
generationState.upperLimitValue = generationState.lastSourceValue.copy().add( incrementSize );
generationState.value = generationState.lastSourceValue.copy();
// handle cases where initial-value is less that one (hsqldb for instance).
while ( generationState.value.lt( 1 ) ) {