本文整理汇总了C#中ByteBuffer.GetInt方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.GetInt方法的具体用法?C# ByteBuffer.GetInt怎么用?C# ByteBuffer.GetInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.GetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFrom
internal static Broker ReadFrom(ByteBuffer buffer)
{
var id = buffer.GetInt();
var host = ApiUtils.ReadShortString(buffer);
var port = buffer.GetInt();
return new Broker(id, host, port);
}
示例2: ReadFrom
public static TopicMetadataResponse ReadFrom(ByteBuffer buffer)
{
var correlationId = buffer.GetInt();
var brokerCount = buffer.GetInt();
var brokers = Enumerable.Range(0, brokerCount).Select(_ => Broker.ReadFrom(buffer)).ToList();
var brokerMap = brokers.ToDictionary(b => b.Id);
var topicCount = buffer.GetInt();
var topicsMetadata =
Enumerable.Range(0, topicCount).Select(_ => TopicMetadata.ReadFrom(buffer, brokerMap)).ToList();
return new TopicMetadataResponse(topicsMetadata, correlationId);
}
示例3: ReadFrom
public static TopicData ReadFrom(ByteBuffer buffer)
{
var topic = ApiUtils.ReadShortString(buffer);
var partitionCount = buffer.GetInt();
var topicPartitionDataPairs = Enumerable.Range(1, partitionCount).Select(
_ =>
{
var partitonId = buffer.GetInt();
var partitionData = FetchResponsePartitionData.ReadFrom(buffer);
return Tuple.Create(partitonId, partitionData);
}).ToList();
return new TopicData(topic, topicPartitionDataPairs.ToDictionary(k => k.Item1, v => v.Item2));
}
示例4: GetObject
public static object GetObject(int type, int numel, ByteBuffer buf)
{
switch (type) {
case CHAR:
byte[] strBytes = new byte[numel];
buf.Get(ref strBytes);
System.Text.Encoding encoding = buf.Encoding;
string val = encoding.GetString(strBytes, 0, strBytes.Length);
return val;
case INT8:
goto case UINT8;
case UINT8:
byte[] int8array = new byte[numel];
buf.Get(ref int8array);
return (object)int8array;
case INT16:
goto case UINT16;
case UINT16:
short[] int16array = new short[numel];
// The following would be faster, but DOES NOT
// increment the position of the original ByteBuffer!!!
// buf.asShortBuffer().get(int16array);
for (int i = 0; i < numel; i++)
int16array[i] = buf.GetShort();
return (object)int16array;
case INT32:
goto case UINT32;
case UINT32:
int[] int32array = new int[numel];
for (int i = 0; i < numel; i++)
int32array[i] = buf.GetInt();
return (object)int32array;
case INT64:
goto case UINT64;
case UINT64:
long[] int64array = new long[numel];
for (int i = 0; i < numel; i++)
int64array[i] = buf.GetLong();
return (object)int64array;
case FLOAT32:
float[] float32array = new float[numel];
for (int i = 0; i < numel; i++)
float32array[i] = buf.GetFloat();
return (object)float32array;
case FLOAT64:
double[] float64array = new double[numel];
for (int i = 0; i < numel; i++)
float64array[i] = buf.GetDouble();
return (object)float64array;
default:
return null;
}
}
示例5: DecodeFromCompressedByteBuffer
/// <summary>
/// Construct a new histogram by decoding it from a compressed form in a ByteBuffer.
/// </summary>
/// <param name="buffer">The buffer to decode from</param>
/// <param name="minBarForHighestTrackableValue">Force highestTrackableValue to be set at least this high</param>
/// <returns>The newly constructed histogram</returns>
public static HistogramBase DecodeFromCompressedByteBuffer(ByteBuffer buffer, long minBarForHighestTrackableValue)
{
var cookie = buffer.GetInt();
var headerSize = GetHeaderSize(cookie);
var lengthOfCompressedContents = buffer.GetInt();
HistogramBase histogram;
//Skip the first two bytes (from the RFC 1950 specification) and move to the deflate specification (RFC 1951)
// http://george.chiramattel.com/blog/2007/09/deflatestream-block-length-does-not-match.html
using (var inputStream = new MemoryStream(buffer.ToArray(), buffer.Position + Rfc1950HeaderLength, lengthOfCompressedContents - Rfc1950HeaderLength))
using (var decompressor = new DeflateStream(inputStream, CompressionMode.Decompress, leaveOpen: true))
{
var headerBuffer = ByteBuffer.Allocate(headerSize);
headerBuffer.ReadFrom(decompressor, headerSize);
histogram = DecodeFromByteBuffer(headerBuffer, minBarForHighestTrackableValue, decompressor);
}
return histogram;
}
示例6: ReadFrom
public static PartitionMetadata ReadFrom(ByteBuffer buffer, Dictionary<int, Broker> brokers)
{
var errorCode = ApiUtils.ReadShortInRange(
buffer, "error code", Tuple.Create<short, short>(-1, short.MaxValue));
var partitionId = ApiUtils.ReadIntInRange(buffer, "partition id", Tuple.Create(0, int.MaxValue)); // partition id
var leaderId = buffer.GetInt();
var leader = brokers[leaderId];
// list of all replicas
var numReplicas = ApiUtils.ReadIntInRange(buffer, "number of all replicas", Tuple.Create(0, int.MaxValue));
var replicaIds = Enumerable.Range(0, numReplicas).Select(_ => buffer.GetInt()).ToList();
var replicas = replicaIds.Select(x => brokers[x]).ToList();
// list of in-sync replicasd
var numIsr = ApiUtils.ReadIntInRange(buffer, "number of in-sync replicas", Tuple.Create(0, int.MaxValue));
var isrIds = Enumerable.Range(0, numIsr).Select(_ => buffer.GetInt()).ToList();
var isr = isrIds.Select(x => brokers[x]).ToList();
return new PartitionMetadata(partitionId, leader, replicas, isr, errorCode);
}
示例7: ReadFrom
public static OffsetResponse ReadFrom(ByteBuffer buffer)
{
var correlationId = buffer.GetInt();
var numTopics = buffer.GetInt();
var pairs = Enumerable.Range(1, numTopics).SelectMany(_ =>
{
var topic = ApiUtils.ReadShortString(buffer);
var numPartitions = buffer.GetInt();
return Enumerable.Range(1, numPartitions).Select(__ =>
{
var partiton = buffer.GetInt();
var error = buffer.GetShort();
var numOffsets = buffer.GetInt();
var offsets = Enumerable.Range(1, numOffsets).Select(o => buffer.GetLong()).ToList();
return new
KeyValuePair<TopicAndPartition, PartitionOffsetsResponse>(
new TopicAndPartition(topic, partiton), new PartitionOffsetsResponse(error, offsets));
});
});
return new OffsetResponse(correlationId, pairs.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
}
示例8: ReadFrom
public static ProducerRequest ReadFrom(ByteBuffer buffer)
{
var versionId = buffer.GetShort();
var correlationId = buffer.GetInt();
var clientId = ApiUtils.ReadShortString(buffer);
var requiredAcks = buffer.GetShort();
var ackTimeoutMs = buffer.GetInt();
// built the topic structure
var topicCount = buffer.GetInt();
var partitionDataPairs = Enumerable.Range(1, topicCount).SelectMany(_ =>
{
// process topic
var topic = ApiUtils.ReadShortString(buffer);
var partitionCount = buffer.GetInt();
return Enumerable.Range(1, partitionCount).Select(__ =>
{
var partition = buffer.GetInt();
var messagesSetSize = buffer.GetInt();
var messageSetBuffer = new byte[messagesSetSize];
buffer.Get(messageSetBuffer, 0, messagesSetSize);
return Tuple.Create(
new TopicAndPartition(topic, partition),
new ByteBufferMessageSet(ByteBuffer.Wrap(messageSetBuffer)));
});
});
return new ProducerRequest(versionId, correlationId, clientId, requiredAcks, ackTimeoutMs, partitionDataPairs.ToDictionary(k => k.Item1, v => v.Item2));
}
示例9: ReadFrom
public static ProducerResponse ReadFrom(ByteBuffer buffer)
{
var correlationId = buffer.GetInt();
var topicCount = buffer.GetInt();
var statusPairs = Enumerable.Range(0, topicCount).SelectMany(
_ =>
{
var topic = ApiUtils.ReadShortString(buffer);
var partitionCount = buffer.GetInt();
return Enumerable.Range(0, partitionCount).Select(
__ =>
{
var partition = buffer.GetInt();
var error = buffer.GetShort();
var offset = buffer.GetLong();
return new KeyValuePair<TopicAndPartition, ProducerResponseStatus>(
new TopicAndPartition(topic, partition), new ProducerResponseStatus(error, offset));
});
});
return new ProducerResponse(statusPairs.ToDictionary(x => x.Key, x => x.Value), correlationId);
}
示例10: ReadFrom
public static TopicMetadataRequest ReadFrom(ByteBuffer buffer)
{
var versonId = buffer.GetShort();
var correlationID = buffer.GetInt();
var clientId = ApiUtils.ReadShortString(buffer);
var numTopic = ApiUtils.ReadIntInRange(buffer, "number of topics", Tuple.Create(0, int.MaxValue));
var topics = new List<string>(numTopic);
for (var i = 0; i < numTopic; i++)
{
topics.Add(ApiUtils.ReadShortString(buffer));
}
return new TopicMetadataRequest(versonId, correlationID, clientId, topics);
}
示例11: ReadFrom
public static FetchRequest ReadFrom(ByteBuffer buffer)
{
var versionId = buffer.GetShort();
var correlationId = buffer.GetInt();
var clientId = ApiUtils.ReadShortString(buffer);
var replicaId = buffer.GetInt();
var maxWait = buffer.GetInt();
var minBytes = buffer.GetInt();
var topicCount = buffer.GetInt();
var pairs = Enumerable.Range(1, topicCount).SelectMany(_ =>
{
var topic = ApiUtils.ReadShortString(buffer);
var partitionCount = buffer.GetInt();
return Enumerable.Range(1, partitionCount).Select(__ =>
{
var partitionId = buffer.GetInt();
var offset = buffer.GetLong();
var fetchSize = buffer.GetInt();
return Tuple.Create(
new TopicAndPartition(topic, partitionId), new PartitionFetchInfo(offset, fetchSize));
});
});
return new FetchRequest(versionId, correlationId, clientId, replicaId, maxWait, minBytes, pairs.ToDictionary(x => x.Item1, x => x.Item2));
}
示例12: ReadFrom
public static OffsetRequest ReadFrom(ByteBuffer buffer)
{
var versionId = buffer.GetShort();
var correlationId = buffer.GetInt();
var clientId = ApiUtils.ReadShortString(buffer);
var replicaId = buffer.GetInt();
var topicCount = buffer.GetInt();
var pairs = Enumerable.Range(1, topicCount).SelectMany(
_ =>
{
var topic = ApiUtils.ReadShortString(buffer);
var partitionCount = buffer.GetInt();
return Enumerable.Range(1, partitionCount).Select(__ =>
{
var partitionId = buffer.GetInt();
var time = buffer.GetLong();
var maxNumOffsets = buffer.GetInt();
return Tuple.Create(
new TopicAndPartition(topic, partitionId),
new PartitionOffsetRequestInfo(time, maxNumOffsets));
});
});
return new OffsetRequest(pairs.ToDictionary(x => x.Item1, x => x.Item2), versionId: versionId, clientId: clientId, correlationId:correlationId, replicaId:replicaId);
}
示例13: GLTexImage2D
public void GLTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer pixels)
{
if ((width != 0) && (height != 0))
{
this.sTextures[this.sTextureId] = new Texture2D(device, width, height);
uint[] data = new uint[width * height];
for (int i = 0; i < data.Length; i++)
{
data[i] = (uint)pixels.GetInt();
}
this.sTextures[this.sTextureId].SetData<uint>(data);
}
}
示例14: GetRootAsTestSimpleTableWithEnum
public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
示例15: DecodeChunkSize
static ChunkSize DecodeChunkSize(ByteBuffer stream)
{
return new ChunkSize(stream.GetInt());
}