forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Equals.java
82 lines (68 loc) · 2.75 KB
/
Equals.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.xpack.esql.expression.predicate.operator.comparison;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.compute.ann.Evaluator;
import org.elasticsearch.xpack.ql.expression.Expression;
import org.elasticsearch.xpack.ql.expression.FieldAttribute;
import org.elasticsearch.xpack.ql.expression.TypeResolutions;
import org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.BinaryComparison;
import org.elasticsearch.xpack.ql.tree.NodeInfo;
import org.elasticsearch.xpack.ql.tree.Source;
import org.elasticsearch.xpack.ql.type.DataTypes;
import java.time.ZoneId;
public class Equals extends org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.Equals {
public Equals(Source source, Expression left, Expression right) {
super(source, left, right);
}
public Equals(Source source, Expression left, Expression right, ZoneId zoneId) {
super(source, left, right, zoneId);
}
@Override
protected TypeResolution resolveInputType(Expression e, TypeResolutions.ParamOrdinal paramOrdinal) {
if (e instanceof FieldAttribute fa && fa.dataType() == DataTypes.TEXT) {
return TypeResolution.TYPE_RESOLVED;
}
return super.resolveInputType(e, paramOrdinal);
}
@Override
protected NodeInfo<org.elasticsearch.xpack.ql.expression.predicate.operator.comparison.Equals> info() {
return NodeInfo.create(this, Equals::new, left(), right(), zoneId());
}
@Override
protected Equals replaceChildren(Expression newLeft, Expression newRight) {
return new Equals(source(), newLeft, newRight, zoneId());
}
@Override
public Equals swapLeftAndRight() {
return new Equals(source(), right(), left(), zoneId());
}
@Override
public BinaryComparison negate() {
return new NotEquals(source(), left(), right(), zoneId());
}
@Evaluator(extraName = "Ints")
static boolean processInts(int lhs, int rhs) {
return lhs == rhs;
}
@Evaluator(extraName = "Longs")
static boolean processLongs(long lhs, long rhs) {
return lhs == rhs;
}
@Evaluator(extraName = "Doubles")
static boolean processDoubles(double lhs, double rhs) {
return lhs == rhs;
}
@Evaluator(extraName = "Keywords")
static boolean processKeywords(BytesRef lhs, BytesRef rhs) {
return lhs.equals(rhs);
}
@Evaluator(extraName = "Bools")
static boolean processBools(boolean lhs, boolean rhs) {
return lhs == rhs;
}
}