Package org.hibernate.search.engine.spi

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


  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 = new MutableEntityIndexBinding( entityMapping.getSelectionStrategy(), entitySimilarity, entityMapping.getIndexManagers() );
          newMapping.setDocumentBuilderIndexedEntity( entityMapping.getDocumentBuilder() );
          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

    sendWorkToShards( work, false );
  }

  private void sendWorkToShards(LuceneWork work, boolean forceAsync) {
    final Class<?> entityType = work.getEntityClass();
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity( entityType );
    IndexShardingStrategy shardingStrategy = entityIndexBinding.getSelectionStrategy();
    if ( forceAsync ) {
      work.getWorkDelegate( StreamingSelectionVisitor.INSTANCE )
          .performStreamOperation( work, shardingStrategy, progressMonitor, forceAsync );
    }
    else {
View Full Code Here

    }
  }

  @Override
  public void flush(Class<?> entityType) {
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity( entityType );
    IndexShardingStrategy shardingStrategy = entityIndexBinding.getSelectionStrategy();
    WorkQueuePerIndexSplitter workContext = new WorkQueuePerIndexSplitter();
    FlushLuceneWork flushOperation = new FlushLuceneWork();
    flushOperation.getWorkDelegate( TransactionalSelectionVisitor.INSTANCE )
        .performOperation( flushOperation, shardingStrategy, workContext );
  }
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

   * @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 (AbstractDocumentBuilder<T>) entityIndexBinding.getDocumentBuilder();
    }
  }
View Full Code Here

        }
      }
    }

    private EntityIndexingInterceptor<? super T> getEntityInterceptor() {
      EntityIndexBinder indexBindingForEntity = searchFactoryImplementor.getIndexBindingForEntity(
          entityClass
      );
      return indexBindingForEntity!=null ?
          (EntityIndexingInterceptor<? super T> ) indexBindingForEntity.getEntityIndexingInterceptor() :
          null;
    }
View Full Code Here

    }
    return -1;
  }

  private static DocumentBuilderIndexedEntity<?> getDocumentBuilder(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz) {
    EntityIndexBinder entityIndexBinding = searchFactoryImplementor.getIndexBindingForEntity(
        clazz
    );
    if ( entityIndexBinding == null ) {
      throw new SearchException( "No Lucene configuration set up for: " + clazz );
    }
    return entityIndexBinding.getDocumentBuilder();
  }
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

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.