Package org.hibernate.search.engine.spi

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


    return analyzer;
  }

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


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

    IndexedTypeDescriptor typeDescriptor;
    if ( indexedTypeDescriptors.containsKey( entityType ) ) {
      typeDescriptor = indexedTypeDescriptors.get( entityType );
    }
    else {
      EntityIndexBinding indexBinder = indexBindingForEntities.get( entityType );
      IndexedTypeDescriptor indexedTypeDescriptor;
      if ( indexBinder == null ) {
        indexedTypeDescriptor = new IndexedTypeDescriptorForUnindexedType(entityType);
      }
      else {
        indexedTypeDescriptor = new IndexedTypeDescriptorImpl(
            indexBinder.getDocumentBuilder().getMetadata(),
            indexBinder.getIndexManagers()
        );
      }
      indexedTypeDescriptors.put( entityType, indexedTypeDescriptor );
      typeDescriptor = indexedTypeDescriptor;
    }
View Full Code Here

    }
    else {
      Set<Class<?>> involvedClasses = new HashSet<Class<?>>( indexedTargetedEntities.size() );
      involvedClasses.addAll( indexedTargetedEntities );
      for ( Class<?> clazz : indexedTargetedEntities ) {
        EntityIndexBinding indexBinder = builders.get( clazz );
        if ( indexBinder != null ) {
          DocumentBuilderIndexedEntity<?> builder = indexBinder.getDocumentBuilder();
          involvedClasses.addAll( builder.getMappedSubclasses() );
        }
      }

      for ( Class clazz : involvedClasses ) {
        EntityIndexBinding 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

    Map<Class<?>, EntityIndexBinding> builders = searchFactoryImplementor.getIndexBindings();
    Set<FieldCacheCollectorFactory> allCollectors = new HashSet<FieldCacheCollectorFactory>();
    // we need all documentBuilder to agree on type, fieldName, and enabling the option:
    FieldCacheCollectorFactory anyImplementation = null;
    for ( Class<?> clazz : classesAndSubclasses ) {
      EntityIndexBinding docBuilder = builders.get( clazz );
      FieldCacheCollectorFactory fieldCacheCollectionFactory = docBuilder.getIdFieldCacheCollectionFactory();
      if ( fieldCacheCollectionFactory == null ) {
        // some implementation disable it, so we won't use it
        return null;
      }
      anyImplementation = fieldCacheCollectionFactory;
View Full Code Here

      log.trace( sb.toString() );
    }
    WorkQueuePerIndexSplitter context = new WorkQueuePerIndexSplitter();
    for ( LuceneWork work : sealedQueue ) {
      final Class<?> entityType = work.getEntityClass();
      EntityIndexBinding entityIndexBinding = entityIndexBindings.get( entityType );
      IndexShardingStrategy shardingStrategy = entityIndexBinding.getSelectionStrategy();
      work.getWorkDelegate( TransactionalSelectionVisitor.INSTANCE )
        .performOperation( work, shardingStrategy, context );
    }
    context.commitOperations( null );
  }
View Full Code Here

  private boolean transactionExpected;

  public void performWork(Work<?> work, TransactionContext transactionContext) {
    final Class<?> entityType = instanceInitializer.getClassFromWork( work );
    EntityIndexBinding indexBindingForEntity = factory.getIndexBinding( entityType );
    if ( indexBindingForEntity == null
        && factory.getDocumentBuilderContainedEntity( entityType ) == null ) {
      throw new SearchException( "Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: " + entityType );
    }
    work = interceptWork( indexBindingForEntity, work );
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

      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

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.