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


C# ByteBuffer.GetLong方法代码示例

本文整理汇总了C#中ByteBuffer.GetLong方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.GetLong方法的具体用法?C# ByteBuffer.GetLong怎么用?C# ByteBuffer.GetLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.GetLong方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: ReadFrom

        public static FetchResponsePartitionData ReadFrom(ByteBuffer buffer)
        {
            var error = buffer.GetShort();
            var hw = buffer.GetLong();
            var messageSetSize = buffer.GetInt();
            var messageSetBuffer = buffer.Slice();
            messageSetBuffer.Limit(messageSetSize);
            buffer.Position = buffer.Position + messageSetSize;

            return new FetchResponsePartitionData(error, hw, new ByteBufferMessageSet(messageSetBuffer));
        }
开发者ID:Cnova,项目名称:kafka-net,代码行数:11,代码来源:FetchResponse.cs

示例3: 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

示例4: 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

示例5: 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

示例6: ReadLongInRange

        /// <summary>
        ///  Read an long out of the ByteBuffer from the current position and check that it falls within the given
        /// range. If not, throw KafkaException.
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="name"></param>
        /// <param name="range"></param>
        /// <returns></returns>
        public static long ReadLongInRange(ByteBuffer buffer, string name, Tuple<long, long> range)
        {
            var value = buffer.GetLong();
            if (value < range.Item1 || value > range.Item2)
            {
                throw new KafkaException(string.Format("{0} has value {1} which is not in the range {2}", name, value, range));
            }

            return value;
        }
开发者ID:ajperrins,项目名称:kafka-net,代码行数:18,代码来源:ApiUtils.cs

示例7: 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

示例8: ReadWord

 /// <summary>
 /// Reads a single value from the <paramref name="buffer"/>. 
 /// </summary>
 /// <param name="buffer">The <see cref="ByteBuffer"/> to read the single value from</param>
 /// <returns>The value as a <c>long</c>.</returns>
 /// <remarks>
 /// Implementations may have different word sizes i.e. short(2), int(4) or long(8).
 /// </remarks>
 protected override long ReadWord(ByteBuffer buffer)
 {
     return buffer.GetLong();
 }
开发者ID:qooroo,项目名称:HdrHistogram.NET,代码行数:12,代码来源:LongHistogram.cs


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