Exemplo n.º 1
0
 private Collection<IndexManager> uniqueIndexManagerForTypes(Collection<Class<?>> entityTypes) {
   HashMap<String, IndexManager> uniqueBackends =
       new HashMap<String, IndexManager>(entityTypes.size());
   for (Class<?> type : entityTypes) {
     EntityIndexBinding indexBindingForEntity = searchFactoryImplementor.getIndexBinding(type);
     if (indexBindingForEntity != null) {
       IndexManager[] indexManagers = indexBindingForEntity.getIndexManagers();
       for (IndexManager im : indexManagers) {
         uniqueBackends.put(im.getIndexName(), im);
       }
     }
   }
   return uniqueBackends.values();
 }
Exemplo n.º 2
0
 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 {
     WorkQueuePerIndexSplitter workContext = new WorkQueuePerIndexSplitter();
     work.getWorkDelegate(TransactionalSelectionVisitor.INSTANCE)
         .performOperation(work, shardingStrategy, workContext);
     workContext.commitOperations(
         progressMonitor); // FIXME I need a "Force sync" actually for when using PurgeAll before
                           // the indexing starts
   }
 }