[hibernate-commits] Hibernate SVN: r14838 - in search/branches/jboss_cache_integration/src/java/org/hibernate/search: engine and 1 other directory.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Tue Jul 1 12:55:25 EDT 2008
Author: navssurtani
Date: 2008-07-01 12:55:24 -0400 (Tue, 01 Jul 2008)
New Revision: 14838
Modified:
search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java
search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java
search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentExtractor.java
Log:
Changed DocumentBuilder and @ProvidedId
Modified: search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java
===================================================================
--- search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java 2008-07-01 15:06:41 UTC (rev 14837)
+++ search/branches/jboss_cache_integration/src/java/org/hibernate/search/annotations/ProvidedId.java 2008-07-01 16:55:24 UTC (rev 14838)
@@ -1,5 +1,7 @@
package org.hibernate.search.annotations;
+import org.hibernate.search.bridge.StringBridge;
+
import java.lang.annotation.*;
/**
@@ -16,5 +18,5 @@
{
String name() default "JBCS_ProvidedId";
- FieldBridge bridge() default @FieldBridge(impl=org.hibernate.search.bridge.builtin.StringBridge.class);
+ Class<StringBridge> bridge() default StringBridge.class;
}
Modified: search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-07-01 15:06:41 UTC (rev 14837)
+++ search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentBuilder.java 2008-07-01 16:55:24 UTC (rev 14838)
@@ -38,6 +38,7 @@
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.TwoWayFieldBridge;
import org.hibernate.search.bridge.TwoWayString2FieldBridgeAdaptor;
+import org.hibernate.search.bridge.builtin.StringBridge;
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.search.store.IndexShardingStrategy;
import org.hibernate.search.util.BinderHelper;
@@ -113,7 +114,7 @@
}
else
{
- idBridge = provided.bridge();
+ idBridge = getProvidedIdBridge();
idKeywordName = provided.name();
}
}
@@ -134,6 +135,12 @@
return getAnalyzer(analyzerAnn, context);
}
+ private TwoWayFieldBridge getProvidedIdBridge()
+ {
+ return new TwoWayString2FieldBridgeAdaptor(new StringBridge());
+ }
+
+
private Analyzer getAnalyzer(org.hibernate.search.annotations.Analyzer analyzerAnn, InitContext context)
{
Class analyzerClass = analyzerAnn == null ? void.class : analyzerAnn.impl();
Modified: search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentExtractor.java
===================================================================
--- search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentExtractor.java 2008-07-01 15:06:41 UTC (rev 14837)
+++ search/branches/jboss_cache_integration/src/java/org/hibernate/search/engine/DocumentExtractor.java 2008-07-01 16:55:24 UTC (rev 14838)
@@ -13,56 +13,69 @@
* @author Emmanuel Bernard
* @author John Griffin
*/
-public class DocumentExtractor {
- private final SearchFactoryImplementor searchFactoryImplementor;
- private final String[] projection;
+public class DocumentExtractor
+{
+ private final SearchFactoryImplementor searchFactoryImplementor;
+ private final String[] projection;
- public DocumentExtractor(SearchFactoryImplementor searchFactoryImplementor, String... projection) {
- this.searchFactoryImplementor = searchFactoryImplementor;
- this.projection = projection;
- }
+ public DocumentExtractor(SearchFactoryImplementor searchFactoryImplementor, String... projection)
+ {
+ this.searchFactoryImplementor = searchFactoryImplementor;
+ this.projection = projection;
+ }
- private EntityInfo extract(Document document) {
- Class clazz = DocumentBuilder.getDocumentClass( document );
- Serializable id = DocumentBuilder.getDocumentId( searchFactoryImplementor, clazz, document );
- Object[] projected = null;
- if ( projection != null && projection.length > 0 ) {
- projected = DocumentBuilder.getDocumentFields( searchFactoryImplementor, clazz, document, projection );
- }
- EntityInfo entityInfo = new EntityInfo( clazz, id, projected );
- return entityInfo;
- }
+ private EntityInfo extract(Document document)
+ {
+ Class clazz = DocumentBuilder.getDocumentClass(document);
+ Serializable id = DocumentBuilder.getDocumentId(searchFactoryImplementor, clazz, document);
+ Object[] projected = null;
+ if (projection != null && projection.length > 0)
+ {
+ projected = DocumentBuilder.getDocumentFields(searchFactoryImplementor, clazz, document, projection);
+ }
+ EntityInfo entityInfo = new EntityInfo(clazz, id, projected);
+ return entityInfo;
+ }
- public EntityInfo extract(Hits hits, int index) throws IOException {
- Document doc = hits.doc( index );
- //TODO if we are only looking for score (unlikely), avoid accessing doc (lazy load)
- EntityInfo entityInfo = extract( doc );
- Object[] eip = entityInfo.projection;
+ public EntityInfo extract(Hits hits, int index) throws IOException
+ {
+ Document doc = hits.doc(index);
+ //TODO if we are only looking for score (unlikely), avoid accessing doc (lazy load)
+ EntityInfo entityInfo = extract(doc);
+ Object[] entityInfoProjection = entityInfo.projection; //Navin Surtani changed eip variable to entityInfoProjection.
- if ( eip != null && eip.length > 0 ) {
- for (int x = 0; x < projection.length; x++) {
- if ( ProjectionConstants.SCORE.equals( projection[x] ) ) {
- eip[x] = hits.score( index );
- }
- else if ( ProjectionConstants.ID.equals( projection[x] ) ) {
- eip[x] = entityInfo.id;
- }
- else if ( ProjectionConstants.DOCUMENT.equals( projection[x] ) ) {
- eip[x] = doc;
- }
- else if ( ProjectionConstants.DOCUMENT_ID.equals( projection[x] ) ) {
- eip[x] = hits.id( index );
- }
- else if ( ProjectionConstants.BOOST.equals( projection[x] ) ) {
- eip[x] = doc.getBoost();
- }
- else if ( ProjectionConstants.THIS.equals( projection[x] ) ) {
- //THIS could be projected more than once
- //THIS loading delayed to the Loader phase
- entityInfo.indexesOfThis.add(x);
- }
- }
- }
- return entityInfo;
- }
+ if (entityInfoProjection != null && entityInfoProjection.length > 0)
+ {
+ for (int x = 0; x < projection.length; x++)
+ {
+ if (ProjectionConstants.SCORE.equals(projection[x]))
+ {
+ entityInfoProjection[x] = hits.score(index);
+ }
+ else if (ProjectionConstants.ID.equals(projection[x]))
+ {
+ entityInfoProjection[x] = entityInfo.id;
+ }
+ else if (ProjectionConstants.DOCUMENT.equals(projection[x]))
+ {
+ entityInfoProjection[x] = doc;
+ }
+ else if (ProjectionConstants.DOCUMENT_ID.equals(projection[x]))
+ {
+ entityInfoProjection[x] = hits.id(index);
+ }
+ else if (ProjectionConstants.BOOST.equals(projection[x]))
+ {
+ entityInfoProjection[x] = doc.getBoost();
+ }
+ else if (ProjectionConstants.THIS.equals(projection[x]))
+ {
+ //THIS could be projected more than once
+ //THIS loading delayed to the Loader phase
+ entityInfo.indexesOfThis.add(x);
+ }
+ }
+ }
+ return entityInfo;
+ }
}
More information about the hibernate-commits
mailing list