Package org.hibernate.search.engine.spi

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


  }

  static DocumentBuilderIndexedEntity getDocumentBuilder(QueryBuildingContext queryContext) {
    final SearchFactoryImplementor factory = queryContext.getFactory();
    final Class<?> type = queryContext.getEntityType();
    EntityIndexBinding indexBinding = factory.getIndexBinding( type );
    if ( indexBinding == null ) {
      throw new AssertionFailure( "Class is not indexed: " + type );
    }
    return indexBinding.getDocumentBuilder();
  }
View Full Code Here


    sendWorkToShards( work, false );
  }

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

  }

  private Collection<IndexManager> uniqueIndexManagerForTypes(Collection<Class<?>> entityTypes) {
    HashMap<String,IndexManager> uniqueBackends = new HashMap<String, IndexManager>( entityTypes.size() );
    for ( Class<?> type : entityTypes ) {
      EntityIndexBinding indexBindingForEntity = searchFactoryImplementor.getIndexBinding( type );
      if ( indexBindingForEntity != null ) {
        IndexManager[] indexManagers = indexBindingForEntity.getIndexManagers();
        for ( IndexManager im : indexManagers ) {
          uniqueBackends.put( im.getIndexName(), im );
        }
      }
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void index(Object entity, Session session, InstanceInitializer sessionInitializer, ConversionContext conversionContext)
      throws InterruptedException {
    Serializable id = session.getIdentifier( entity );
    Class<?> clazz = HibernateHelper.getClass( entity );
    EntityIndexBinding 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;
    }

    EntityIndexingInterceptor interceptor = entityIndexBinding.getEntityIndexingInterceptor();
    if ( interceptor != null ) {
      IndexingOverride onAdd = interceptor.onAdd( entity );
      switch ( onAdd ) {
        case REMOVE:
        case SKIP:
          return;
      }
      //default: continue indexing this instance
    }

    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    TwoWayFieldBridge idBridge = docBuilder.getIdBridge();
    conversionContext.pushProperty( docBuilder.getIdKeywordName() );
    String idInString = null;
    try {
      idInString = conversionContext
View Full Code Here

         worker.performWork(work, transactionContext);
      }
   }

   public boolean isIndexed(final Class<?> c) {
      final EntityIndexBinding indexBinding = this.searchFactory.getIndexBinding(c);
      return indexBinding != null;
   }
View Full Code Here

      return new EmbeddedLuceneQuery(searchManager, parsingResult, sort, startOffset, maxResults);
   }

   private PropertyMetadata getPropertyMetadata(Class<?> type, String propName) {
      EntityIndexBinding entityIndexBinding = ((SearchFactoryImplementor) searchManager.getSearchFactory()).getIndexBinding(type);
      if (entityIndexBinding == null) {
         throw new IllegalArgumentException("The type " + type.getName() + " is not an indexed entity.");
      }

      return entityIndexBinding.getDocumentBuilder().getMetadata().getPropertyMetadataForProperty(propName);
   }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void index(Object entity, Session session, InstanceInitializer sessionInitializer, ConversionContext conversionContext)
      throws InterruptedException {
    Serializable id = session.getIdentifier( entity );
    Class<?> clazz = HibernateHelper.getClass( entity );
    EntityIndexBinding 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;
    }

    EntityIndexingInterceptor interceptor = entityIndexBinding.getEntityIndexingInterceptor();
    if ( interceptor != null ) {
      IndexingOverride onAdd = interceptor.onAdd( entity );
      switch ( onAdd ) {
        case REMOVE:
        case SKIP:
          return;
      }
      //default: continue indexing this instance
    }

    DocumentBuilderIndexedEntity docBuilder = entityIndexBinding.getDocumentBuilder();
    TwoWayFieldBridge idBridge = docBuilder.getIdBridge();
    conversionContext.pushProperty( docBuilder.getIdKeywordName() );
    String idInString = null;
    try {
      idInString = conversionContext
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<?>, EntityIndexBinding> documentBuildersIndexedEntities = factoryState.getIndexBindings();
    for ( Entry<Class<?>, EntityIndexBinding> entry : documentBuildersIndexedEntities.entrySet() ) {
      Class<?> clazz = entry.getKey();
      EntityIndexBinding entityIndexBinding = entry.getValue();
      Similarity entitySimilarity = entityIndexBinding.getSimilarity();
      if ( entitySimilarity == null ) {
        //might have been read from annotations, fill the missing information in the EntityIndexBinder:
        entitySimilarity = entityIndexBinding.getDocumentBuilder().getSimilarity();
        if ( entitySimilarity != null ) {
          MutableEntityIndexBinding newMapping = buildTypeSafeMutableEntityBinder(
              entityIndexBinding,
              entitySimilarity
          );
          entityIndexBinding = newMapping;
          documentBuildersIndexedEntities.put( clazz, entityIndexBinding );
        }
      }
      IndexManager[] indexManagers = entityIndexBinding.getIndexManagers();
      for ( IndexManager indexManager : indexManagers ) {
        Similarity indexSimilarity = indexManager.getSimilarity();
        if ( entitySimilarity != null && indexSimilarity == null ) {
          indexManager.setSimilarity( entitySimilarity );
        }
View Full Code Here

      Map<Class<?>, EntityIndexBinding> documentBuildersIndexedEntities,
      Map<Class<?>, DocumentBuilderContainedEntity<?>> documentBuildersContainedEntities) {
    for ( XClass xClass : optimizationBlackListX ) {
      Class type = classMappings.get( xClass );
      if ( type != null ) {
        EntityIndexBinding 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

    }
  }

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

TOP

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

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.