Package org.hibernate.search.store

Examples of org.hibernate.search.store.IndexShardingStrategy


  }

  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


      indexManager.addContainedEntity( mappedClass );
      providers[index] = indexManager;
    }

    //define sharding strategy for this entity:
    IndexShardingStrategy shardingStrategy;
    //any indexProperty will do, the indexProps[0] surely exists.
    String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
    if ( shardingStrategyName == null ) {
      if ( indexProps.length == 1 ) {
        shardingStrategy = new NotShardedStrategy();
      }
      else {
        shardingStrategy = new IdHashShardingStrategy();
      }
    }
    else {
      shardingStrategy = ClassLoaderHelper.instanceFromName(
          IndexShardingStrategy.class,
          shardingStrategyName, DirectoryProviderFactory.class, "IndexShardingStrategy"
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), providers
    );

    //define the Similarity implementation:
    // warning: it can also be set by an annotation at class level
View Full Code Here

  }
 
  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, forceAsync );
    }
    else {
      WorkQueuePerIndexSplitter workContext = new WorkQueuePerIndexSplitter();
View Full Code Here

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

      indexManager.addContainedEntity( mappedClass );
      providers[index] = indexManager;
    }
   
    //define sharding strategy for this entity:
    IndexShardingStrategy shardingStrategy;
    //any indexProperty will do, the indexProps[0] surely exists.
    String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
    if ( shardingStrategyName == null ) {
      if ( indexProps.length == 1 ) {
        shardingStrategy = new NotShardedStrategy();
      }
      else {
        shardingStrategy = new IdHashShardingStrategy();
      }
    }
    else {
      shardingStrategy = ClassLoaderHelper.instanceFromName(
          IndexShardingStrategy.class,
          shardingStrategyName, DirectoryProviderFactory.class, "IndexShardingStrategy"
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), providers
    );
   
    //define the Similarity implementation:
    // warning: it can also be set by an annotation at class level
View Full Code Here

    return similarity;
  }

  private void populateDirectories(List<DirectoryProvider> directories, DocumentBuilderIndexedEntity builder) {
    final IndexShardingStrategy indexShardingStrategy = builder.getDirectoryProviderSelectionStrategy();
    final DirectoryProvider[] directoryProviders;
    if ( filterDefinitions != null && !filterDefinitions.isEmpty() ) {
      directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery(
          filterDefinitions.values().toArray( new FullTextFilterImplementor[filterDefinitions.size()] )
      );
    }
    else {
      //no filter get all shards
      directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery( EMPTY_FULL_TEXT_FILTER_IMPLEMENTOR );
    }

    for ( DirectoryProvider provider : directoryProviders ) {
      if ( !directories.contains( provider ) ) {
        directories.add( provider );
View Full Code Here

          mappedClass,
          buildContext
      );
    }

    IndexShardingStrategy shardingStrategy = null;
    if ( !isDynamicSharding ) {
      shardingStrategy = createIndexShardingStrategy( indexProperties, indexManagers, buildContext );
    }

    ShardIdentifierProvider shardIdentifierProvider = null;
View Full Code Here

  }

  private IndexShardingStrategy createIndexShardingStrategy(Properties[] indexProps,
      IndexManager[] indexManagers,
      WorkerBuildContext buildContext) {
    IndexShardingStrategy shardingStrategy;

    // any indexProperty will do, the indexProps[0] surely exists.
    String shardingStrategyName = indexProps[0].getProperty( SHARDING_STRATEGY );
    if ( shardingStrategyName == null ) {
      if ( indexProps.length == 1 ) {
        shardingStrategy = new NotShardedStrategy();
      }
      else {
        shardingStrategy = new IdHashShardingStrategy();
      }
    }
    else {
      ServiceManager serviceManager = buildContext.getServiceManager();
      shardingStrategy = ClassLoaderHelper.instanceFromName(
          IndexShardingStrategy.class,
          shardingStrategyName,
          "IndexShardingStrategy",
          serviceManager
      );
    }
    shardingStrategy.initialize(
        new MaskedProperty( indexProps[0], SHARDING_STRATEGY ), indexManagers
    );
    return shardingStrategy;
  }
View Full Code Here

    // divide the queue in tasks, adding to QueueProcessors by affected Directory.
    try {
      for ( LuceneWork work : queue ) {
        final Class<?> entityType = work.getEntityClass();
        DocumentBuilderIndexedEntity<?> documentBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityType );
        IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
        work.getWorkDelegate( providerSelectionVisitor ).addAsPayLoadsToQueue( work, shardingStrategy, processors );
      }
      //this Runnable splits tasks in more runnables and then runs them:
      processors.runAll( sync );
    } catch ( Exception e ) {
View Full Code Here

  }
 
  private void sendWorkToShards(LuceneWork work, PerDirectoryWorkProcessor worker) throws InterruptedException {
    final Class<?> entityType = work.getEntityClass();
    DocumentBuilderIndexedEntity<?> documentBuilder = searchFactoryImplementor.getDocumentBuilderIndexedEntity( entityType );
    IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
    work.getWorkDelegate( providerSelectionVisitor ).addAsPayLoadsToQueue( work, shardingStrategy, worker );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.store.IndexShardingStrategy

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.