Package org.hibernate.search.engine.spi

Examples of org.hibernate.search.engine.spi.EntityIndexBinder


    }
    return analyzer;
  }

  public Analyzer getAnalyzer(Class<?> clazz) {
    EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( clazz );
    DocumentBuilderIndexedEntity<?> builder = entityIndexBinding.getDocumentBuilder();
    return builder.getAnalyzer();
  }
View Full Code Here


  @Override
  public IndexReader openIndexReader(Class<?>... entities) {
    HashMap<String,IndexManager> indexManagers = new HashMap<String,IndexManager>();
    for ( Class<?> type : entities ) {
      EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( type );
      IndexManager[] indexManagersForAllShards = entityIndexBinding.getSelectionStrategy().getIndexManagersForAllShards();
      for (IndexManager im : indexManagersForAllShards) {
        indexManagers.put( im.getIndexName(), im );
      }
    }
    IndexManager[] uniqueIndexManagers = indexManagers.values().toArray( new IndexManager[indexManagers.size()]);
View Full Code Here

  private EntityIndexBinder getSafeIndexBindingForEntity(Class entityType) {
    if ( entityType == null ) {
      throw new IllegalArgumentException( "Null is not a valid indexed entity type" );
    }
    EntityIndexBinder entityIndexBinding = getIndexBindingForEntity( entityType );
    if ( entityIndexBinding == null ) {
      throw new IllegalArgumentException( "Entity is not an indexed type: " + entityType );
    }
    return entityIndexBinding;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void index( Object entity, Session session, ClassNavigator sessionInitializer ) throws InterruptedException {
    Serializable id = session.getIdentifier( entity );
    Class<?> clazz = HibernateHelper.getClass( entity );
    EntityIndexBinder entityIndexBinding = entityIndexBinders.get( clazz );
    if ( entityIndexBinding == null ) {
      // it might be possible to receive not-indexes subclasses of the currently indexed type;
      // being not-indexed, we skip them.
      // FIXME for improved performance: avoid loading them in an early phase.
      return;
    }
    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    TwoWayFieldBridge idBridge = docBuilder.getIdBridge();
    ContextualException2WayBridge contextualBridge = new ContextualException2WayBridge()
        .setClass(clazz)
        .setFieldName(docBuilder.getIdKeywordName())
        .setFieldBridge(idBridge);
View Full Code Here

  private void fillSimilarityMapping() {
    //TODO cleanup: this logic to select the Similarity is too complex, should likely be done in a previous phase
    final Map<Class<?>, EntityIndexBinder> documentBuildersIndexedEntities = factoryState.getIndexBindingForEntity();
    for ( Entry<Class<?>, EntityIndexBinder> entry : documentBuildersIndexedEntities.entrySet() ) {
      Class<?> clazz = entry.getKey();
      EntityIndexBinder entityMapping = entry.getValue();
      Similarity entitySimilarity = entityMapping.getSimilarity();
      if ( entitySimilarity == null ) {
        //might have been read from annotations, fill the missing information in the EntityIndexBinder:
        entitySimilarity = entityMapping.getDocumentBuilder().getSimilarity();
        if ( entitySimilarity != null ) {
          MutableEntityIndexBinding newMapping = buildTypeSafeMutableEntityBinder(
              clazz,
              entityMapping,
              entitySimilarity
          );
          entityMapping = newMapping;
          documentBuildersIndexedEntities.put( clazz, entityMapping );
        }
      }
      IndexManager[] indexManagers = entityMapping.getIndexManagers();
      for ( IndexManager indexManager : indexManagers ) {
        Similarity indexSimilarity = indexManager.getSimilarity();
        if ( entitySimilarity != null && indexSimilarity == null ) {
          indexManager.setSimilarity( entitySimilarity );
        }
View Full Code Here

      Map<Class<?>, EntityIndexBinder> documentBuildersIndexedEntities,
      Map<Class<?>, DocumentBuilderContainedEntity<?>> documentBuildersContainedEntities) {
    for ( XClass xClass : optimizationBlackListX ) {
      Class type = classMappings.get( xClass );
      if ( type != null ) {
        EntityIndexBinder entityIndexBinding = documentBuildersIndexedEntities.get( type );
        if ( entityIndexBinding != null ) {
          log.tracef( "Dirty checking optimizations disabled for class %s", type );
          entityIndexBinding.getDocumentBuilder().forceStateInspectionOptimizationsDisabled();
        }
        DocumentBuilderContainedEntity<?> documentBuilderContainedEntity = documentBuildersContainedEntities.get( type );
        if ( documentBuilderContainedEntity != null ) {
          log.tracef( "Dirty checking optimizations disabled for class %s", type );
          documentBuilderContainedEntity.forceStateInspectionOptimizationsDisabled();
View Full Code Here

      im.optimize();
    }
  }

  public void optimize(Class entityType) {
    EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( entityType );
    for ( IndexManager im: entityIndexBinding.getIndexManagers() ) {
      im.optimize();
    }
  }
View Full Code Here

    }
    return analyzer;
  }

  public Analyzer getAnalyzer(Class<?> clazz) {
    EntityIndexBinder entityIndexBinding = getSafeIndexBindingForEntity( clazz );
    DocumentBuilderIndexedEntity<?> builder = entityIndexBinding.getDocumentBuilder();
    return builder.getAnalyzer();
  }
View Full Code Here

  public EntityIndexBinder getSafeIndexBindingForEntity(Class<?> entityType) {
    if ( entityType == null ) {
      throw log.nullIsInvalidIndexedType();
    }
    EntityIndexBinder entityIndexBinding = getIndexBindingForEntity( entityType );
    if ( entityIndexBinding == null ) {
      throw log.notAnIndexedType( entityType.getName() );
    }
    return entityIndexBinding;
  }
View Full Code Here

    }
    return luceneDocument;
  }

  private String objectIdInString(Class<?> entityClass, Serializable id, ConversionContext conversionContext) {
    EntityIndexBinder indexBindingForEntity = searchFactory.getIndexBindingForEntity( entityClass );
    if ( indexBindingForEntity == null ) {
      throw new SearchException( "Unable to find entity type metadata while deserializing: " + entityClass );
    }
    DocumentBuilderIndexedEntity<?> documentBuilder = indexBindingForEntity.getDocumentBuilder();
    return documentBuilder.objectToString( documentBuilder.getIdKeywordName(), id, conversionContext );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.engine.spi.EntityIndexBinder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.