-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added get_serialized_size_bytes() #428
Conversation
Pull Request Test Coverage Report for Build 8399001848Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple very minor comments, not blockers
tdigest/include/tdigest_impl.hpp
Outdated
void tdigest<T, A>::serialize(std::ostream& os) const { | ||
const_cast<tdigest*>(this)->merge_buffered(); // side effect | ||
void tdigest<T, A>::serialize(std::ostream& os, bool with_buffer) const { | ||
if (!with_buffer) const_cast<tdigest*>(this)->compress(); // side effect | ||
write(os, is_empty() || is_single_value() ? PREAMBLE_LONGS_EMPTY_OR_SINGLE : PREAMBLE_LONGS_MULTIPLE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can call the newly added get_preamble_longs()
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right
if (!with_buffer) const_cast<tdigest*>(this)->compress(); // side effect | ||
vector_bytes bytes(get_serialized_size_bytes(with_buffer), 0, buffer_.get_allocator()); | ||
uint8_t* ptr = bytes.data() + header_size_bytes; | ||
*ptr++ = get_preamble_longs(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the more aggressive warning flags complains about *ptr++ as possibly incrementing a null ptr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this would happen.
I thought about encapsulating this keeping track of the offset. or, perhaps, using something like std::strstream
for (size_t i = 0; i < n; ++i) td.update(i); | ||
// std::cout << td.to_string(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker but some extra comments left in it seems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are tests, and I uncomment this sometimes to check. not a big deal. we can kill this later
No description provided.