public class FunctionInfo extends java.lang.Object implements java.lang.Comparable<FunctionInfo>, org.elasticsearch.common.io.stream.Streamable
Modifier and Type | Class and Description |
---|---|
static class |
FunctionInfo.Type |
Constructor and Description |
---|
FunctionInfo() |
FunctionInfo(FunctionIdent ident,
DataType returnType) |
FunctionInfo(FunctionIdent ident,
DataType returnType,
FunctionInfo.Type type) |
FunctionInfo(FunctionIdent ident,
DataType returnType,
FunctionInfo.Type type,
boolean deterministic,
boolean comparisonReplacementPossible) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(FunctionInfo o) |
boolean |
comparisonReplacementPossible()
If this method returns
true , for this function it is possible to replace the containing
comparison while preserving the truth value for all used operators
with or without an operator mapping. |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
FunctionIdent |
ident() |
boolean |
isDeterministic() |
void |
readFrom(org.elasticsearch.common.io.stream.StreamInput in) |
DataType |
returnType() |
java.lang.String |
toString() |
FunctionInfo.Type |
type() |
void |
writeTo(org.elasticsearch.common.io.stream.StreamOutput out) |
public FunctionInfo()
public FunctionInfo(FunctionIdent ident, DataType returnType)
public FunctionInfo(FunctionIdent ident, DataType returnType, FunctionInfo.Type type)
public FunctionInfo(FunctionIdent ident, DataType returnType, FunctionInfo.Type type, boolean deterministic, boolean comparisonReplacementPossible)
public FunctionIdent ident()
public FunctionInfo.Type type()
public boolean isDeterministic()
public DataType returnType()
public boolean comparisonReplacementPossible()
true
, for this function it is possible to replace the containing
comparison while preserving the truth value for all used operators
with or without an operator mapping.
It describes the following:
say we have a comparison-query like this:
col > 10.5
then a function f, for which comparions are replaceable, can be applied so
that:
f(col) > f(10.5)
for all col for which col > 10.5 is true. Maybe > needs to be mapped to another
operator, but this may not depend on the actual values used here.
Fun facts:
* This property holds for the = comparison operator for all functions f.
* This property is transitive so if f and g are replaceable,
then f(g(x)) also is
* it is possible to replace:
col > 10.5
with:
f(col) > f(10.5)
for every operator (possibly mapped) and the query is still equivalent.
Example 1:
if f is defined as f(v) = v + 1
then col + 1 > 11.5 must be true for all col > 10.5.
This is indeed true.
So f is replaceable for >.
Fun fact: for f all comparison operators =, >, <, >=,<= are replaceable
Example 2 (a rounding function):
if f is defined as f(v) = ceil(v)
then ceil(col) > 11 for all col > 10.5.
But there is 10.8 for which f is 11 and
11 > 11 is false.
Here a simple mapping of the operator will do the trick:
> -> >=
< -> <=
So for f comparisons are replaceable using the mapping above.
Example 3:
if f is defined as f(v) = v % 5
then col % 5 > 0.5 for all col > 10.5
but there is 20 for which
f is 0 and
0 > 0.5 is false.
So for f comparisons cannot be replaced.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(FunctionInfo o)
compareTo
in interface java.lang.Comparable<FunctionInfo>
public void readFrom(org.elasticsearch.common.io.stream.StreamInput in) throws java.io.IOException
readFrom
in interface org.elasticsearch.common.io.stream.Streamable
java.io.IOException
public void writeTo(org.elasticsearch.common.io.stream.StreamOutput out) throws java.io.IOException
writeTo
in interface org.elasticsearch.common.io.stream.Streamable
java.io.IOException