예제 #1
0
 public static TimeSpan WriteIndexWithEvent(Analyzer analyzer, IndexerSet indexer, Source source, bool create,
                                         IndexCompletedEventHandler OnIndexCompleted,
                                         IndexProgressChangedEventHandler OnProgressChanged)
 {
     try
     {
         //ChineseSegAnalysis csa = new ChineseSegAnalysis(index.BasePath, index.NamePath, index.NumberPath, index.CustomPaths);
         //csa.FilterFilePath = index.FilterPath;
         //Analyzer analyzer = csa.GetAnalyzer();
         string connect = source.GetConnString();
         DateTime start;
         if (create)
         {
             DBRamCreateIndexer dbcIndexer = new DBRamCreateIndexer(analyzer, source.DBType, connect, index.Path,index.Caption);
             dbcIndexer.OnIndexCompleted += OnIndexCompleted;
             dbcIndexer.OnProgressChanged += OnProgressChanged;
             start = DateTime.Now;
             dbcIndexer.WriteResultsWithEvent(source.Query, indexer.MaxFieldLength, indexer.RamBufferSize, indexer.MergeFactor, indexer.MaxBufferedDocs);
             return DateTime.Now - start;
         }
         else
         {
             DBRamIncremIndexer dbiIndexer = new DBRamIncremIndexer(analyzer, source.DBType, connect, index.Path,index.Caption);
             dbiIndexer.OnIndexCompleted += OnIndexCompleted;
             dbiIndexer.OnProgressChanged += OnProgressChanged;
             start = DateTime.Now;
             dbiIndexer.WriteResultsWithEvent(source.Query, indexer.MaxFieldLength, indexer.RamBufferSize, indexer.MergeFactor, indexer.MaxBufferedDocs);
             return DateTime.Now - start;
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #2
0
 public static TimeSpan WriteIndex(Analyzer analyzer,IndexerSet indexer, Source source,bool create)
 {
     try
     {
         //ChineseSegAnalysis csa = new ChineseSegAnalysis(index.BasePath, index.NamePath, index.NumberPath, index.CustomPaths);
         //csa.FilterFilePath = index.FilterPath;
         //Analyzer analyzer = csa.GetAnalyzer();
         string connect = source.GetConnString();
         DateTime start;
         if (create)
         {
             DBCreateIndexer dbcIndexer = new DBCreateIndexer(analyzer, source.DBType, connect, index.Path,index.Caption);
             dbcIndexer.PrimaryKey = source.PrimaryKey;
             start = DateTime.Now;
             dbcIndexer.WriteResults(source.Query,indexer.MaxFieldLength,indexer.RamBufferSize, indexer.MergeFactor, indexer.MaxBufferedDocs);
             return DateTime.Now - start;
         }
         else
         {
             DBIncremIndexer dbiIndexer = new DBIncremIndexer(analyzer, source.DBType, connect, index.Path,index.Caption);
             dbiIndexer.PrimaryKey = source.PrimaryKey;
             start = DateTime.Now;
             dbiIndexer.WriteResults(source.Query, indexer.MaxFieldLength, indexer.RamBufferSize, indexer.MergeFactor, indexer.MaxBufferedDocs);                 
             return DateTime.Now - start;
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }