Skip to content

Commit

Permalink
Merge pull request #26 from filipecosta90/fix.codec
Browse files Browse the repository at this point in the history
[fix] conversion_ratio_bits type setted to c_double
  • Loading branch information
ahothan authored Nov 3, 2019
2 parents d566355 + 018f04f commit 8101bf1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion hdrh/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from ctypes import c_ushort
from ctypes import c_uint
from ctypes import c_ulonglong
from ctypes import c_double

import zlib

Expand Down Expand Up @@ -98,7 +99,7 @@ class PayloadHeader(BigEndianStructure):
("significant_figures", c_uint),
("lowest_trackable_value", c_ulonglong),
("highest_trackable_value", c_ulonglong),
("conversion_ratio_bits", c_ulonglong)]
("conversion_ratio_bits", c_double)]


payload_header_size = ctypes.sizeof(PayloadHeader)
Expand Down
3 changes: 3 additions & 0 deletions hdrh/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,9 @@ def decode(encoded_histogram, b64_wrap=True):
def get_word_size(self):
return self.word_size

def get_int_to_double_conversion_ratio(self):
return self.int_to_double_conversion_ratio

def output_percentile_distribution(self,
out_file,
output_value_unit_scaling_ratio,
Expand Down
14 changes: 8 additions & 6 deletions test/test_hdrhistogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,17 @@ def check_hist_encode(word_size,
ENCODE_ARG_LIST = (
# word size digits expected_compressed_length, fill_start%, fill_count%
# best case when all counters are zero
(8, 3, 48, 0, 0), # V1=52 385 = size when compressing entire counts array
(8, 2, 48, 0, 0), # 126
(8, 3, 52, 0, 0), # V1=52 385 = size when compressing entire counts array
(8, 2, 52, 0, 0), # 126
# typical case when all counters are aggregated in a small contiguous area
(8, 3, 15560, 30, 20), # V1=16452
(8, 2, 1688, 30, 20), # V1=2096
(8, 3, 15564, 30, 20), # V1=16452
(8, 2, 1692, 30, 20), # V1=2096
# worst case when all counters are different
(8, 3, 76892, 0, 100), # V1=80680
(8, 2, 9340, 0, 100), # V1=10744
(8, 2, 9344, 0, 100), # V1=10744
# worst case 32-bit and 16-bit counters
(2, 3, 76892, 0, 100), # V1=68936
(2, 2, 9340, 0, 100), # V1=9144
(2, 2, 9344, 0, 100), # V1=9144
)

@pytest.mark.codec
Expand Down Expand Up @@ -618,6 +618,8 @@ def test_jHiccup_v2_log():
accumulated_histogram.add(decoded_histogram)
# These logs use 8 byte counters
assert decoded_histogram.get_word_size() == 8
# These logs use the default 1.0 conversion ratio
assert decoded_histogram.get_int_to_double_conversion_ratio() == 1.0
for statement in target_numbers:
assert eval(statement) == target_numbers[statement]

Expand Down

0 comments on commit 8101bf1

Please sign in to comment.