Skip to content

Commit 27a9042

Browse files
committed
rename alg -> algorithm
1 parent c2811b7 commit 27a9042

File tree

7 files changed

+65
-63
lines changed

7 files changed

+65
-63
lines changed

docs/reference/esql/functions/kibana/definition/hash.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/parameters/hash.asciidoc

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/esql/functions/signature/hash.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/reference/esql/functions/types/hash.asciidoc

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashConstantEvaluator.java

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/generated/org/elasticsearch/xpack/esql/expression/function/scalar/string/HashEvaluator.java

Lines changed: 26 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Hash.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class Hash extends EsqlScalarFunction {
3838

3939
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(Expression.class, "Hash", Hash::new);
4040

41-
private final Expression alg;
41+
private final Expression algorithm;
4242
private final Expression input;
4343

4444
@FunctionInfo(
@@ -47,11 +47,11 @@ public class Hash extends EsqlScalarFunction {
4747
)
4848
public Hash(
4949
Source source,
50-
@Param(name = "alg", type = { "keyword", "text" }, description = "Hash algorithm to use.") Expression alg,
50+
@Param(name = "algorithm", type = { "keyword", "text" }, description = "Hash algorithm to use.") Expression algorithm,
5151
@Param(name = "input", type = { "keyword", "text" }, description = "Input to hash.") Expression input
5252
) {
53-
super(source, List.of(alg, input));
54-
this.alg = alg;
53+
super(source, List.of(algorithm, input));
54+
this.algorithm = algorithm;
5555
this.input = input;
5656
}
5757

@@ -62,7 +62,7 @@ private Hash(StreamInput in) throws IOException {
6262
@Override
6363
public void writeTo(StreamOutput out) throws IOException {
6464
source().writeTo(out);
65-
out.writeNamedWriteable(alg);
65+
out.writeNamedWriteable(algorithm);
6666
out.writeNamedWriteable(input);
6767
}
6868

@@ -82,7 +82,7 @@ protected TypeResolution resolveType() {
8282
return new TypeResolution("Unresolved children");
8383
}
8484

85-
TypeResolution resolution = isString(alg, sourceText(), FIRST);
85+
TypeResolution resolution = isString(algorithm, sourceText(), FIRST);
8686
if (resolution.unresolved()) {
8787
return resolution;
8888
}
@@ -92,28 +92,28 @@ protected TypeResolution resolveType() {
9292

9393
@Override
9494
public boolean foldable() {
95-
return alg.foldable() && input.foldable();
95+
return algorithm.foldable() && input.foldable();
9696
}
9797

9898
@Evaluator(warnExceptions = NoSuchAlgorithmException.class)
99-
static BytesRef process(@Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch, BytesRef alg, BytesRef input)
99+
static BytesRef process(@Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch, BytesRef algorithm, BytesRef input)
100100
throws NoSuchAlgorithmException {
101-
return hash(scratch, MessageDigest.getInstance(alg.utf8ToString()), input);
101+
return hash(scratch, MessageDigest.getInstance(algorithm.utf8ToString()), input);
102102
}
103103

104104
@Evaluator(extraName = "Constant")
105105
static BytesRef processConstant(
106106
@Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch,
107-
@Fixed(build = true) MessageDigest alg,
107+
@Fixed(build = true) MessageDigest algorithm,
108108
BytesRef input
109109
) {
110-
return hash(scratch, alg, input);
110+
return hash(scratch, algorithm, input);
111111
}
112112

113-
private static BytesRef hash(BreakingBytesRefBuilder scratch, MessageDigest alg, BytesRef input) {
114-
alg.reset();
115-
alg.update(input.bytes, input.offset, input.length);
116-
var digest = alg.digest();
113+
private static BytesRef hash(BreakingBytesRefBuilder scratch, MessageDigest algorithm, BytesRef input) {
114+
algorithm.reset();
115+
algorithm.update(input.bytes, input.offset, input.length);
116+
var digest = algorithm.digest();
117117
scratch.clear();
118118
scratch.grow(digest.length * 2);
119119
appendUtf8HexDigest(scratch, digest);
@@ -135,23 +135,23 @@ private static void appendUtf8HexDigest(BreakingBytesRefBuilder scratch, byte[]
135135

136136
@Override
137137
public EvalOperator.ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvaluator) {
138-
if (alg.foldable()) {
138+
if (algorithm.foldable()) {
139139
try {
140-
var md = MessageDigest.getInstance(((BytesRef) alg.fold()).utf8ToString());
140+
var md = MessageDigest.getInstance(((BytesRef) algorithm.fold()).utf8ToString());
141141
return new HashConstantEvaluator.Factory(
142142
source(),
143143
context -> new BreakingBytesRefBuilder(context.breaker(), "hash"),
144144
context -> md,
145145
toEvaluator.apply(input)
146146
);
147147
} catch (NoSuchAlgorithmException e) {
148-
throw new InvalidArgumentException(e, "invalid alg for [{}]: {}", sourceText(), e.getMessage());
148+
throw new InvalidArgumentException(e, "invalid algorithm for [{}]: {}", sourceText(), e.getMessage());
149149
}
150150
} else {
151151
return new HashEvaluator.Factory(
152152
source(),
153153
context -> new BreakingBytesRefBuilder(context.breaker(), "hash"),
154-
toEvaluator.apply(alg),
154+
toEvaluator.apply(algorithm),
155155
toEvaluator.apply(input)
156156
);
157157
}

0 commit comments

Comments
 (0)