private void TestPersistence(ulong count, ExpandableArrayOfKeys keys) { using (var validEntries = new BitVector(_pool)) { validEntries.EnsureCapacity(count); validEntries.ChangeAll(true); using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Create, FileAccess.ReadWrite)) { using (var writer = new BinaryWriter(stream)) { keys.Write(writer, (ulong)count, validEntries); } } using (var keys2 = new ExpandableArrayOfKeys(_pool)) { using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Open, FileAccess.Read)) { using (var reader = new BinaryReader(stream)) { { keys2.Read(reader, (ulong)count, validEntries); } } } } } }
private void TestSetAll() { using (var vector = new BitVector(Pool)) { vector.EnsureCapacity(100000000); for (ulong i = 0; i < vector.Capacity; i++) { if (i % 3 == 0 || i % 7 == 0) { vector.Set(i); } } for (ulong i = 0; i < vector.Capacity; i++) { if (i % 3 == 0 || i % 7 == 0) { IsFalse(!vector.Get(i)); } } vector.ChangeAll(false); for (ulong i = 0; i < vector.Capacity; i++) { IsFalse(vector.Get(i)); } vector.ChangeAll(true); for (ulong i = 0; i < vector.Capacity; i++) { IsFalse(!vector.Get(i)); } } }
public void TestIndexInt32() { using (var validDocsBitmap = new BitVector(Pool)) { validDocsBitmap.EnsureCapacity(4); validDocsBitmap.ChangeAll(true); using (var data = new ColumnData<int>(DbType.Int32, Pool)) { data.EnsureCapacity(4); data.DataArray.GetBlock(0)[0] = 1; data.DataArray.GetBlock(0)[1] = 3; data.DataArray.GetBlock(0)[2] = -1; data.DataArray.GetBlock(0)[3] = 555; data.NotNulls.Set(0); data.NotNulls.Set(1); data.NotNulls.Set(2); data.NotNulls.Clear(3); var index = new SortIndex(); index.Update(data, validDocsBitmap, 4); Assert.AreEqual(4, index.OrderData.Length); // expected resulting order: 3, 2, 0, 1 // item 3 goes on top because it is marked as NULL Assert.AreEqual(3, index.OrderData[0]); Assert.AreEqual(2, index.OrderData[1]); Assert.AreEqual(0, index.OrderData[2]); Assert.AreEqual(1, index.OrderData[3]); } } }
public void TestIndexInt32() { using (var validDocsBitmap = new BitVector(Pool)) { validDocsBitmap.EnsureCapacity(4); validDocsBitmap.ChangeAll(true); using (var data = new ColumnData <int>(DbType.Int32, Pool)) { data.EnsureCapacity(4); data.DataArray.GetBlock(0)[0] = 1; data.DataArray.GetBlock(0)[1] = 3; data.DataArray.GetBlock(0)[2] = -1; data.DataArray.GetBlock(0)[3] = 555; data.NotNulls.Set(0); data.NotNulls.Set(1); data.NotNulls.Set(2); data.NotNulls.Clear(3); var index = new SortIndex(); index.Update(data, validDocsBitmap, 4); Assert.AreEqual(4, index.OrderData.Length); // expected resulting order: 3, 2, 0, 1 // item 3 goes on top because it is marked as NULL Assert.AreEqual(3, index.OrderData[0]); Assert.AreEqual(2, index.OrderData[1]); Assert.AreEqual(0, index.OrderData[2]); Assert.AreEqual(1, index.OrderData[3]); } } }
private void TestSetAll() { using (var vector = new BitVector(Pool)) { vector.EnsureCapacity(100000000); for (ulong i = 0; i < vector.Capacity; i++) { if (i % 3 == 0 || i % 7 == 0) { vector.Set(i); } } for (ulong i = 0; i < vector.Capacity; i++) { if (i % 3 == 0 || i % 7 == 0) { IsFalse(!vector.Get(i)); } } vector.ChangeAll(false); for (ulong i = 0; i < vector.Capacity; i++) { IsFalse(vector.Get(i)); } vector.ChangeAll(true); for (ulong i = 0; i < vector.Capacity; i++) { IsFalse(!vector.Get(i)); } } }
private void TestPersistence(ulong count, ExpandableArrayOfKeys keys) { using (var validEntries = new BitVector(_pool)) { validEntries.EnsureCapacity(count); validEntries.ChangeAll(true); using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Create, FileAccess.ReadWrite)) { using (var writer = new BinaryWriter(stream)) { keys.Write(writer, (ulong) count, validEntries); } } using (var keys2 = new ExpandableArrayOfKeys(_pool)) { using (var stream = new FileStream(@"c:\temp\data.d", FileMode.Open, FileAccess.Read)) { using (var reader = new BinaryReader(stream)) { { keys2.Read(reader, (ulong) count, validEntries); } } } } } }