public async Task Test_Vector_Fast() { using (var db = await OpenTestPartitionAsync()) { var location = await GetCleanDirectory(db, "ranked_set"); var vector = new FdbRankedSet(location); await db.ReadWriteAsync(async (tr) => { await vector.OpenAsync(tr); await PrintRankedSet(vector, tr); }, this.Cancellation); Log(); var rnd = new Random(); var sw = Stopwatch.StartNew(); for (int i = 0; i < 100; i++) { Console.Write("\rInserting " + i); await db.ReadWriteAsync((tr) => vector.InsertAsync(tr, TuPack.EncodeKey(rnd.Next())), this.Cancellation); } sw.Stop(); Log("\rDone in {0:N3} sec", sw.Elapsed.TotalSeconds); await db.ReadAsync((tr) => PrintRankedSet(vector, tr), this.Cancellation); } }
public async Task Test_Vector_Fast() { using (var db = await OpenTestPartitionAsync()) { var location = db.Root["ranked_set"]; await CleanLocation(db, location); var rankedSet = new FdbRankedSet(location); await db.WriteAsync(tr => rankedSet.OpenAsync(tr), this.Cancellation); Log(await rankedSet.ReadAsync(db, (tr, state) => PrintRankedSet(state, tr), this.Cancellation)); Log(); var rnd = new Random(); var sw = Stopwatch.StartNew(); for (int i = 0; i < 100; i++) { //Log("Inserting " + i); await db.WriteAsync(async tr => { var state = await rankedSet.Resolve(tr); await state.InsertAsync(tr, TuPack.EncodeKey(rnd.Next())); }, this.Cancellation); } sw.Stop(); Log($"Done in {sw.Elapsed.TotalSeconds:N3} sec"); #if FULL_DEBUG await DumpSubspace(db, location); #endif Log(await rankedSet.ReadAsync(db, (tr, state) => PrintRankedSet(state, tr), this.Cancellation)); } }
public async Task Test_Vector_Fast() { using (var db = await OpenTestPartitionAsync()) { var location = await GetCleanDirectory(db, "ranked_set"); var vector = new FdbRankedSet(location); await db.ReadWriteAsync(async (tr) => { await vector.OpenAsync(tr); await PrintRankedSet(vector, tr); }, this.Cancellation); Console.WriteLine(); var rnd = new Random(); var sw = Stopwatch.StartNew(); for (int i = 0; i < 100; i++) { Console.Write("\rInserting " + i); await db.ReadWriteAsync((tr) => vector.InsertAsync(tr, FdbTuple.EncodeKey(rnd.Next())), this.Cancellation); } sw.Stop(); Console.WriteLine("\rDone in {0:N3} sec", sw.Elapsed.TotalSeconds); await db.ReadAsync((tr) => PrintRankedSet(vector, tr), this.Cancellation); } }
private static async Task PrintRankedSet(FdbRankedSet rs, IFdbReadOnlyTransaction tr) { var sb = new StringBuilder(); for (int l = 0; l < 6; l++) { sb.AppendFormat("Level {0}:\r\n", l); await tr.GetRange(rs.Subspace.Partition(l).ToRange()).ForEachAsync((kvp) => { sb.AppendFormat("\t{0} = {1}\r\n", rs.Subspace.Unpack(kvp.Key), kvp.Value.ToInt64()); }); } Console.WriteLine(sb.ToString()); }
private static async Task PrintRankedSet(FdbRankedSet rs, IFdbReadOnlyTransaction tr) { var sb = new StringBuilder(); for (int l = 0; l < 6; l++) { sb.AppendFormat("Level {0}:\r\n", l); await tr.GetRange(rs.Subspace.Partition.ByKey(l).Keys.ToRange()).ForEachAsync((kvp) => { sb.AppendFormat("\t{0} = {1}\r\n", rs.Subspace.Keys.Unpack(kvp.Key), kvp.Value.ToInt64()); }); } Log(sb.ToString()); }
public async Task Test_Vector_Fast() { using (var db = await OpenTestPartitionAsync()) { var location = await GetCleanDirectory(db, "ranked_set"); var vector = new FdbRankedSet(location); await db.ReadWriteAsync(async (tr) => { await vector.OpenAsync(tr); await PrintRankedSet(vector, tr); }, this.Cancellation); var rnd = new Random(); for (int i = 0; i < 1000; i++) { await db.ReadWriteAsync((tr) => vector.InsertAsync(tr, FdbTuple.Pack(rnd.Next())), this.Cancellation); } await db.ReadAsync((tr) => PrintRankedSet(vector, tr), this.Cancellation); } }
public async Task Test_Vector_Fast() { using (var db = await OpenTestPartitionAsync()) { var location = await GetCleanDirectory(db, "ranked_set"); var vector = new FdbRankedSet(location); await db.ReadWriteAsync(async (tr) => { await vector.OpenAsync(tr); await PrintRankedSet(vector, tr); }, this.Cancellation); var rnd = new Random(); for (int i = 0; i < 1000; i++) { await db.ReadWriteAsync((tr) => vector.InsertAsync(tr, FdbTuple.Pack(rnd.Next())), this.Cancellation); } await db.ReadAsync((tr) => PrintRankedSet(vector, tr), this.Cancellation); } }