Exemplo n.º 1
0
        private static HistogramBase CompressedEncodeDecode(HistogramBase source)
        {
            var targetBuffer = ByteBuffer.Allocate(source.GetNeededByteBufferCapacity());

            source.EncodeIntoCompressedByteBuffer(targetBuffer);
            targetBuffer.Position = 0;
            return(HistogramEncoding.DecodeFromCompressedByteBuffer(targetBuffer, 0));
        }
        private void WriteHistogram(HistogramBase histogram)
        {
            var targetBuffer     = ByteBuffer.Allocate(histogram.GetNeededByteBufferCapacity());
            var compressedLength = histogram.EncodeIntoCompressedByteBuffer(targetBuffer);

            byte[] compressedArray = new byte[compressedLength];
            targetBuffer.BlockGet(compressedArray, 0, 0, compressedLength);

            var startTimeStampSec = histogram.StartTimeStamp / 1000.0;
            var endTimeStampSec   = histogram.EndTimeStamp / 1000.0;
            var intervalLength    = endTimeStampSec - startTimeStampSec;
            var maxValueUnitRatio = 1000000.0;
            var intervalMax       = histogram.GetMaxValue() / maxValueUnitRatio;

            var binary  = Convert.ToBase64String(compressedArray);
            var payload = $"{startTimeStampSec:F3},{intervalLength:F3},{intervalMax:F3},{binary}";

            _log.WriteLine(payload);
            _log.Flush();
        }
        private void WriteHistogram(HistogramBase histogram)
        {
            var targetBuffer = ByteBuffer.Allocate(histogram.GetNeededByteBufferCapacity());
            var compressedLength = histogram.EncodeIntoCompressedByteBuffer(targetBuffer);
            byte[] compressedArray = new byte[compressedLength];
            targetBuffer.BlockGet(compressedArray, 0, 0, compressedLength);

            var startTimeStampSec = histogram.StartTimeStamp / 1000.0;
            var endTimeStampSec = histogram.EndTimeStamp / 1000.0;
            var intervalLength = endTimeStampSec - startTimeStampSec;
            var maxValueUnitRatio = 1000000.0;
            var intervalMax = histogram.GetMaxValue() / maxValueUnitRatio;

            var binary = Convert.ToBase64String(compressedArray);
            var payload = $"{startTimeStampSec:F3},{intervalLength:F3},{intervalMax:F3},{binary}";
            _log.WriteLine(payload);
            _log.Flush();
        }