/// <inheritdoc /> public unsafe void CommitIndexCheckpoint(Guid indexToken, byte[] commitMetadata) { var device = NextIndexCheckpointDevice(indexToken); // Two phase to ensure we write metadata in single Write operation using var ms = new MemoryStream(); using var writer = new BinaryWriter(ms); writer.Write(commitMetadata.Length); writer.Write(commitMetadata); WriteInto(device, 0, ms.ToArray(), (int)ms.Position); device.Dispose(); if (removeOutdated) { var prior = indexTokenHistory[indexTokenHistoryOffset]; indexTokenHistory[indexTokenHistoryOffset] = indexToken; indexTokenHistoryOffset = (indexTokenHistoryOffset + 1) % indexTokenHistory.Length; if (prior != default) { deviceFactory.Delete(checkpointNamingScheme.IndexCheckpointBase(prior)); } } }
/// <inheritdoc /> public void Purge(Guid token) { // Try both because we do not know which type the guid denotes deviceFactory.Delete(checkpointNamingScheme.LogCheckpointBase(token)); deviceFactory.Delete(checkpointNamingScheme.IndexCheckpointBase(token)); }