/// <inheritdoc />
        public unsafe void Commit(long beginAddress, long untilAddress, byte[] commitMetadata, long commitNum)
        {
            using var device = deviceFactory.Get(checkpointNamingScheme.FasterLogCommitMetadata(commitNum));

            // 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);

            if (removeOutdated)
            {
                var prior = flogCommitHistory[flogCommitHistoryOffset];
                flogCommitHistory[flogCommitHistoryOffset] = commitNum;
                flogCommitHistoryOffset = (byte)((flogCommitHistoryOffset + 1) % flogCommitCount);
                if (prior != default)
                {
                    deviceFactory.Delete(checkpointNamingScheme.FasterLogCommitMetadata(prior));
                }
            }
        }
        /// <inheritdoc />
        public byte[] GetCommitMetadata(long commitNum)
        {
            IDevice device;

            if (overwriteLogCommits)
            {
                if (singleLogCommitDevice == null)
                {
                    singleLogCommitDevice = deviceFactory.Get(checkpointNamingScheme.FasterLogCommitMetadata(commitNum));
                }
                device = singleLogCommitDevice;
            }
            else
            {
                device         = deviceFactory.Get(checkpointNamingScheme.FasterLogCommitMetadata(commitNum));
                this.commitNum = commitNum + 1;
            }


            ReadInto(device, 0, out byte[] writePad, sizeof(int));
            int size = BitConverter.ToInt32(writePad, 0);

            byte[] body;
            if (writePad.Length >= size + sizeof(int))
            {
                body = writePad;
            }
            else
            {
                ReadInto(device, 0, out body, size + sizeof(int));
            }

            if (!overwriteLogCommits)
            {
                device.Close();
            }

            return(new Span <byte>(body).Slice(sizeof(int)).ToArray());
        }