Skip to content

Commit

Permalink
Fix TermGapFiller namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
JPWatson committed Apr 23, 2018
1 parent 59e105a commit b1c7e98
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
1 change: 0 additions & 1 deletion src/Adaptive.Aeron.Tests/LogBuffer/TermGapFillerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
59 changes: 28 additions & 31 deletions src/Adaptive.Aeron/LogBuffer/TermGapFiller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,43 @@

namespace Adaptive.Aeron.LogBuffer
{
namespace io.aeron.logbuffer
/// <summary>
/// Fills a gap in a term with a padding record.
/// </summary>
public class TermGapFiller
{
/// <summary>
/// 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 <seealso cref="FrameDescriptor.FRAME_ALIGNMENT"/> boundary.
/// </summary>
public class TermGapFiller
/// <param name="logMetaDataBuffer"> containing the default headers </param>
/// <param name="termBuffer"> to gap fill </param>
/// <param name="termId"> for the current term. </param>
/// <param name="gapOffset"> to fill from </param>
/// <param name="gapLength"> to length of the gap. </param>
/// <returns> true if the gap has been filled with a padding record or false if data found. </returns>
public static bool TryFillGap(UnsafeBuffer logMetaDataBuffer, UnsafeBuffer termBuffer, int termId, int gapOffset, int gapLength)
{
/// <summary>
/// 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 <seealso cref="FrameDescriptor.FRAME_ALIGNMENT"/> boundary.
/// </summary>
/// <param name="logMetaDataBuffer"> containing the default headers </param>
/// <param name="termBuffer"> to gap fill </param>
/// <param name="termId"> for the current term. </param>
/// <param name="gapOffset"> to fill from </param>
/// <param name="gapLength"> to length of the gap. </param>
/// <returns> true if the gap has been filled with a padding record or false if data found. </returns>
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;
}
}
}

0 comments on commit b1c7e98

Please sign in to comment.