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() ) ) {
          /***********hibernate search code**********
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
              work.getEntityClass(),
              work.getId(),
              work.getIdInString()
          );
           *****************************************/
         
          /****************changed by Jerry*************/
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
              work.getEntityClass(),
              work.getId(),
              work.getIdInString(),
              work.getDocument()
          );
          /*****************************************/
          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() ) ) {
          /***********hibernate search code**********
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
              work.getEntityClass(),
              work.getId(),
              work.getIdInString()
          );
           *****************************************/
         
          /****************changed by Jerry*************/
          DirectoryProvider[] providers = shardingStrategy.getDirectoryProvidersForDeletion(
              work.getEntityClass(),
              work.getId(),
              work.getIdInString(),
              work.getDocument()
          );
          /*****************************************/
          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


    QueueProcessors processors = new QueueProcessors( visitorsMap );
    // divide tasks in parts, adding to QueueProcessors by affected Directory.
    for ( LuceneWork work : queue ) {
      final Class<?> entityType = work.getEntityClass();
      DocumentBuilder<?> documentBuilder = searchFactoryImplementor.getDocumentBuilder( entityType );
      IndexShardingStrategy shardingStrategy = documentBuilder.getDirectoryProviderSelectionStrategy();
      work.getWorkDelegate( providerSelectionVisitor ).addAsPayLoadsToQueue( work, shardingStrategy, processors );
    }
    // TODO next cycle could be performed in parallel
    for ( PerDPQueueProcessor processor : processors.getQueueProcessors() ) {
      // perform the work on indexes
View Full Code Here

      }
    }
  }

  private void populateDirectories(List<DirectoryProvider> directories, DocumentBuilderIndexedEntity builder) {
    final IndexShardingStrategy indexShardingStrategy = builder.getDirectoryProviderSelectionStrategy();
    final DirectoryProvider[] directoryProviders;
    directoryProviders = indexShardingStrategy.getDirectoryProvidersForQuery( new FullTextFilterImplementor[0] );

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

    //default
    return new IndexSearcherWithPayload( is, false, false );
  }

  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

  }
 
  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

    is.setSimilarity( searcherSimilarity );
    return is;
  }

  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

  }

  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

      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

    }
    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

    }
    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( 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.