mirror of https://github.com/apache/druid.git
check should be safe to move out of loop
This commit is contained in:
parent
46a5409207
commit
a0c38f574b
|
@ -350,7 +350,7 @@ public abstract class HyperLogLogCollector implements Comparable<HyperLogLogColl
|
|||
byte myOffset = getRegisterOffset();
|
||||
short numNonZero = getNumNonZeroRegisters();
|
||||
|
||||
int offsetDiff = myOffset - otherOffset;
|
||||
final int offsetDiff = myOffset - otherOffset;
|
||||
if (offsetDiff < 0) {
|
||||
throw new ISE("offsetDiff[%d] < 0, shouldn't happen because of swap.", offsetDiff);
|
||||
}
|
||||
|
@ -368,13 +368,11 @@ public abstract class HyperLogLogCollector implements Comparable<HyperLogLogColl
|
|||
offsetDiff,
|
||||
otherBuffer.get()
|
||||
);
|
||||
if (numNonZero == NUM_BUCKETS) {
|
||||
numNonZero = decrementBuckets();
|
||||
setRegisterOffset(++myOffset);
|
||||
setNumNonZeroRegisters(numNonZero);
|
||||
|
||||
offsetDiff = myOffset - otherOffset;
|
||||
}
|
||||
}
|
||||
if (numNonZero == NUM_BUCKETS) {
|
||||
numNonZero = decrementBuckets();
|
||||
setRegisterOffset(++myOffset);
|
||||
setNumNonZeroRegisters(numNonZero);
|
||||
}
|
||||
} else { // dense
|
||||
int position = getPayloadBytePosition();
|
||||
|
@ -384,15 +382,13 @@ public abstract class HyperLogLogCollector implements Comparable<HyperLogLogColl
|
|||
offsetDiff,
|
||||
otherBuffer.get()
|
||||
);
|
||||
if (numNonZero == NUM_BUCKETS) {
|
||||
numNonZero = decrementBuckets();
|
||||
setRegisterOffset(++myOffset);
|
||||
setNumNonZeroRegisters(numNonZero);
|
||||
|
||||
offsetDiff = myOffset - otherOffset;
|
||||
}
|
||||
position++;
|
||||
}
|
||||
if (numNonZero == NUM_BUCKETS) {
|
||||
numNonZero = decrementBuckets();
|
||||
setRegisterOffset(++myOffset);
|
||||
setNumNonZeroRegisters(numNonZero);
|
||||
}
|
||||
}
|
||||
|
||||
// no need to call setRegisterOffset(myOffset) here, since it gets updated every time myOffset is incremented
|
||||
|
|
Loading…
Reference in New Issue