Repository navigation
Theta: validate the preamble of empty compact sketches as Java does #543
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
Open
leerho
wants to merge
1
commit into
master
Choose a base branch
from
theta-empty-mask
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,31 @@ class compact_theta_sketch_parser { | |
| static void check_v4_entry_bits(uint8_t entry_bits); | ||
| static void check_v4_num_entries_bytes(uint8_t num_entries_bytes); | ||
|
|
||
| /** | ||
| * Checks the first 8 bytes of a serial version 3 compact sketch that has the empty flag set. | ||
| * Accepts the current 8-byte form (preamble longs 1), and the legacy 24-byte form | ||
| * (preamble longs 3) written by Java before 1.0.0 for sketches with p < 1. | ||
| * The legacy form must also carry the expected seed hash. | ||
| * The caller must check that a legacy image is 24 bytes long and has no entries. | ||
| * @param pre0 the first 8 bytes of the image, little-endian | ||
| * @param expected_seed_hash the seed hash computed from the expected seed | ||
| * @return the number of preamble longs: 1 or 3 | ||
| * @throw std::invalid_argument if the image is not a valid empty compact sketch | ||
| */ | ||
| static uint8_t check_empty_v3(uint64_t pre0, uint16_t expected_seed_hash); | ||
|
|
||
| // The MASK selects which bits of the first 8 bytes of an empty image are examined. | ||
| // The TEST gives the required values of the examined bits; it must lie within the MASK. | ||
| // Examined: preamble longs, serial version 3, sketch type 3, bytes 3 and 4 = 0 (not used by compact); | ||
| // flags read-only, empty, compact set; single-item and reserved bits 0, 6, 7 clear. | ||
| // The ordered flag is ignored: C++ before 3.3.0 and Java before 1.0.0 wrote empty images without it. | ||
| // The reserved flag bits must be zero for serial version 3. Any future use of them requires a new one. | ||
| // The seed hash is ignored in the 8-byte form: it may be 0 or the seed hash, depending on the writer. | ||
| // These must stay the same as in Java EmptyCompactSketch. | ||
| static const uint64_t EMPTY_SKETCH_MASK = 0x0000EFFFFFFFFFFFULL; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are there reasons not to be private? |
||
| static const uint64_t EMPTY_SKETCH_TEST = 0x00000E0000030301ULL; | ||
| static const uint64_t EMPTY_SKETCH_TEST_LEGACY = 0x00000E0000030303ULL; | ||
|
|
||
| private: | ||
| // offsets are in sizeof(type) | ||
| static const size_t COMPACT_SKETCH_PRE_LONGS_BYTE = 0; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For the code consistency, how to change signature to "void"?