/// <summary> /// Regenerates the index. /// </summary> /// <returns></returns> public async Task Regenerate() { int c = 0; int d = 0; await this.ClearAsync(); using (ObjectBTreeFileEnumerator <object> e = await this.objectFile.GetTypedEnumeratorAsync <object>(true)) { while (await e.MoveNextAsync()) { object Obj = e.Current; if (Obj != null) { c++; await this.SaveNewObject((Guid)e.CurrentObjectId, e.Current, e.CurrentSerializer); } else { d++; } } } Log.Notice("Index regenerated.", this.indexFile.FileName, new KeyValuePair <string, object>("NrObjects", c), new KeyValuePair <string, object>("NrNotLoadable", d)); }
/// <summary> /// Loads the entire table and returns it as an array. /// </summary> /// <returns>Array of key-value pairs.</returns> public async Task <KeyValuePair <string, object>[]> ToArrayAsync() { List <KeyValuePair <string, object> > Result = new List <KeyValuePair <string, object> >(); using (ObjectBTreeFileEnumerator <KeyValuePair <string, object> > e = await this.GetEnumerator(true)) { while (await e.MoveNextAsync()) { Result.Add(e.Current); } } return(Result.ToArray()); }
/// <summary> /// Regenerates the index. /// </summary> /// <returns></returns> public async Task Regenerate() { LinkedList <object> Objects = new LinkedList <object>(); LinkedList <Guid> ObjectIds = new LinkedList <Guid>(); IObjectSerializer LastSerializer = null; int Count = 0; int c = 0; int d = 0; await this.ClearAsync(); using (ObjectBTreeFileEnumerator <object> e = await this.objectFile.GetTypedEnumeratorAsync <object>(LockType.Write)) { while (await e.MoveNextAsync()) { object Obj = e.Current; IObjectSerializer Serializer = e.CurrentSerializer; if (!(Obj is null)) { if (LastSerializer is null || Serializer != LastSerializer) { if (Count > 0) { await this.SaveNewObjects(ObjectIds, Objects, LastSerializer); ObjectIds.Clear(); Objects.Clear(); Count = 0; } LastSerializer = Serializer; } ObjectIds.AddLast((Guid)e.CurrentObjectId); Objects.AddLast(Obj); c++; Count++; if (Count >= 1000) { await this.SaveNewObjects(ObjectIds, Objects, LastSerializer); ObjectIds.Clear(); Objects.Clear(); Count = 0; } }
/// <summary> /// Regenerates the index. /// </summary> /// <returns></returns> public async Task Regenerate() { LinkedList <object> Objects = new LinkedList <object>(); LinkedList <Guid> ObjectIds = new LinkedList <Guid>(); IObjectSerializer LastSerializer = null; int Count = 0; int c = 0; int d = 0; await this.ClearAsync(); using (ObjectBTreeFileEnumerator <object> e = await this.objectFile.GetTypedEnumeratorAsync <object>(true)) { while (await e.MoveNextAsync()) { object Obj = e.Current; IObjectSerializer Serializer = e.CurrentSerializer; if (Obj != null) { if (LastSerializer is null || Serializer != LastSerializer) { LastSerializer = Serializer; if (Count > 0) { await this.SaveNewObjects(ObjectIds, Objects, LastSerializer); ObjectIds.Clear(); Objects.Clear(); Count = 0; } } ObjectIds.AddLast((Guid)e.CurrentObjectId); Objects.AddLast(Obj); c++; Count++; if (Count >= 1000) { await this.SaveNewObjects(ObjectIds, Objects, LastSerializer); ObjectIds.Clear(); Objects.Clear(); Count = 0; } } else { d++; } } if (Count > 0) { await this.SaveNewObjects(ObjectIds, Objects, LastSerializer); } } Log.Notice("Index regenerated.", this.indexFile.FileName, new KeyValuePair <string, object>("NrObjects", c), new KeyValuePair <string, object>("NrNotLoadable", d)); }