public void Sort_Int_Desc() { var rnd = new Random(); var source = Enumerable.Range(0, 20000) .Select(x => new KeyValuePair <BsonValue, PageAddress>(rnd.Next(1, 30000), PageAddress.Empty)) .ToArray(); var pragmas = new EnginePragmas(null); pragmas.Set(Pragmas.COLLATION, Collation.Binary.ToString(), false); using (var tempDisk = new SortDisk(_factory, 10 * 8192, pragmas)) using (var s = new SortService(tempDisk, Query.Descending, pragmas)) { s.Insert(source); s.Count.Should().Be(20000); s.Containers.Count.Should().Be(3); s.Containers.ElementAt(0).Count.Should().Be(8192); s.Containers.ElementAt(1).Count.Should().Be(8192); s.Containers.ElementAt(2).Count.Should().Be(3616); var output = s.Sort().ToArray(); output.Should().Equal(source.OrderByDescending(x => x.Key).ToArray()); } }
public void Sort_Int_Desc() { var rnd = new Random(); var source = Enumerable.Range(0, 20000) .Select(x => new KeyValuePair <BsonValue, PageAddress>(rnd.Next(1, 30000), PageAddress.Empty)) .ToArray(); using (var tempDisk = new SortDisk(_factory, 10 * 8192, false)) using (var s = new SortService(tempDisk, Query.Descending)) { s.Insert(source); Assert.AreEqual(20000, s.Count); Assert.AreEqual(3, s.Containers.Count); Assert.AreEqual(8192, s.Containers.ElementAt(0).Count); Assert.AreEqual(8192, s.Containers.ElementAt(1).Count); Assert.AreEqual(3616, s.Containers.ElementAt(2).Count); var output = s.Sort().ToArray(); CollectionAssert.AreEqual(source.OrderByDescending(x => x.Key).ToArray(), output); } }
public void Sort_String_Asc() { var source = Enumerable.Range(0, 2000) .Select(x => Guid.NewGuid().ToString()) .Select(x => new KeyValuePair <BsonValue, PageAddress>(x, PageAddress.Empty)) .ToArray(); var pragmas = new EnginePragmas(null); pragmas.Set("COLLATION", Collation.Binary.ToString(), false); using (var tempDisk = new SortDisk(_factory, 10 * 8192, pragmas)) using (var s = new SortService(tempDisk, Query.Ascending, pragmas)) { s.Insert(source); s.Count.Should().Be(2000); s.Containers.Count.Should().Be(2); s.Containers.ElementAt(0).Count.Should().Be(1905); s.Containers.ElementAt(1).Count.Should().Be(95); var output = s.Sort().ToArray(); output.Should().Equal(source.OrderBy(x => x.Key).ToArray()); } }
public void Sort_String_Asc() { var source = Enumerable.Range(0, 2000) .Select(x => Guid.NewGuid().ToString()) .Select(x => new KeyValuePair <BsonValue, PageAddress>(x, PageAddress.Empty)) .ToArray(); using (var tempDisk = new SortDisk(_factory, 10 * 8192, false)) using (var s = new SortService(tempDisk, Query.Ascending)) { s.Insert(source); Assert.AreEqual(2000, s.Count); Assert.AreEqual(2, s.Containers.Count); Assert.AreEqual(1905, s.Containers.ElementAt(0).Count); Assert.AreEqual(95, s.Containers.ElementAt(1).Count); var output = s.Sort().ToArray(); CollectionAssert.AreEqual(source.OrderBy(x => x.Key).ToArray(), output); } }