public int Index(Document doc, bool deleteold) { checkloaded(); _log.Info("indexing doc : " + doc.FileName); DateTime dt = FastDateTime.Now; if (deleteold && doc.DocNumber > -1) { _deleted.Set(true, doc.DocNumber); } if (deleteold == true || doc.DocNumber == -1) { doc.DocNumber = _lastDocNum++; } // save doc to disk string dstr = fastJSON.JSON.ToJSON(doc, new fastJSON.JSONParameters { UseExtensions = false }); _docs.Set(doc.FileName.ToLower(), Encoding.Unicode.GetBytes(dstr)); _log.Info("writing doc to disk (ms) = " + FastDateTime.Now.Subtract(dt).TotalMilliseconds); dt = FastDateTime.Now; // index doc AddtoIndex(doc.DocNumber, doc.Text); _log.Info("indexing time (ms) = " + FastDateTime.Now.Subtract(dt).TotalMilliseconds); return(_lastDocNum); }
/// <summary> /// write a delete record /// </summary> /// <param name="id"></param> /// <returns></returns> internal bool Delete(T id) { int rec = (int)_archive.Delete(id); _deleted.Set(true, rec); return(_index.RemoveKey(id)); }
internal bool Delete(T id, byte[] data) { // write a delete record int rec = _archive.WriteData(id, data, true); _deleted.Set(true, rec); return(_index.RemoveKey(id)); }