Package org.hibernate.search.backend

Examples of org.hibernate.search.backend.Workspace$DPStatistics


    this.queue = queue;
    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


  private final Map<DirectoryProvider,LuceneWorkVisitor> visitorsMap = new HashMap<DirectoryProvider,LuceneWorkVisitor>();

  public void initialize(Properties props, SearchFactoryImplementor searchFactoryImplementor) {
    this.searchFactoryImp = searchFactoryImplementor;
    for (DirectoryProvider dp : searchFactoryImplementor.getDirectoryProviders() ) {
      Workspace w = new Workspace( searchFactoryImplementor, dp );
      LuceneWorkVisitor visitor = new LuceneWorkVisitor( w );
      visitorsMap.put( dp, visitor );
    }
  }
View Full Code Here

  private final boolean exclusiveIndexUsage;
  private final ErrorHandler errorHandler;
 
  PerDPResources(WorkerBuildContext context, DirectoryProvider<?> dp) {
    errorHandler = context.getErrorHandler();
    workspace = new Workspace( context, dp, errorHandler );
    visitor = new LuceneWorkVisitor( workspace, context );
    executor = Executors.newFixedThreadPool( 1, "Directory writer" );
    exclusiveIndexUsage = context.isExclusiveIndexUsageEnabled( dp );
  }
View Full Code Here

  DirectoryProviderWorkspace(WorkerBuildContext context, DirectoryProvider<?> dp, MassIndexerProgressMonitor monitor, int maxThreads) {
    if ( maxThreads < 1 ) {
      throw new IllegalArgumentException( "maxThreads needs to be at least 1" );
    }
    this.monitor = monitor;
    workspace = new Workspace( context, dp );
    visitor = new LuceneWorkVisitor( workspace, context );
    executor = Executors.newFixedThreadPool( maxThreads, "indexwriter" );
  }
View Full Code Here

  private final Workspace workspace;
  private final boolean exclusiveIndexUsage;
  private final ErrorHandler errorHandler;
 
  PerDPResources(WorkerBuildContext context, DirectoryProvider<?> dp) {
    workspace = new Workspace( context, dp );
    visitor = new LuceneWorkVisitor( workspace, context );
    executor = Executors.newFixedThreadPool( 1, "Directory writer" );
    exclusiveIndexUsage = context.isExclusiveIndexUsageEnabled( dp );
    errorHandler = context.getErrorHandler();
  }
View Full Code Here

    this.queue = queue;
    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() ) ) {
          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 {
          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

  DirectoryProviderWorkspace(SearchFactoryImplementor searchFactoryImp, DirectoryProvider<?> dp, MassIndexerProgressMonitor monitor, int maxThreads) {
    if ( maxThreads < 1 ) {
      throw new IllegalArgumentException( "maxThreads needs to be at least 1" );
    }
    this.monitor = monitor;
    workspace = new Workspace( searchFactoryImp, dp );
    visitor = new LuceneWorkVisitor( workspace );
    executor = Executors.newFixedThreadPool( maxThreads, "indexwriter" );
  }
View Full Code Here

  private final Workspace workspace;
  private final boolean exclusiveIndexUsage;
  private final ErrorHandler errorHandler;
 
  PerDPResources(SearchFactoryImplementor searchFactoryImp, DirectoryProvider<?> dp) {
    workspace = new Workspace( searchFactoryImp, dp );
    visitor = new LuceneWorkVisitor( workspace );
    executor = Executors.newFixedThreadPool( 1, "Directory writer" );
    exclusiveIndexUsage = searchFactoryImp.isExclusiveIndexUsageEnabled( dp );
    errorHandler = searchFactoryImp.getErrorHandler();
  }
View Full Code Here

  private final LuceneWorkVisitor visitor;
  private final Workspace workspace;
  private final boolean exclusiveIndexUsage;
 
  PerDPResources(SearchFactoryImplementor searchFactoryImp, DirectoryProvider<?> dp) {
    workspace = new Workspace( searchFactoryImp, dp );
    visitor = new LuceneWorkVisitor( workspace );
    executor = Executors.newFixedThreadPool( 1 );
    exclusiveIndexUsage = searchFactoryImp.isExclusiveIndexUsageEnabled( dp );
  }
View Full Code Here

  DirectoryProviderWorkspace(SearchFactoryImplementor searchFactoryImp, DirectoryProvider<?> dp, MassIndexerProgressMonitor monitor, int maxThreads) {
    if ( maxThreads < 1 ) {
      throw new IllegalArgumentException( "maxThreads needs to be at least 1" );
    }
    this.monitor = monitor;
    workspace = new Workspace( searchFactoryImp, dp );
    visitor = new LuceneWorkVisitor( workspace );
    executor = Executors.newFixedThreadPool( maxThreads, "indexwriter" );
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.backend.Workspace$DPStatistics

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.