Skip to content

Commit

Permalink
[Java] Fix typo using the wrong field. Should have been termBufferLen…
Browse files Browse the repository at this point in the history
…gth.
  • Loading branch information
mjpt777 committed Jul 15, 2017
1 parent b11194e commit b155bf6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ enum Status
private final int sessionId;
private final int streamId;
private final int tripGain;
private final int termBufferLength;
private final int termWindowLength;
private final int positionBitsToShift;
private final int initialTermId;
Expand Down Expand Up @@ -84,6 +85,7 @@ public IpcPublication(
this.initialTermId = initialTermId(rawLog.metaData());

final int termLength = rawLog.termLength();
this.termBufferLength = termLength;
this.positionBitsToShift = Integer.numberOfTrailingZeros(termLength);
this.termWindowLength = Configuration.ipcPublicationTermWindowLength(termLength);
this.tripGain = termWindowLength / 8;
Expand Down Expand Up @@ -195,7 +197,7 @@ private void cleanBuffer(final long minConsumerPosition)
final long cleanPosition = this.cleanPosition;
final UnsafeBuffer dirtyTerm = termBuffers[indexByPosition(cleanPosition, positionBitsToShift)];
final int bytesForCleaning = (int)(minConsumerPosition - cleanPosition);
final int bufferCapacity = dirtyTerm.capacity();
final int bufferCapacity = termBufferLength;
final int termOffset = (int)cleanPosition & (bufferCapacity - 1);
final int length = Math.min(bytesForCleaning, bufferCapacity - termOffset);

Expand All @@ -214,7 +216,7 @@ public long joinPosition()
public long producerPosition()
{
final long rawTail = rawTailVolatile(metaDataBuffer);
final int termOffset = termOffset(rawTail, termWindowLength);
final int termOffset = termOffset(rawTail, termBufferLength);

return computePosition(termId(rawTail), termOffset, positionBitsToShift, initialTermId);
}
Expand Down

0 comments on commit b155bf6

Please sign in to comment.