public unsafe void RecoverAndTest(Guid cprVersion, Guid indexVersion) { // Recover fht.Recover(cprVersion, indexVersion); // Create array for reading var inputArray = new StructTuple <AdId, Input> [numUniqueKeys]; for (int i = 0; i < numUniqueKeys; i++) { inputArray[i] = new StructTuple <AdId, Input> { Item1 = new AdId { adId = i }, Item2 = new Input { numClicks = new NumClicks { numClicks = 0 } } }; } var outputArray = new Output[numUniqueKeys]; for (int i = 0; i < numUniqueKeys; i++) { outputArray[i] = new Output(); } // Register with thread var session = fht.NewSession(new Functions()); Input input = default; // Issue read requests for (var i = 0; i < numUniqueKeys; i++) { session.Read(ref inputArray[i].Item1, ref input, ref outputArray[i], Empty.Default, i); } // Complete all pending requests session.CompletePending(true); // Release session.Dispose(); // Test outputs var checkpointInfo = default(HybridLogRecoveryInfo); checkpointInfo.Recover(cprVersion, new DeviceLogCommitCheckpointManager( new LocalStorageNamedDeviceFactory(), new DefaultCheckpointNamingScheme( new DirectoryInfo(test_path).FullName))); // Compute expected array long[] expected = new long[numUniqueKeys]; foreach (var guid in checkpointInfo.continueTokens.Keys) { var cp = checkpointInfo.continueTokens[guid]; for (long i = 0; i <= cp.UntilSerialNo; i++) { var id = i % numUniqueKeys; expected[id]++; } } int threadCount = 1; // single threaded test int numCompleted = threadCount - checkpointInfo.continueTokens.Count; for (int t = 0; t < numCompleted; t++) { var sno = numOps; for (long i = 0; i < sno; i++) { var id = i % numUniqueKeys; expected[id]++; } } // Assert if expected is same as found for (long i = 0; i < numUniqueKeys; i++) { Assert.IsTrue( expected[i] == outputArray[i].value.numClicks, "Debug error for AdId {0}: Expected ({1}), Found({2})", inputArray[i].Item1.adId, expected[i], outputArray[i].value.numClicks); } }
public unsafe void RecoverAndTest(Guid cprVersion, Guid indexVersion) { // Recover fht.Recover(cprVersion, indexVersion); // Create array for reading var inputArray = new StructTuple <AdId, Input> [numUniqueKeys]; for (int i = 0; i < numUniqueKeys; i++) { inputArray[i] = new StructTuple <AdId, Input> { Item1 = new AdId { adId = i }, Item2 = new Input { numClicks = new NumClicks { numClicks = 0 } } }; } var outputArray = new Output[numUniqueKeys]; for (int i = 0; i < numUniqueKeys; i++) { outputArray[i] = new Output(); } // Register with thread fht.StartSession(); Input input = default(Input); // Issue read requests for (var i = 0; i < numUniqueKeys; i++) { fht.Read(ref inputArray[i].Item1, ref input, ref outputArray[i], Empty.Default, i); } // Complete all pending requests fht.CompletePending(true); // Release fht.StopSession(); // Test outputs var checkpointInfo = default(HybridLogRecoveryInfo); checkpointInfo.Recover(cprVersion, new DirectoryConfiguration(test_path)); // Compute expected array long[] expected = new long[numUniqueKeys]; foreach (var guid in checkpointInfo.continueTokens.Keys) { var sno = checkpointInfo.continueTokens[guid]; for (long i = 0; i <= sno; i++) { var id = i % numUniqueKeys; expected[id]++; } } int threadCount = 1; // single threaded test int numCompleted = threadCount - checkpointInfo.continueTokens.Count; for (int t = 0; t < numCompleted; t++) { var sno = numOps; for (long i = 0; i < sno; i++) { var id = i % numUniqueKeys; expected[id]++; } } // Assert if expected is same as found for (long i = 0; i < numUniqueKeys; i++) { Assert.IsTrue( expected[i] == outputArray[i].value.numClicks, "Debug error for AdId {0}: Expected ({1}), Found({2})", inputArray[i].Item1.adId, expected[i], outputArray[i].value.numClicks); } }
public unsafe void Populate() { // Prepare the dataset var inputArray = new StructTuple <AdId, Input> [numOps]; for (int i = 0; i < numOps; i++) { inputArray[i] = new StructTuple <AdId, Input> { Item1 = new AdId { adId = i % numUniqueKeys }, Item2 = new Input { numClicks = new NumClicks { numClicks = 1 } } }; } // Register thread with FASTER var session = fht.NewSession(new Functions()); // Prpcess the batch of input data bool first = true; for (int i = 0; i < numOps; i++) { session.RMW(ref inputArray[i].Item1, ref inputArray[i].Item2, Empty.Default, i); if ((i + 1) % checkpointInterval == 0) { if (first) { while (!fht.TakeFullCheckpoint(out token)) { ; } } else { while (!fht.TakeFullCheckpoint(out _)) { ; } } fht.CompleteCheckpointAsync().GetAwaiter().GetResult(); first = false; } if (i % completePendingInterval == 0) { session.CompletePending(false); } } // Make sure operations are completed session.CompletePending(true); session.Dispose(); }
public unsafe void Populate() { // Prepare the dataset var inputArray = new StructTuple <AdId, Input> [numOps]; for (int i = 0; i < numOps; i++) { inputArray[i] = new StructTuple <AdId, Input> { Item1 = new AdId { adId = i % numUniqueKeys }, Item2 = new Input { numClicks = new NumClicks { numClicks = 1 } } }; } // Register thread with FASTER fht.StartSession(); // Prpcess the batch of input data bool first = true; for (int i = 0; i < numOps; i++) { fht.RMW(ref inputArray[i].Item1, ref inputArray[i].Item2, Empty.Default, i); if ((i + 1) % checkpointInterval == 0) { if (first) { while (!fht.TakeFullCheckpoint(out token)) { fht.Refresh(); } } else { while (!fht.TakeFullCheckpoint(out Guid nextToken)) { fht.Refresh(); } } fht.CompleteCheckpoint(true); first = false; } if (i % completePendingInterval == 0) { fht.CompletePending(false); } else if (i % refreshInterval == 0) { fht.Refresh(); } } // Make sure operations are completed fht.CompletePending(true); // Deregister thread from FASTER fht.StopSession(); }