Package org.hibernate.search.backend.impl.lucene

Examples of org.hibernate.search.backend.impl.lucene.LuceneWorker$WorkWithPayload


    this.searchFactoryImplementor = searchFactoryImplementor;
  }

  public void run() {
    Workspace workspace;
    LuceneWorker worker;
    workspace = new Workspace( searchFactoryImplementor );
    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 {
          throw new AssertionFailure( "Unknown work type: " + work.getClass() );
        }
      }
      deadlockFreeQueue(queueWithFlatDPs, searchFactoryImplementor);
      checkForBatchIndexing(workspace);   
      for ( LuceneWorker.WorkWithPayload luceneWork : queueWithFlatDPs ) {
        worker.performWork( luceneWork );
      }
    }
    finally {
      workspace.clean();
      queue.clear();
View Full Code Here

TOP

Related Classes of org.hibernate.search.backend.impl.lucene.LuceneWorker$WorkWithPayload

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.