/// <summary> /// Webインデックス作成 /// </summary> /// <param name="rootPath"></param> /// <param name="targetUrl"></param> /// <param name="targetDic"></param> /// <param name="progress"></param> /// <returns></returns> private static LuceneIndexBuilder CreateWebIndex( string rootPath, string targetUrl, Dictionary <string, WebContents> targetDic, IProgress <ProgressReport> progress) { //カウントを初期化 _targetCount = 0; _indexedCount = 0; _skippedCount = 0; _totalBytes = 0; _targetCount = targetDic.Count; _indexedPath = targetUrl; _indexStorePath = rootPath + IndexDirName + _reservedNo.ToString(); //インデックス保存場所フォルダ作成 System.IO.Directory.CreateDirectory(rootPath); System.IO.Directory.CreateDirectory(_indexStorePath); _createMode = CreateModes.Create; var instance = new LuceneIndexBuilder(); var options = new ParallelOptions() { MaxDegreeOfParallelism = 1 }; Parallel.Invoke(options, () => instance.CreateWebFSIndex( _indexStorePath, targetDic, progress, "IndexingThread1")); return(instance); }
private static LuceneIndexBuilder DoWorkMulti( Analyzer analyzer, string rootPath, string targetDir, IProgress <ProgressReport> progress) { DeleteOldIndexes(rootPath); // var instance = new LuceneIndexBuilder(); var options = new ParallelOptions() { MaxDegreeOfParallelism = 4 }; //Parallel.For(0, _targetFileList.Length, options, i => { // instance.PushRAMDir(progress, analyzer, _targetFileList[i], "Thread" + i.ToString()); //}); Parallel.Invoke(options, () => instance.WriteFromQueue(progress, rootPath, analyzer), () => instance.PushRAMDir(progress, analyzer, _targetFileList[0], "Thread1"), () => instance.PushRAMDir(progress, analyzer, _targetFileList[1], "Thread2")); return(instance); }
/// <summary> /// インデックス作成 /// </summary> /// <param name="rootPath"></param> /// <param name="targetDir"></param> /// <param name="progress"></param> /// <returns></returns> private static LuceneIndexBuilder CreateSingle( string rootPath, string targetDir, IProgress <ProgressReport> progress, string orgIndexStorePath) { //カウントを初期化 _targetCount = 0; _indexedCount = 0; _skippedCount = 0; _totalBytes = 0; var targetFileList = FileUtil.GetAllFileInfo(targetDir); _targetCount = targetFileList.Count; _indexedPath = targetDir; _indexStorePath = rootPath + IndexDirName + _reservedNo.ToString(); if (StringUtil.NullToBlank(orgIndexStorePath) != "") { //既存のIndexディレクトリのパスを取得 _indexStorePath = orgIndexStorePath; _createMode = CreateModes.Update; } else { //インデックス保存場所フォルダ作成 System.IO.Directory.CreateDirectory(rootPath); System.IO.Directory.CreateDirectory(_indexStorePath); _createMode = CreateModes.Create; } var instance = new LuceneIndexBuilder(); var options = new ParallelOptions() { MaxDegreeOfParallelism = 1 }; Parallel.Invoke(options, () => instance.CreateFSIndex( //rootPath + BuildDirName + "1", _indexStorePath, targetFileList, progress, "IndexingThread1")); return(instance); }