Skip to content

Commit

Permalink
HSEARCH-2541 Push up some bypass code from AbstractLoader.executeLoad…
Browse files Browse the repository at this point in the history
… to AbstractLoader.load
  • Loading branch information
yrodiere committed Mar 6, 2017
1 parent df590b9 commit 5007ece
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate.search.query.hibernate.impl;

import java.util.Collections;
import java.util.List;

import org.hibernate.Session;
Expand Down Expand Up @@ -55,7 +56,22 @@ public List load(List<EntityInfo> entityInfos) {
startTime = System.nanoTime();
}

List loadedObjects = executeLoad( entityInfos );
List loadedObjects;
if ( entityInfos.isEmpty() ) {
loadedObjects = Collections.EMPTY_LIST;
}
else if ( entityInfos.size() == 1 ) {
final Object entity = executeLoad( entityInfos.get( 0 ) );
if ( entity == null ) {
loadedObjects = Collections.EMPTY_LIST;
}
else {
loadedObjects = Collections.singletonList( entity );
}
}
else {
loadedObjects = executeLoad( entityInfos );
}

if ( takeTimings ) {
statisticsImplementor.objectLoadExecuted( loadedObjects.size(), System.nanoTime() - startTime );
Expand Down
Expand Up @@ -7,7 +7,6 @@
package org.hibernate.search.query.hibernate.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -81,20 +80,6 @@ protected Object executeLoad(EntityInfo entityInfo) {

@Override
protected List executeLoad(List<EntityInfo> entityInfos) {
if ( entityInfos.isEmpty() ) {
return Collections.EMPTY_LIST;
}

if ( entityInfos.size() == 1 ) {
final Object entity = executeLoad( entityInfos.get( 0 ) );
if ( entity == null ) {
return Collections.EMPTY_LIST;
}
else {
return Collections.singletonList( entity );
}
}

LinkedHashMap<EntityInfoLoadKey, Object> idToObjectMap = new LinkedHashMap<>( (int) ( entityInfos.size() / 0.75 ) + 1 );

// split EntityInfo per root entity
Expand Down
Expand Up @@ -73,10 +73,6 @@ protected final List executeLoad(List<EntityInfo> entityInfos) {
throw new AssertionFailure( "EntityType not defined" );
}

if ( entityInfos.isEmpty() ) {
return Collections.EMPTY_LIST;
}

LinkedHashMap<EntityInfoLoadKey, Object> idToObjectMap = new LinkedHashMap<>( (int) ( entityInfos.size() / 0.75 ) + 1 );
for ( EntityInfo entityInfo : entityInfos ) {
idToObjectMap.put(
Expand Down

0 comments on commit 5007ece

Please sign in to comment.