Package org.hibernate.search.store

Examples of org.hibernate.search.store.IndexShardingStrategy


    worker = new LuceneWorker( workspace );
    try {
      List<LuceneWorker.WorkWithPayload> queueWithFlatDPs = new ArrayList<LuceneWorker.WorkWithPayload>( queue.size()*2 );
      for ( LuceneWork work : queue ) {
        DocumentBuilder documentBuilder = searchFactoryImplementor.getDocumentBuilders().get( work.getEntityClass() );
        IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();

        if ( PurgeAllLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
              work.getEntityClass(),
              work.getId(),
              work.getIdInString()
          );
          for (DirectoryProvider provider : providers) {
            queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload( work, provider ) );
          }
        }
        else if ( AddLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
          DirectoryProvider provider = shardingStrategy.getDirectoryProviderForAddition(
              work.getEntityClass(),
              work.getId(),
              work.getIdInString(),
              work.getDocument()
          );
          queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload( work, provider ) );
        }
        else if ( DeleteLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
              work.getEntityClass(),
              work.getId(),
              work.getIdInString()
          );
          for (DirectoryProvider provider : providers) {
            queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload( work, provider ) );
          }
        }
        else if ( OptimizeLuceneWork.class.isAssignableFrom( work.getClass() ) ) {
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForAllShards();
          for (DirectoryProvider provider : providers) {
            queueWithFlatDPs.add( new LuceneWorker.WorkWithPayload( work, provider ) );
          }
        }
        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

  }
 
  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

      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

    // 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

    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

          context
      );
    }

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

    ShardIdentifierProvider shardIdentifierProvider = null;
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.