leerho commented on a change in pull request #324:
URL:
https://github.com/apache/incubator-datasketches-java/pull/324#discussion_r455403972
##########
File path: src/main/java/org/apache/datasketches/theta/HeapAlphaSketch.java
##########
@@ -128,20 +128,19 @@ static HeapAlphaSketch heapifyInstance(final Memory
srcMem, final long seed) {
checkMemIntegrity(srcMem, seed, preambleLongs, lgNomLongs, lgArrLongs);
final float p = extractP(srcMem); //bytes 12-15
- final int lgRF = extractLgResizeFactor(srcMem); //byte 0
- final ResizeFactor myRF = ResizeFactor.getRF(lgRF);
+ final int memlgRF = extractLgResizeFactor(srcMem); //byte 0
+ final ResizeFactor memRF = ResizeFactor.getRF(memlgRF);
final double nomLongs = (1L << lgNomLongs);
final double alpha = nomLongs / (nomLongs + 1.0);
final long split1 = (long) (((p * (alpha + 1.0)) / 2.0) *
LONG_MAX_VALUE_AS_DOUBLE);
- if ((myRF == ResizeFactor.X1)
- && (lgArrLongs != startingSubMultiple(lgNomLongs + 1, myRF,
MIN_LG_ARR_LONGS))) {
- throw new SketchesArgumentException("Possible corruption: ResizeFactor
X1, but provided "
- + "array too small for sketch size");
+ if (isResizeFactorIncorrect(srcMem, lgNomLongs, lgArrLongs)) {
+ throw new SketchesArgumentException("Possible corruption: ResizeFactor "
+ + "inconsistent with lgNomLongs and lgArrLongs.");
Review comment:
Yes. Look more closely at the object being modified in the case where
X2 is set. It is a WritableMemory. In the case where I have to throw, it is
just Memory, which is immutable. Big difference.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]