mirror of https://github.com/apache/druid.git
BoundDimFilter: Simplify the various DruidLongPredicates. (#10906)
They all use Long.compare, but they don't need to. Changing to regular comparisons simplifies the code and also removes branches. (Internally, Long.compare has two branches.)
This commit is contained in:
parent
f5bfccc720
commit
b7e9f5bc85
|
@ -615,93 +615,25 @@ public class BoundDimFilter extends AbstractOptimizableDimFilter implements DimF
|
||||||
{
|
{
|
||||||
if (hasLowerLongBound && hasUpperLongBound) {
|
if (hasLowerLongBound && hasUpperLongBound) {
|
||||||
if (upperStrict && lowerStrict) {
|
if (upperStrict && lowerStrict) {
|
||||||
return new DruidLongPredicate()
|
return input -> input > lowerLongBound && input < upperLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
|
||||||
final int upperComparing = Long.compare(upperLongBound, input);
|
|
||||||
return ((lowerComparing > 0)) && (upperComparing > 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else if (lowerStrict) {
|
} else if (lowerStrict) {
|
||||||
return new DruidLongPredicate()
|
return input -> input > lowerLongBound && input <= upperLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
|
||||||
final int upperComparing = Long.compare(upperLongBound, input);
|
|
||||||
return (lowerComparing > 0) && (upperComparing >= 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else if (upperStrict) {
|
} else if (upperStrict) {
|
||||||
return new DruidLongPredicate()
|
return input -> input >= lowerLongBound && input < upperLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
|
||||||
final int upperComparing = Long.compare(upperLongBound, input);
|
|
||||||
return (lowerComparing >= 0) && (upperComparing > 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
return new DruidLongPredicate()
|
return input -> input >= lowerLongBound && input <= upperLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
|
||||||
final int upperComparing = Long.compare(upperLongBound, input);
|
|
||||||
return (lowerComparing >= 0) && (upperComparing >= 0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
} else if (hasUpperLongBound) {
|
} else if (hasUpperLongBound) {
|
||||||
if (upperStrict) {
|
if (upperStrict) {
|
||||||
return new DruidLongPredicate()
|
return input -> input < upperLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int upperComparing = Long.compare(upperLongBound, input);
|
|
||||||
return upperComparing > 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
return new DruidLongPredicate()
|
return input -> input <= upperLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int upperComparing = Long.compare(upperLongBound, input);
|
|
||||||
return upperComparing >= 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
} else if (hasLowerLongBound) {
|
} else if (hasLowerLongBound) {
|
||||||
if (lowerStrict) {
|
if (lowerStrict) {
|
||||||
return new DruidLongPredicate()
|
return input -> input > lowerLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
|
||||||
return lowerComparing > 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
return new DruidLongPredicate()
|
return input -> input >= lowerLongBound;
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean applyLong(long input)
|
|
||||||
{
|
|
||||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
|
||||||
return lowerComparing >= 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return DruidLongPredicate.ALWAYS_TRUE;
|
return DruidLongPredicate.ALWAYS_TRUE;
|
||||||
|
|
Loading…
Reference in New Issue