Now that we have explicit Ln() and Log10(), let's get rid of the hopelessly esoteric arbitrary-base Log().
This commit is contained in:
@@ -68,8 +68,7 @@ public class Funcs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an expression that computes the natural logarithm of the supplied expression,
|
* Creates an expression that computes the natural logarithm of the supplied expression.
|
||||||
* which may be double-precision.
|
|
||||||
*/
|
*/
|
||||||
public static Ln ln (SQLExpression exp)
|
public static Ln ln (SQLExpression exp)
|
||||||
{
|
{
|
||||||
@@ -77,24 +76,13 @@ public class Funcs
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an expression that computes the base-10 logarithm of the supplied expression,
|
* Creates an expression that computes the base-10 logarithm of the supplied expression.
|
||||||
* which may be double-precision.
|
|
||||||
*/
|
*/
|
||||||
public static Log10 log10 (SQLExpression value)
|
public static Log10 log10 (SQLExpression value)
|
||||||
{
|
{
|
||||||
return new Log10(value);
|
return new Log10(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an expression that computes the logarithm of the supplied value expression
|
|
||||||
* in the supplied base expression. Note: Under PostgreSQL, this must evaluate to a simple
|
|
||||||
* numerical, not double precision.
|
|
||||||
*/
|
|
||||||
public static LogN logN (SQLExpression base, SQLExpression value)
|
|
||||||
{
|
|
||||||
return new LogN(base, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an expression that evaluates to the constant PI.
|
* Creates an expression that evaluates to the constant PI.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -79,21 +79,6 @@ public abstract class NumericalFun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LogN extends TwoArgFun {
|
|
||||||
public LogN (SQLExpression base, SQLExpression value) {
|
|
||||||
super(base, value);
|
|
||||||
}
|
|
||||||
public Object accept (ExpressionVisitor<?> visitor) {
|
|
||||||
return visitor.visit(this);
|
|
||||||
}
|
|
||||||
public SQLExpression getBase () {
|
|
||||||
return _arg1;
|
|
||||||
}
|
|
||||||
public SQLExpression getValue () {
|
|
||||||
return _arg2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Pi extends NoArgFun {
|
public static class Pi extends NoArgFun {
|
||||||
public Object accept (ExpressionVisitor<?> visitor) {
|
public Object accept (ExpressionVisitor<?> visitor) {
|
||||||
return visitor.visit(this);
|
return visitor.visit(this);
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ import com.samskivert.depot.function.NumericalFun.Exp;
|
|||||||
import com.samskivert.depot.function.NumericalFun.Floor;
|
import com.samskivert.depot.function.NumericalFun.Floor;
|
||||||
import com.samskivert.depot.function.NumericalFun.Ln;
|
import com.samskivert.depot.function.NumericalFun.Ln;
|
||||||
import com.samskivert.depot.function.NumericalFun.Log10;
|
import com.samskivert.depot.function.NumericalFun.Log10;
|
||||||
import com.samskivert.depot.function.NumericalFun.LogN;
|
|
||||||
import com.samskivert.depot.function.NumericalFun.Pi;
|
import com.samskivert.depot.function.NumericalFun.Pi;
|
||||||
import com.samskivert.depot.function.NumericalFun.Power;
|
import com.samskivert.depot.function.NumericalFun.Power;
|
||||||
import com.samskivert.depot.function.NumericalFun.Random;
|
import com.samskivert.depot.function.NumericalFun.Random;
|
||||||
@@ -623,11 +622,6 @@ public abstract class BuildVisitor implements ExpressionVisitor<Void>
|
|||||||
return appendFunctionCall("log", exp.getArg());
|
return appendFunctionCall("log", exp.getArg());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Void visit (LogN exp)
|
|
||||||
{
|
|
||||||
return appendFunctionCall("log", exp.getBase(), exp.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Void visit (Pi exp)
|
public Void visit (Pi exp)
|
||||||
{
|
{
|
||||||
return appendFunctionCall("PI");
|
return appendFunctionCall("PI");
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ import com.samskivert.depot.function.NumericalFun.Exp;
|
|||||||
import com.samskivert.depot.function.NumericalFun.Floor;
|
import com.samskivert.depot.function.NumericalFun.Floor;
|
||||||
import com.samskivert.depot.function.NumericalFun.Ln;
|
import com.samskivert.depot.function.NumericalFun.Ln;
|
||||||
import com.samskivert.depot.function.NumericalFun.Log10;
|
import com.samskivert.depot.function.NumericalFun.Log10;
|
||||||
import com.samskivert.depot.function.NumericalFun.LogN;
|
|
||||||
import com.samskivert.depot.function.NumericalFun.Pi;
|
import com.samskivert.depot.function.NumericalFun.Pi;
|
||||||
import com.samskivert.depot.function.NumericalFun.Power;
|
import com.samskivert.depot.function.NumericalFun.Power;
|
||||||
import com.samskivert.depot.function.NumericalFun.Random;
|
import com.samskivert.depot.function.NumericalFun.Random;
|
||||||
@@ -395,11 +394,6 @@ public class ExpressionEvaluator
|
|||||||
throw new IllegalArgumentException("Can't evaluate expression: " + exp);
|
throw new IllegalArgumentException("Can't evaluate expression: " + exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Void visit (LogN exp)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Can't evaluate expression: " + exp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Void visit (Pi exp)
|
public Void visit (Pi exp)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Can't evaluate expression: " + exp);
|
throw new IllegalArgumentException("Can't evaluate expression: " + exp);
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import com.samskivert.depot.function.NumericalFun.Exp;
|
|||||||
import com.samskivert.depot.function.NumericalFun.Floor;
|
import com.samskivert.depot.function.NumericalFun.Floor;
|
||||||
import com.samskivert.depot.function.NumericalFun.Ln;
|
import com.samskivert.depot.function.NumericalFun.Ln;
|
||||||
import com.samskivert.depot.function.NumericalFun.Log10;
|
import com.samskivert.depot.function.NumericalFun.Log10;
|
||||||
import com.samskivert.depot.function.NumericalFun.LogN;
|
|
||||||
import com.samskivert.depot.function.NumericalFun.Pi;
|
import com.samskivert.depot.function.NumericalFun.Pi;
|
||||||
import com.samskivert.depot.function.NumericalFun.Power;
|
import com.samskivert.depot.function.NumericalFun.Power;
|
||||||
import com.samskivert.depot.function.NumericalFun.Random;
|
import com.samskivert.depot.function.NumericalFun.Random;
|
||||||
@@ -125,7 +124,6 @@ public interface ExpressionVisitor<T>
|
|||||||
public T visit (Floor exp);
|
public T visit (Floor exp);
|
||||||
public T visit (Ln exp);
|
public T visit (Ln exp);
|
||||||
public T visit (Log10 exp);
|
public T visit (Log10 exp);
|
||||||
public T visit (LogN exp);
|
|
||||||
public T visit (Pi exp);
|
public T visit (Pi exp);
|
||||||
public T visit (Power exp);
|
public T visit (Power exp);
|
||||||
public T visit (Random exp);
|
public T visit (Random exp);
|
||||||
|
|||||||
Reference in New Issue
Block a user