Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hdrh/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class HdrHistogramSettingsException(Exception):
# External encoding header
class ExternalHeader(BigEndianStructure):
_pack_ = 1
_layout_ = "ms"
_fields_ = [
("cookie", c_uint),
("length", c_uint)]
Expand All @@ -89,6 +90,7 @@ class ExternalHeader(BigEndianStructure):
# Header for the zlib compressed part
class PayloadHeader(BigEndianStructure):
_pack_ = 1
_layout_ = "ms"
_fields_ = [
("cookie", c_uint),
("payload_len", c_uint),
Expand Down
7 changes: 7 additions & 0 deletions test/test_hdrhistogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@
from hdrh.histogram import HdrHistogram
from hdrh.log import HistogramLogWriter
from hdrh.log import HistogramLogReader
from hdrh.codec import ExternalHeader
from hdrh.codec import HdrPayload
from hdrh.codec import HdrCookieException
from hdrh.codec import PayloadHeader
from hdrh.dump import dump


Expand All @@ -64,6 +66,11 @@ def python_bitness():
INTERVAL = 10000
BITNESS = python_bitness()

@pytest.mark.codec
def test_codec_headers_use_explicit_packed_layout():
assert ExternalHeader._layout_ == "ms"
assert PayloadHeader._layout_ == "ms"

@pytest.mark.basic
def test_basic():
histogram = HdrHistogram(LOWEST, HIGHEST, SIGNIFICANT)
Expand Down