public void LargeObjectTest(CheckpointType checkpointType) { MyInput input = default; MyLargeOutput output = new MyLargeOutput(); log = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.log"); objlog = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.obj.log"); fht1 = new FasterKV <MyKey, MyLargeValue> (128, new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, PageSizeBits = 21, MemorySizeBits = 26 }, new CheckpointSettings { CheckpointDir = test_path, CheckPointType = checkpointType }, new SerializerSettings <MyKey, MyLargeValue> { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyLargeValueSerializer() } ); int maxSize = 100; int numOps = 5000; var session1 = fht1.For(new MyLargeFunctions()).NewSession <MyLargeFunctions>(); Random r = new Random(33); for (int key = 0; key < numOps; key++) { var mykey = new MyKey { key = key }; var value = new MyLargeValue(1 + r.Next(maxSize)); session1.Upsert(ref mykey, ref value, Empty.Default, 0); } session1.Dispose(); fht1.TakeFullCheckpoint(out Guid token); fht1.CompleteCheckpointAsync().GetAwaiter().GetResult(); fht1.Dispose(); log.Dispose(); objlog.Dispose(); log = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.log"); objlog = Devices.CreateLogDevice(test_path + "\\LargeObjectTest.obj.log"); fht2 = new FasterKV <MyKey, MyLargeValue> (128, new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, PageSizeBits = 21, MemorySizeBits = 26 }, new CheckpointSettings { CheckpointDir = test_path, CheckPointType = checkpointType }, new SerializerSettings <MyKey, MyLargeValue> { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyLargeValueSerializer() } ); fht2.Recover(token); var session2 = fht2.For(new MyLargeFunctions()).NewSession <MyLargeFunctions>(); for (int keycnt = 0; keycnt < numOps; keycnt++) { var key = new MyKey { key = keycnt }; var status = session2.Read(ref key, ref input, ref output, Empty.Default, 0); if (status == Status.PENDING) { session2.CompletePending(true); } else { for (int i = 0; i < output.value.value.Length; i++) { Assert.IsTrue(output.value.value[i] == (byte)(output.value.value.Length + i)); } } } session2.Dispose(); fht2.Dispose(); log.Dispose(); objlog.Dispose(); }
public void LargeObjectTest1() { log = FasterFactory.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog", deleteOnClose: true); objlog = FasterFactory.CreateObjectLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog", deleteOnClose: true); Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints"); fht1 = FasterFactory.Create <MyKey, MyLargeValue, MyInput, MyLargeOutput, MyContext, MyLargeFunctions> (indexSizeBuckets: 128, functions: new MyLargeFunctions(), logSettings: new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 29 }, checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot } ); fht2 = FasterFactory.Create <MyKey, MyLargeValue, MyInput, MyLargeOutput, MyContext, MyLargeFunctions> (indexSizeBuckets: 128, functions: new MyLargeFunctions(), logSettings: new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, MemorySizeBits = 29 }, checkpointSettings: new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot } ); int maxSize = 1000; int numOps = 5000; //var value = new MyLargeValue(size); fht1.StartSession(); Random r = new Random(33); for (int key = 0; key < numOps; key++) { var value = new MyLargeValue(1 + r.Next(maxSize)); fht1.Upsert(new MyKey { key = key }, value, null, 0); } fht1.TakeFullCheckpoint(out Guid token); fht1.CompleteCheckpoint(true); fht1.StopSession(); fht1.Dispose(); MyLargeOutput output = new MyLargeOutput(); fht2.Recover(token); fht2.StartSession(); for (int key = 0; key < numOps; key++) { var status = fht2.Read(new MyKey { key = key }, new MyInput(), ref output, null, 0); if (status == Status.PENDING) { fht2.CompletePending(true); } else { for (int i = 0; i < output.value.value.Length; i++) { Assert.IsTrue(output.value.value[i] == (byte)(output.value.value.Length + i)); } } } fht2.StopSession(); fht2.Dispose(); log.Close(); objlog.Close(); new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints").Delete(true); }
public void LargeObjectTest1() { MyInput input = default(MyInput); MyLargeOutput output = new MyLargeOutput(); log = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog.log", deleteOnClose: true); objlog = Devices.CreateLogDevice(TestContext.CurrentContext.TestDirectory + "\\hlog.obj.log", deleteOnClose: true); Directory.CreateDirectory(TestContext.CurrentContext.TestDirectory + "\\checkpoints"); fht1 = new FasterKV <MyKey, MyLargeValue, MyInput, MyLargeOutput, Empty, MyLargeFunctions> (128, new MyLargeFunctions(), new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, PageSizeBits = 21, MemorySizeBits = 26 }, new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot }, new SerializerSettings <MyKey, MyLargeValue> { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyLargeValueSerializer() } ); fht2 = new FasterKV <MyKey, MyLargeValue, MyInput, MyLargeOutput, Empty, MyLargeFunctions> (128, new MyLargeFunctions(), new LogSettings { LogDevice = log, ObjectLogDevice = objlog, MutableFraction = 0.1, PageSizeBits = 21, MemorySizeBits = 26 }, new CheckpointSettings { CheckpointDir = TestContext.CurrentContext.TestDirectory + "\\checkpoints", CheckPointType = CheckpointType.Snapshot }, new SerializerSettings <MyKey, MyLargeValue> { keySerializer = () => new MyKeySerializer(), valueSerializer = () => new MyLargeValueSerializer() } ); int maxSize = 100; int numOps = 5000; fht1.StartSession(); Random r = new Random(33); for (int key = 0; key < numOps; key++) { var mykey = new MyKey { key = key }; var value = new MyLargeValue(1 + r.Next(maxSize)); fht1.Upsert(ref mykey, ref value, Empty.Default, 0); } fht1.TakeFullCheckpoint(out Guid token); fht1.CompleteCheckpoint(true); fht1.StopSession(); fht1.Dispose(); fht2.Recover(token); fht2.StartSession(); for (int keycnt = 0; keycnt < numOps; keycnt++) { var key = new MyKey { key = keycnt }; var status = fht2.Read(ref key, ref input, ref output, Empty.Default, 0); if (status == Status.PENDING) { fht2.CompletePending(true); } else { for (int i = 0; i < output.value.value.Length; i++) { Assert.IsTrue(output.value.value[i] == (byte)(output.value.value.Length + i)); } } } fht2.StopSession(); fht2.Dispose(); log.Close(); objlog.Close(); new DirectoryInfo(TestContext.CurrentContext.TestDirectory + "\\checkpoints").Delete(true); }