public void BuildFullIndex() { SetTreeOptions(); this.FullIndex = new BPlusTree <string, int>(Options); Dictionary <string, int> grams = new Dictionary <string, int>(); for (int i = 0; i < LuceneService.DirReader.MaxDoc; i++) { var msg = LuceneService.DirReader.Document(i).GetField(ProjectInfo.TextFieldKey).GetStringValue(); int value; foreach (var gram in GetNGrams(ProjectInfo.TextFieldKey, msg)) { if (!grams.TryGetValue(gram, out value)) { grams.Add(gram, 1); } else { grams[gram]++; } } } FullIndex.BulkInsert(grams, bulkOptions); grams = null; this.IndexExists = true; this.IndexIsRead = true; GC.Collect(); GC.WaitForPendingFinalizers(); }
private void UpdateIndexWith(int subIndex) { var parts = FullIndex.Split('.'); parts[parts.Length - 1] = subIndex.ToString(); FullIndex = string.Join('.', parts); }
private int GetSubIndex() => int.Parse(FullIndex.Split('.').Last());
private int GetLevel() => FullIndex.Split('.').Count() - 1;