public DocumentBuilder(DocumentMapping classMapping, Analyzer defaultAnalyzer, IDirectoryProvider[] directoryProviders, IIndexShardingStrategy shardingStrategy) { analyzer = new ScopedAnalyzer(); this.directoryProviders = directoryProviders; this.shardingStrategy = shardingStrategy; if (classMapping == null) { throw new AssertionFailure("Unable to build a DocumemntBuilder with a null class"); } rootClassMapping = classMapping; Set <System.Type> processedClasses = new HashedSet <System.Type>(); processedClasses.Add(classMapping.MappedClass); CollectAnalyzers(rootClassMapping, defaultAnalyzer, true, string.Empty, processedClasses); //processedClasses.remove( clazz ); for the sake of completness analyzer.GlobalAnalyzer = defaultAnalyzer; if (idMapping == null) { throw new SearchException("No document id for: " + classMapping.MappedClass.Name); } }
/// <summary> /// /// </summary> /// <param name="ignore">Ignored, used to keep the delegate signature that WaitCallback requires</param> public void Run(object ignore) { Workspace workspace = new Workspace(searchFactoryImplementor); LuceneWorker worker = new LuceneWorker(workspace); try { List <LuceneWorker.WorkWithPayload> queueWithFlatDPs = new List <LuceneWorker.WorkWithPayload>(queue.Count * 2); foreach (LuceneWork work in queue) { DocumentBuilder documentBuilder = searchFactoryImplementor.DocumentBuilders[work.EntityClass]; IIndexShardingStrategy shardingStrategy = documentBuilder.DirectoryProvidersSelectionStrategy; if (work is PurgeAllLuceneWork) { IDirectoryProvider[] providers = shardingStrategy.GetDirectoryProvidersForDeletion(work.EntityClass, work.Id, work.IdInString); foreach (IDirectoryProvider provider in providers) { queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider)); } } else if (work is AddLuceneWork) { IDirectoryProvider provider = shardingStrategy.GetDirectoryProviderForAddition(work.EntityClass, work.Id, work.IdInString, work.Document); queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider)); } else if (work is DeleteLuceneWork) { IDirectoryProvider[] providers = shardingStrategy.GetDirectoryProvidersForDeletion(work.EntityClass, work.Id, work.IdInString); foreach (IDirectoryProvider provider in providers) { queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider)); } } else if (work is OptimizeLuceneWork) { IDirectoryProvider[] providers = shardingStrategy.GetDirectoryProvidersForAllShards(); foreach (IDirectoryProvider provider in providers) { queueWithFlatDPs.Add(new LuceneWorker.WorkWithPayload(work, provider)); } } else { throw new AssertionFailure("Unknown work type: " + work.GetType()); } } DeadLockFreeQueue(queueWithFlatDPs); CheckForBatchIndexing(workspace); foreach (LuceneWorker.WorkWithPayload luceneWork in queueWithFlatDPs) { worker.PerformWork(luceneWork); } } finally { workspace.Dispose(); queue.Clear(); } }
public DocumentBuilder(DocumentMapping classMapping, Analyzer defaultAnalyzer, IDirectoryProvider[] directoryProviders, IIndexShardingStrategy shardingStrategy) { analyzer = new ScopedAnalyzer(); this.directoryProviders = directoryProviders; this.shardingStrategy = shardingStrategy; if (classMapping == null) throw new AssertionFailure("Unable to build a DocumemntBuilder with a null class"); rootClassMapping = classMapping; Set<System.Type> processedClasses = new HashedSet<System.Type>(); processedClasses.Add(classMapping.MappedClass); CollectAnalyzers(rootClassMapping, defaultAnalyzer, true, string.Empty, processedClasses); //processedClasses.remove( clazz ); for the sake of completness analyzer.GlobalAnalyzer = defaultAnalyzer; if (idMapping == null) throw new SearchException("No document id for: " + classMapping.MappedClass.Name); }
public DocumentBuilder(System.Type clazz, Analyzer defaultAnalyzer, IDirectoryProvider[] directoryProviders, IIndexShardingStrategy shardingStrategy) { analyzer = new ScopedAnalyzer(); beanClass = clazz; this.directoryProviders = directoryProviders; this.shardingStrategy = shardingStrategy; if (clazz == null) throw new AssertionFailure("Unable to build a DocumemntBuilder with a null class"); rootPropertiesMetadata = new PropertiesMetadata(); rootPropertiesMetadata.boost = GetBoost(clazz); rootPropertiesMetadata.analyzer = defaultAnalyzer; Set<System.Type> processedClasses = new HashedSet<System.Type>(); processedClasses.Add(clazz); InitializeMembers(clazz, rootPropertiesMetadata, true, string.Empty, processedClasses); //processedClasses.remove( clazz ); for the sake of completness analyzer.GlobalAnalyzer = rootPropertiesMetadata.analyzer; if (idKeywordName == null) throw new SearchException("No document id for: " + clazz.Name); }
public DirectoryProviders(IIndexShardingStrategy shardingStrategy, IDirectoryProvider[] providers) { this.shardingStrategy = shardingStrategy; this.providers = providers; }