Package org.hibernate.search.engine.spi

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


      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

  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

    public final Set<Class<?>> mappedSubclasses;
    private final Criteria criteria;

    RootEntityMetadata(Class<?> rootEntity, SearchFactoryImplementor searchFactoryImplementor) {
      this.rootEntity = rootEntity;
      EntityIndexBinder provider = searchFactoryImplementor.getIndexBindingForEntity( rootEntity );
      if ( provider == null) throw new AssertionFailure("Provider not found for class: " + rootEntity);
      this.mappedSubclasses = provider.getDocumentBuilder().getMappedSubclasses();
      this.criteria = null; //default
    }
View Full Code Here

   * @param entityClass the entity type for which to retrieve the document builder
   *
   * @return the DocumentBuilder for this type
   */
  private static <T> AbstractDocumentBuilder<T> getEntityBuilder(SearchFactoryImplementor searchFactoryImplementor, Class<?> entityClass) {
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity( entityClass );
    if ( entityIndexBinding == null ) {
      DocumentBuilderContainedEntity entityBuilder = searchFactoryImplementor.getDocumentBuilderContainedEntity(
          entityClass
      );
      if ( entityBuilder == null ) {
        // should never happen but better be safe than sorry
        throw new SearchException(
            "Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: " + entityClass
        );
      }
      else {
        return entityBuilder;
      }
    }
    else {
      return entityIndexBinding.getDocumentBuilder();
    }
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void index( Object entity, Session session, EntityInitializer 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

          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        EntityIndexBinder indexBinder = builders.get( clazz );
        //TODO should we rather choose a polymorphic path and allow non mapped entities
        if ( indexBinder == null ) {
          throw new SearchException( "Not a mapped entity (don't forget to add @Indexed): " + clazz );
        }
        DocumentBuilderIndexedEntity<?> builder = indexBinder.getDocumentBuilder();
        if ( builder.getIdKeywordName() != null ) {
          idFieldNames.add( builder.getIdKeywordName() );
          allowFieldSelectionInProjection = allowFieldSelectionInProjection && builder.allowFieldSelectionInProjection();
        }
        searcherSimilarity = checkSimilarity( searcherSimilarity, builder );
        useFieldCacheOnClassTypes = useFieldCacheOnClassTypes || builder.getFieldCacheOption()
            .contains( FieldCacheType.CLASS );
        populateIndexManagers( targetedIndexes, indexBinder.getSelectionStrategy() );
      }
      this.classesAndSubclasses = involvedClasses;
    }
    this.idFieldNames = idFieldNames;
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

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.