本文整理汇总了C#中ByteBuffer.PutLong方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.PutLong方法的具体用法?C# ByteBuffer.PutLong怎么用?C# ByteBuffer.PutLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.PutLong方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Encode
/// <summary>
/// Encodes the supplied <see cref="IRecordedData"/> into the supplied <see cref="ByteBuffer"/>.
/// </summary>
/// <param name="data">The data to encode.</param>
/// <param name="buffer">The target <see cref="ByteBuffer"/> to write to.</param>
/// <returns>The number of bytes written.</returns>
public int Encode(IRecordedData data, ByteBuffer buffer)
{
int initialPosition = buffer.Position;
buffer.PutInt(data.Cookie);
int payloadLengthPosition = buffer.Position;
buffer.PutInt(0); // Placeholder for payload length in bytes.
buffer.PutInt(data.NormalizingIndexOffset);
buffer.PutInt(data.NumberOfSignificantValueDigits);
buffer.PutLong(data.LowestDiscernibleValue);
buffer.PutLong(data.HighestTrackableValue);
buffer.PutDouble(data.IntegerToDoubleValueConversionRatio);
var payloadLength = FillBufferFromCountsArray(buffer, data);
buffer.PutInt(payloadLengthPosition, payloadLength);
var bytesWritten = buffer.Position - initialPosition;
return bytesWritten;
}
示例2: WriteTo
public override void WriteTo(ByteBuffer buffer)
{
buffer.PutShort(this.VersionId);
buffer.PutInt(this.CorrelationId);
ApiUtils.WriteShortString(buffer, this.ClientId);
buffer.PutInt(this.ReplicaId);
buffer.PutInt(this.requestInfoGroupedByTopic.Value.Count);
foreach (var topicAndPartitionInfos in this.requestInfoGroupedByTopic.Value)
{
var topic = topicAndPartitionInfos.Key;
var partitionInfos = topicAndPartitionInfos.Value;
ApiUtils.WriteShortString(buffer, topic);
buffer.PutInt(partitionInfos.Count); // partition count
foreach (var pi in partitionInfos)
{
var partition = pi.Key.Partiton;
var partitionInfo = pi.Value;
buffer.PutInt(partition);
buffer.PutLong(partitionInfo.Time);
buffer.PutInt(partitionInfo.MaxNumOffsets);
}
}
}
示例3: WriteTo
public override void WriteTo(ByteBuffer buffer)
{
buffer.PutShort(this.VersionId);
buffer.PutInt(this.CorrelationId);
ApiUtils.WriteShortString(buffer, this.ClientId);
buffer.PutInt(this.ReplicaId);
buffer.PutInt(this.MaxWait);
buffer.PutInt(this.MinBytes);
buffer.PutInt(this.requestInfoGroupedByTopic.Value.Count); // topic count
foreach (var kvp in this.requestInfoGroupedByTopic.Value)
{
var topic = kvp.Key;
var partitionFetchInfos = kvp.Value;
ApiUtils.WriteShortString(buffer, topic);
buffer.PutInt(partitionFetchInfos.Count); // partition count
foreach (var pfi in partitionFetchInfos)
{
buffer.PutInt(pfi.Key.Partiton);
buffer.PutLong(pfi.Value.Offset);
buffer.PutInt(pfi.Value.FetchSize);
}
}
}
示例4: WriteTo
public override void WriteTo(ByteBuffer buffer)
{
var groupedStatus = this.statusGroupedByTopic.Value;
buffer.PutInt(this.CorrelationId);
buffer.PutInt(groupedStatus.Count); // topic count
foreach (var topicStatus in groupedStatus)
{
var topic = topicStatus.Key;
var errorsAndOffsets = topicStatus.Value;
ApiUtils.WriteShortString(buffer, topic);
buffer.PutInt(errorsAndOffsets.Count); // partition count
foreach (var kvp in errorsAndOffsets)
{
buffer.PutInt(kvp.Key.Partiton);
buffer.PutShort(kvp.Value.Error);
buffer.PutLong(kvp.Value.Offset);
}
}
}
示例5: WriteTo
public override void WriteTo(ByteBuffer buffer)
{
buffer.PutInt(CorrelationId);
buffer.PutInt(offsetsGroupedByTopic.Value.Count); // topic count
foreach (var kvp in offsetsGroupedByTopic.Value)
{
var topic = kvp.Key;
var errorAndOffsetsMap = kvp.Value;
ApiUtils.WriteShortString(buffer, topic);
buffer.PutInt(errorAndOffsetsMap.Count);
foreach (var topicPartitionAndErrorOffset in errorAndOffsetsMap)
{
buffer.PutInt(topicPartitionAndErrorOffset.Key.Partiton);
buffer.PutShort(topicPartitionAndErrorOffset.Value.Error);
buffer.PutInt(topicPartitionAndErrorOffset.Value.Offsets.Count);
foreach (var offset in topicPartitionAndErrorOffset.Value.Offsets)
{
buffer.PutLong(offset);
}
}
}
}