Skip to content

Commit 8101bf1

Browse files
authored
Merge pull request #26 from filipecosta90/fix.codec
[fix] conversion_ratio_bits type setted to c_double
2 parents d566355 + 018f04f commit 8101bf1

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

hdrh/codec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from ctypes import c_ushort
3636
from ctypes import c_uint
3737
from ctypes import c_ulonglong
38+
from ctypes import c_double
3839

3940
import zlib
4041

@@ -98,7 +99,7 @@ class PayloadHeader(BigEndianStructure):
9899
("significant_figures", c_uint),
99100
("lowest_trackable_value", c_ulonglong),
100101
("highest_trackable_value", c_ulonglong),
101-
("conversion_ratio_bits", c_ulonglong)]
102+
("conversion_ratio_bits", c_double)]
102103

103104

104105
payload_header_size = ctypes.sizeof(PayloadHeader)

hdrh/histogram.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ def decode(encoded_histogram, b64_wrap=True):
574574
def get_word_size(self):
575575
return self.word_size
576576

577+
def get_int_to_double_conversion_ratio(self):
578+
return self.int_to_double_conversion_ratio
579+
577580
def output_percentile_distribution(self,
578581
out_file,
579582
output_value_unit_scaling_ratio,

test/test_hdrhistogram.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -425,17 +425,17 @@ def check_hist_encode(word_size,
425425
ENCODE_ARG_LIST = (
426426
# word size digits expected_compressed_length, fill_start%, fill_count%
427427
# best case when all counters are zero
428-
(8, 3, 48, 0, 0), # V1=52 385 = size when compressing entire counts array
429-
(8, 2, 48, 0, 0), # 126
428+
(8, 3, 52, 0, 0), # V1=52 385 = size when compressing entire counts array
429+
(8, 2, 52, 0, 0), # 126
430430
# typical case when all counters are aggregated in a small contiguous area
431-
(8, 3, 15560, 30, 20), # V1=16452
432-
(8, 2, 1688, 30, 20), # V1=2096
431+
(8, 3, 15564, 30, 20), # V1=16452
432+
(8, 2, 1692, 30, 20), # V1=2096
433433
# worst case when all counters are different
434434
(8, 3, 76892, 0, 100), # V1=80680
435-
(8, 2, 9340, 0, 100), # V1=10744
435+
(8, 2, 9344, 0, 100), # V1=10744
436436
# worst case 32-bit and 16-bit counters
437437
(2, 3, 76892, 0, 100), # V1=68936
438-
(2, 2, 9340, 0, 100), # V1=9144
438+
(2, 2, 9344, 0, 100), # V1=9144
439439
)
440440

441441
@pytest.mark.codec
@@ -618,6 +618,8 @@ def test_jHiccup_v2_log():
618618
accumulated_histogram.add(decoded_histogram)
619619
# These logs use 8 byte counters
620620
assert decoded_histogram.get_word_size() == 8
621+
# These logs use the default 1.0 conversion ratio
622+
assert decoded_histogram.get_int_to_double_conversion_ratio() == 1.0
621623
for statement in target_numbers:
622624
assert eval(statement) == target_numbers[statement]
623625

0 commit comments

Comments
 (0)