Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Commits List »

[hibernate-commits] Hibernate SVN: r14819 -
 search/trunk/src/java/org/hibernate/search/engine.

hibernate-commits

2008-06-29


Author LoginPost Reply
Author: epbernard
Date: 2008-06-29 04:18:20 -0400 (Sun, 29 Jun 2008)
New Revision: 14819

Modified:
 search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
 search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java
Log:
Minor optimization: use simple object loading when the List of EntityInfo is of size one

Modified: search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java  2008-06-28 10:51:13 UTC (rev 14818)
+++ search/trunk/src/java/org/hibernate/search/engine/MultiClassesQueryLoader.java  2008-06-29 08:18:20 UTC (rev 14819)
@@(protected) @@

 public List load(EntityInfo... entityInfos) {
   if ( entityInfos.length == 0 ) return Collections.EMPTY_LIST;
+    if ( entityInfos.length == 1 ) {
+      final Object entity = load( entityInfos[0] );
+      if ( entity == null ) {
+        return Collections.EMPTY_LIST;
+      }
+      else {
+        final List<Object> list = new ArrayList<Object>( 1 );
+        list.add( entity );
+        return list;
+      }
+    }
+
   //split EntityInfo per root entity
   Map<RootEntityMetadata, List<EntityInfo>> entityinfoBuckets =
       new HashMap<RootEntityMetadata, List<EntityInfo>>( entityMatadata.size());

Modified: search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java  2008-06-28 10:51:13 UTC (rev 14818)
+++ search/trunk/src/java/org/hibernate/search/engine/ObjectLoader.java  2008-06-29 08:18:20 UTC (rev 14819)
@@(protected) @@

import java.util.ArrayList;
import java.util.List;
+import java.util.Collections;

import org.hibernate.Hibernate;
import org.hibernate.Session;
@@(protected) @@
 }

 public List load(EntityInfo... entityInfos) {
+    if ( entityInfos.length == 0 ) return Collections.EMPTY_LIST;
+    if ( entityInfos.length == 1 ) {
+      final Object entity = load( entityInfos[0] );
+      if ( entity == null ) {
+        return Collections.EMPTY_LIST;
+      }
+      else {
+        final List<Object> list = new ArrayList<Object>( 1 );
+        list.add( entity );
+        return list;
+      }
+    }
   //use load to benefit from the batch-size
   //we don't face proxy casting issues since the exact class is extracted from the index
   for (EntityInfo entityInfo : entityInfos) {

_______________________________________________
hibernate-commits mailing list
hibernate-commits@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-commits
©2008 gg3721.com - Jax Systems, LLC, U.S.A.