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 (upperStrict && lowerStrict) {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@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);
|
||||
}
|
||||
};
|
||||
return input -> input > lowerLongBound && input < upperLongBound;
|
||||
} else if (lowerStrict) {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@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);
|
||||
}
|
||||
};
|
||||
return input -> input > lowerLongBound && input <= upperLongBound;
|
||||
} else if (upperStrict) {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@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);
|
||||
}
|
||||
};
|
||||
return input -> input >= lowerLongBound && input < upperLongBound;
|
||||
} else {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@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);
|
||||
}
|
||||
};
|
||||
return input -> input >= lowerLongBound && input <= upperLongBound;
|
||||
}
|
||||
} else if (hasUpperLongBound) {
|
||||
if (upperStrict) {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@Override
|
||||
public boolean applyLong(long input)
|
||||
{
|
||||
final int upperComparing = Long.compare(upperLongBound, input);
|
||||
return upperComparing > 0;
|
||||
}
|
||||
};
|
||||
return input -> input < upperLongBound;
|
||||
} else {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@Override
|
||||
public boolean applyLong(long input)
|
||||
{
|
||||
final int upperComparing = Long.compare(upperLongBound, input);
|
||||
return upperComparing >= 0;
|
||||
}
|
||||
};
|
||||
return input -> input <= upperLongBound;
|
||||
}
|
||||
} else if (hasLowerLongBound) {
|
||||
if (lowerStrict) {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@Override
|
||||
public boolean applyLong(long input)
|
||||
{
|
||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
||||
return lowerComparing > 0;
|
||||
}
|
||||
};
|
||||
return input -> input > lowerLongBound;
|
||||
} else {
|
||||
return new DruidLongPredicate()
|
||||
{
|
||||
@Override
|
||||
public boolean applyLong(long input)
|
||||
{
|
||||
final int lowerComparing = Long.compare(input, lowerLongBound);
|
||||
return lowerComparing >= 0;
|
||||
}
|
||||
};
|
||||
return input -> input >= lowerLongBound;
|
||||
}
|
||||
} else {
|
||||
return DruidLongPredicate.ALWAYS_TRUE;
|
||||
|
|
Loading…
Reference in New Issue