Skip to content
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

Merged
merged 5 commits into from
Mar 23, 2024
Merged

added get_serialized_size_bytes() #428

merged 5 commits into from
Mar 23, 2024

Conversation

AlexanderSaydakov
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Mar 12, 2024

Pull Request Test Coverage Report for Build 8399001848

Details

  • 83 of 83 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 98.962%

Totals Coverage Status
Change from base Build 8208655264: 0.001%
Covered Lines: 16393
Relevant Lines: 16565

💛 - Coveralls

Copy link
Contributor

@jmalkin jmalkin left a 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

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);
Copy link
Contributor

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

Copy link
Contributor Author

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();
Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

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

@AlexanderSaydakov AlexanderSaydakov merged commit 145ab0d into master Mar 23, 2024
8 checks passed
@AlexanderSaydakov AlexanderSaydakov deleted the tdigest branch March 23, 2024 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants