当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.GetInt方法代码示例

本文整理汇总了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);
 }
开发者ID:ajperrins,项目名称:kafka-net,代码行数:7,代码来源:Broker.cs

示例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);
 }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:11,代码来源:TopicMetadataResponse.cs

示例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));
 }
开发者ID:Cnova,项目名称:kafka-net,代码行数:13,代码来源:FetchResponse.cs

示例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;
            }
        }
开发者ID:gbarresi,项目名称:buffer_bci,代码行数:60,代码来源:DataType.cs

示例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;
 }
开发者ID:HdrHistogram,项目名称:HdrHistogram.NET,代码行数:23,代码来源:HistogramEncoding.cs

示例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);
        }
开发者ID:Cnova,项目名称:kafka-net,代码行数:20,代码来源:TopicMetadata.cs

示例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));
 }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:21,代码来源:OffsetResponse.cs

示例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));
        }
开发者ID:Cnova,项目名称:kafka-net,代码行数:28,代码来源:ProducerRequest.cs

示例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);
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:22,代码来源:ProducerResponse.cs

示例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);
        }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:14,代码来源:TopicMetadataRequest.cs

示例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));
 }
开发者ID:ajperrins,项目名称:kafka-net,代码行数:24,代码来源:FetchRequest.cs

示例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);
 }
开发者ID:CMTelecom,项目名称:kafka-net,代码行数:24,代码来源:OffsetRequest.cs

示例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);
     }
 }
开发者ID:ordanielcmessias,项目名称:LGame,代码行数:13,代码来源:GL.cs

示例14: GetRootAsTestSimpleTableWithEnum

 public static TestSimpleTableWithEnum GetRootAsTestSimpleTableWithEnum(ByteBuffer _bb, TestSimpleTableWithEnum obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
开发者ID:zzragida,项目名称:flatbuffers,代码行数:1,代码来源:TestSimpleTableWithEnum.cs

示例15: DecodeChunkSize

		static ChunkSize DecodeChunkSize(ByteBuffer stream) 
		{
			return new ChunkSize(stream.GetInt());
		}
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:4,代码来源:RtmpProtocolDecoder.cs


注:本文中的ByteBuffer.GetInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。