in src/main/java/org/apache/datasketches/quantiles/HeapUpdateDoublesSketch.java [404:431]
static void checkPreLongsFlagsSerVer(final int flags, final int serVer, final int preLongs) {
final boolean empty = (flags & EMPTY_FLAG_MASK) > 0;
final boolean compact = (flags & COMPACT_FLAG_MASK) > 0;
final int sw = (compact ? 1 : 0) + (2 * (empty ? 1 : 0)) + (4 * (serVer & 0xF))
+ (32 * (preLongs & 0x3F));
boolean valid = true;
switch (sw) { //These are the valid cases.
case 38 : break; //!compact, empty, serVer = 1, preLongs = 1; always stored as not compact
case 164 : break; //!compact, !empty, serVer = 1, preLongs = 5; always stored as not compact
case 42 : break; //!compact, empty, serVer = 2, preLongs = 1; always stored as compact
case 72 : break; //!compact, !empty, serVer = 2, preLongs = 2; always stored as compact
case 47 : break; // compact, empty, serVer = 3, preLongs = 1;
case 46 : break; //!compact, empty, serVer = 3, preLongs = 1;
case 79 : break; // compact, empty, serVer = 3, preLongs = 2;
case 78 : break; //!compact, empty, serVer = 3, preLongs = 2;
case 77 : break; // compact, !empty, serVer = 3, preLongs = 2;
case 76 : break; //!compact, !empty, serVer = 3, preLongs = 2;
default : //all other cases are invalid
valid = false;
}
if (!valid) {
throw new SketchesArgumentException("Possible corruption. Inconsistent state: "
+ "PreambleLongs = " + preLongs + ", empty = " + empty + ", SerVer = " + serVer
+ ", Compact = " + compact);
}
}