private long NewPosition(int resultingOffset) { if (resultingOffset > 0) { _termOffset = resultingOffset; return(_termBeginPosition + resultingOffset); } else { if ((_termBeginPosition + _termBufferLength) >= MaxPossiblePosition()) { return(MAX_POSITION_EXCEEDED); } int nextIndex = LogBufferDescriptor.NextPartitionIndex(_activePartitionIndex); int nextTermId = _termId + 1; _activePartitionIndex = nextIndex; _termOffset = 0; _termId = nextTermId; _termBeginPosition = LogBufferDescriptor.ComputeTermBeginPosition(nextTermId, _positionBitsToShift, InitialTermId); LogBufferDescriptor.InitialiseTailWithTermId(_logMetaDataBuffer, nextIndex, nextTermId); LogBufferDescriptor.ActivePartitionIndexOrdered(_logMetaDataBuffer, nextIndex); return(ADMIN_ACTION); } }
private long NewPosition(int index, int currentTail, long position, long result) { var newPosition = ADMIN_ACTION; var termOffset = TermAppender.TermOffset(result); if (termOffset > 0) { newPosition = (position - currentTail) + termOffset; } else if (termOffset == TermAppender.TRIPPED) { var nextIndex = LogBufferDescriptor.NextPartitionIndex(index); _termAppenders[nextIndex].TailTermId(TermAppender.TermId(result) + 1); LogBufferDescriptor.ActivePartitionIndexOrdered(_logMetaDataBuffer, nextIndex); } return(newPosition); }
private long NewPosition(int index, int currentTail, long position, long result) { var newPosition = ADMIN_ACTION; var termOffset = LogBufferDescriptor.TermOffset(result); if (termOffset > 0) { newPosition = (position - currentTail) + termOffset; } else if ((position + currentTail) > _maxPossiblePosition) { newPosition = MAX_POSITION_EXCEEDED; } else if (termOffset == TermAppender.TRIPPED) { var nextIndex = LogBufferDescriptor.NextPartitionIndex(index); LogBufferDescriptor.InitialiseTailWithTermId(_logMetaDataBuffer, nextIndex, LogBufferDescriptor.TermId(result) + 1); LogBufferDescriptor.ActivePartitionIndexOrdered(_logMetaDataBuffer, nextIndex); } return(newPosition); }
private long NewPosition(int resultingOffset) { if (resultingOffset > 0) { _termOffset = resultingOffset; return(_termBeginPosition + resultingOffset); } else { int nextIndex = LogBufferDescriptor.NextPartitionIndex(_activePartitionIndex); int nextTermId = _termId + 1; _activePartitionIndex = nextIndex; _termOffset = 0; _termId = nextTermId; _termBeginPosition = LogBufferDescriptor.ComputeTermBeginPosition(nextTermId, _positionBitsToShift, InitialTermId); _termAppenders[nextIndex].TailTermId(nextTermId); LogBufferDescriptor.ActivePartitionIndexOrdered(_logMetaDataBuffer, nextIndex); return(ADMIN_ACTION); } }