mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-23 19:57:08 +00:00
HHH-8878 Avoid hot allocation in PooledLoOptimizer
This commit is contained in:
parent
03fa305667
commit
b644b515ef
@ -507,6 +507,7 @@ public void injectInitialValue(long initialValue) {
|
||||
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 PooledLoOptimizer(Class returnClass, int incrementSize) {
|
||||
|
||||
@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…
x
Reference in New Issue
Block a user