Class ToIp
- All Implemented Interfaces:
NamedWriteable,Writeable,Resolvable,EvaluatorMapper,OptionalArgument,ConvertFunction,SurrogateExpression
IPv4 addresses have traditionally parsed quads with leading zeros in three mutually exclusive ways:
- As octal numbers. So
1.1.010.1becomes1.1.8.1. - As decimal numbers. So
1.1.010.1becomes1.1.10.1. - Rejects them entirely. So
1.1.010.1becomesnullwith a warning.
These three ways of handling leading zeros are available with the optional
leading_zeros named parameter. Set to octal, decimal,
or reject. If not sent this defaults to reject which has
been Elasticsearch's traditional way of handling leading zeros for years.
This doesn't extend from AbstractConvertFunction so that it can
support a named parameter for the leading zeros behavior. Instead, it rewrites
itself into either ToIpLeadingZerosOctal, ToIpLeadingZerosDecimal,
or ToIpLeadingZerosRejected which are all AbstractConvertFunction
subclasses. This keeps the conversion code happy while still allowing us to
expose a single method to users.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
Expression.TypeResolutionNested classes/interfaces inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
EvaluatorMapper.ToEvaluatorNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsFields inherited from class org.elasticsearch.xpack.esql.core.expression.function.scalar.ScalarFunction
MAX_BYTES_REF_RESULT_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondataType()field()Expression containing the values to be converted.protected NodeInfo<? extends Expression> info()replaceChildren(List<Expression> newChildren) protected Expression.TypeResolutionThe types thatConvertFunction.field()can have.Returns the expression to be replaced by ornullif this cannot be replaced.toEvaluator(EvaluatorMapper.ToEvaluator toEvaluator) Convert this into anEvalOperator.ExpressionEvaluator.voidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.xpack.esql.expression.function.scalar.EsqlScalarFunction
foldMethods inherited from class org.elasticsearch.xpack.esql.core.expression.function.Function
arguments, equals, functionName, hashCode, nodeString, nullableMethods inherited from class org.elasticsearch.xpack.esql.core.expression.Expression
canonical, canonicalize, childrenResolved, foldable, propertiesToString, references, resolved, semanticEquals, semanticHash, toString, typeResolvedMethods inherited from class org.elasticsearch.xpack.esql.core.tree.Node
anyMatch, children, collect, collectFirstChildren, collectLeaves, doCollectFirst, forEachDown, forEachDown, forEachProperty, forEachPropertyDown, forEachPropertyOnly, forEachPropertyUp, forEachUp, forEachUp, nodeName, nodeProperties, replaceChildrenSameSize, source, sourceLocation, sourceText, transformChildren, transformDown, transformDown, transformDown, transformNodeProps, transformPropertiesDown, transformPropertiesOnly, transformPropertiesUp, transformUp, transformUp, transformUpMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper
fold
-
Field Details
-
ALLOWED_OPTIONS
-
-
Constructor Details
-
ToIp
-
-
Method Details
-
getWriteableName
- Specified by:
getWriteableNamein interfaceNamedWriteable
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
dataType
- Specified by:
dataTypein classExpression
-
replaceChildren
- Specified by:
replaceChildrenin classNode<Expression>
-
info
- Specified by:
infoin classNode<Expression>
-
toEvaluator
public EvalOperator.ExpressionEvaluator.Factory toEvaluator(EvaluatorMapper.ToEvaluator toEvaluator) Description copied from interface:EvaluatorMapperConvert this into anEvalOperator.ExpressionEvaluator.Note for implementors: If you are implementing this function, you should call the passed-in lambda on your children, after doing any other manipulation (casting, etc.) necessary.
Note for Callers: If you are attempting to call this method, and you have an
Expressionand aLayout, you likely want to callEvalMapper.toEvaluator(org.elasticsearch.xpack.esql.core.expression.FoldContext, org.elasticsearch.xpack.esql.core.expression.Expression, org.elasticsearch.xpack.esql.planner.Layout)instead. On the other hand, if you already have something that looks like the parameter for this method, you should call this method with that function.Build an
EvalOperator.ExpressionEvaluator.Factoryfor the tree of expressions rooted at this node. This is only guaranteed to return a sensible evaluator if this node has a valid type. If this node is a subclass ofExpressionthen "valid type" means thatExpression.typeResolved()returns a non-error resolution. If Expression.typeResolved() returns an error then this method may throw. Or return an evaluator that produces garbage. Or return an evaluator that throws when run.- Specified by:
toEvaluatorin interfaceEvaluatorMapper
-
surrogate
Description copied from interface:SurrogateExpressionReturns the expression to be replaced by ornullif this cannot be replaced.- Specified by:
surrogatein interfaceSurrogateExpression
-
field
Description copied from interface:ConvertFunctionExpression containing the values to be converted.- Specified by:
fieldin interfaceConvertFunction
-
supportedTypes
Description copied from interface:ConvertFunctionThe types thatConvertFunction.field()can have.- Specified by:
supportedTypesin interfaceConvertFunction
-
resolveType
- Overrides:
resolveTypein classExpression
-