diff --git a/src/Adaptive.Aeron.Tests/LogBuffer/TermGapFillerTests.cs b/src/Adaptive.Aeron.Tests/LogBuffer/TermGapFillerTests.cs index 7e8308f3..52432245 100644 --- a/src/Adaptive.Aeron.Tests/LogBuffer/TermGapFillerTests.cs +++ b/src/Adaptive.Aeron.Tests/LogBuffer/TermGapFillerTests.cs @@ -15,7 +15,6 @@ */ using Adaptive.Aeron.LogBuffer; -using Adaptive.Aeron.LogBuffer.io.aeron.logbuffer; using Adaptive.Aeron.Protocol; using Adaptive.Agrona.Concurrent; using NUnit.Framework; diff --git a/src/Adaptive.Aeron/LogBuffer/TermGapFiller.cs b/src/Adaptive.Aeron/LogBuffer/TermGapFiller.cs index fa08b2a7..f14869dc 100644 --- a/src/Adaptive.Aeron/LogBuffer/TermGapFiller.cs +++ b/src/Adaptive.Aeron/LogBuffer/TermGapFiller.cs @@ -19,46 +19,43 @@ namespace Adaptive.Aeron.LogBuffer { - namespace io.aeron.logbuffer + /// + /// Fills a gap in a term with a padding record. + /// + public class TermGapFiller { /// - /// Fills a gap in a term with a padding record. + /// Try to gap fill the current term at a given offset if the gap contains no data. + /// + /// Note: the gap offset plus gap length must end on a boundary. /// - public class TermGapFiller + /// containing the default headers + /// to gap fill + /// for the current term. + /// to fill from + /// to length of the gap. + /// true if the gap has been filled with a padding record or false if data found. + public static bool TryFillGap(UnsafeBuffer logMetaDataBuffer, UnsafeBuffer termBuffer, int termId, int gapOffset, int gapLength) { - /// - /// Try to gap fill the current term at a given offset if the gap contains no data. - /// - /// Note: the gap offset plus gap length must end on a boundary. - /// - /// containing the default headers - /// to gap fill - /// for the current term. - /// to fill from - /// to length of the gap. - /// true if the gap has been filled with a padding record or false if data found. - public static bool TryFillGap(UnsafeBuffer logMetaDataBuffer, UnsafeBuffer termBuffer, int termId, int gapOffset, int gapLength) - { - int offset = gapOffset + gapLength - FrameDescriptor.FRAME_ALIGNMENT; + int offset = gapOffset + gapLength - FrameDescriptor.FRAME_ALIGNMENT; - while (offset >= gapOffset) + while (offset >= gapOffset) + { + if (0 != termBuffer.GetInt(offset)) { - if (0 != termBuffer.GetInt(offset)) - { - return false; - } - - offset -= FrameDescriptor.FRAME_ALIGNMENT; + return false; } - LogBufferDescriptor.ApplyDefaultHeader(logMetaDataBuffer, termBuffer, gapOffset); - FrameDescriptor.FrameType(termBuffer, gapOffset, HeaderFlyweight.HDR_TYPE_PAD); - FrameDescriptor.FrameTermOffset(termBuffer, gapOffset); - FrameDescriptor.FrameTermId(termBuffer, gapOffset, termId); - FrameDescriptor.FrameLengthOrdered(termBuffer, gapOffset, gapLength); - - return true; + offset -= FrameDescriptor.FRAME_ALIGNMENT; } + + LogBufferDescriptor.ApplyDefaultHeader(logMetaDataBuffer, termBuffer, gapOffset); + FrameDescriptor.FrameType(termBuffer, gapOffset, HeaderFlyweight.HDR_TYPE_PAD); + FrameDescriptor.FrameTermOffset(termBuffer, gapOffset); + FrameDescriptor.FrameTermId(termBuffer, gapOffset, termId); + FrameDescriptor.FrameLengthOrdered(termBuffer, gapOffset, gapLength); + + return true; } } } \ No newline at end of file