leerho commented on code in PR #789:
URL: https://github.com/apache/datasketches-java/pull/789#discussion_r4445811670
##########
src/main/java/org/apache/datasketches/tuple/arrayofdoubles/HeapArrayOfDoublesCompactSketch.java:
##########
@@ -126,8 +126,9 @@ final class HeapArrayOfDoublesCompactSketch extends
ArrayOfDoublesCompactSketch
throw new SketchesArgumentException(
"Serial version mismatch. Expected: " + serialVersionUID + ",
actual: " + version);
}
- Util.checkSeedHashes(seedHash_, Util.computeSeedHash(seed));
isEmpty_ = (seg.get(JAVA_BYTE, FLAGS_BYTE) & (1 <<
Flags.IS_EMPTY.ordinal())) != 0;
+ // the seed hash of an empty image is ignored; historical images may have
filled it in
+ if (!isEmpty_) { Util.checkSeedHashes(seedHash_,
Util.computeSeedHash(seed)); }
Review Comment:
Good catch, thanks. Done in both the heap and direct readers (f63e080bd):
the seed hash is now checked when the image is non-empty or has entries, so a
corrupt image that claims to be empty but carries entries can't skip the check.
Added a test with such a corrupt image. This is also a little stricter than
C++, which checks when has-entries is set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]