示例#1
0
文件: Indexer.cs 项目: 5andi5/Indexer
 private void IndexFile(ref int newCount, ref int updatedCount, ref int unchangedCount, CdrReader cdrReader, FileInfo file)
 {
     string path = file.FullName;
     string hash = CalculateHash(path);
     Entry entry = LuceneStore.Current.Find(path);
     if (entry == null)
     {
         this.log("+");
         newCount++;
         entry = new Entry
         {
             Path = file.FullName.ToLower(),
             Name = file.Name,
             Hash = hash,
             ModifiedOn = file.LastWriteTime,
         };
         ReadText(path, entry, cdrReader);
         LuceneStore.Current.Insert(entry);
     }
     else if (entry.Hash != hash)
     {
         this.log("*");
         updatedCount++;
         entry.Hash = hash;
         ReadText(path, entry, cdrReader);
         LuceneStore.Current.Update(entry);
     }
     else
     {
         this.log(".");
         unchangedCount++;
     }
     this.onFileIndexed();
 }
示例#2
0
 public void Update(Entry entry)
 {
     this.writer.UpdateDocument(FindTerm(entry.Path), entry.ToDocument());
     this.writer.Flush(triggerMerge: false, flushDocStores: true, flushDeletes: true);
 }
示例#3
0
文件: Indexer.cs 项目: 5andi5/Indexer
 private void ReadText(string path, Entry entry, CdrReader cdrReader)
 {
     entry.Text = cdrReader.ReadText(path);
     entry.CalculateAll();
 }
示例#4
0
 public void Insert(Entry entry)
 {
     this.writer.AddDocument(entry.ToDocument());
     this.writer.Flush(triggerMerge: false, flushDocStores: true, flushDeletes: true);
 }