Skip to content

Commit 99ad357

Browse files
committed
rename alg -> algorithm
1 parent c2811b7 commit 99ad357

File tree

8 files changed

+86
-81
lines changed

8 files changed

+86
-81
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: 23 additions & 20 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,31 @@ 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)
100-
throws NoSuchAlgorithmException {
101-
return hash(scratch, MessageDigest.getInstance(alg.utf8ToString()), input);
99+
static BytesRef process(
100+
@Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch,
101+
BytesRef algorithm,
102+
BytesRef input
103+
) throws NoSuchAlgorithmException {
104+
return hash(scratch, MessageDigest.getInstance(algorithm.utf8ToString()), input);
102105
}
103106

104107
@Evaluator(extraName = "Constant")
105108
static BytesRef processConstant(
106109
@Fixed(includeInToString = false, build = true) BreakingBytesRefBuilder scratch,
107-
@Fixed(build = true) MessageDigest alg,
110+
@Fixed(build = true) MessageDigest algorithm,
108111
BytesRef input
109112
) {
110-
return hash(scratch, alg, input);
113+
return hash(scratch, algorithm, input);
111114
}
112115

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();
116+
private static BytesRef hash(BreakingBytesRefBuilder scratch, MessageDigest algorithm, BytesRef input) {
117+
algorithm.reset();
118+
algorithm.update(input.bytes, input.offset, input.length);
119+
var digest = algorithm.digest();
117120
scratch.clear();
118121
scratch.grow(digest.length * 2);
119122
appendUtf8HexDigest(scratch, digest);
@@ -135,23 +138,23 @@ private static void appendUtf8HexDigest(BreakingBytesRefBuilder scratch, byte[]
135138

136139
@Override
137140
public EvalOperator.ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvaluator) {
138-
if (alg.foldable()) {
141+
if (algorithm.foldable()) {
139142
try {
140-
var md = MessageDigest.getInstance(((BytesRef) alg.fold()).utf8ToString());
143+
var md = MessageDigest.getInstance(((BytesRef) algorithm.fold()).utf8ToString());
141144
return new HashConstantEvaluator.Factory(
142145
source(),
143146
context -> new BreakingBytesRefBuilder(context.breaker(), "hash"),
144147
context -> md,
145148
toEvaluator.apply(input)
146149
);
147150
} catch (NoSuchAlgorithmException e) {
148-
throw new InvalidArgumentException(e, "invalid alg for [{}]: {}", sourceText(), e.getMessage());
151+
throw new InvalidArgumentException(e, "invalid algorithm for [{}]: {}", sourceText(), e.getMessage());
149152
}
150153
} else {
151154
return new HashEvaluator.Factory(
152155
source(),
153156
context -> new BreakingBytesRefBuilder(context.breaker(), "hash"),
154-
toEvaluator.apply(alg),
157+
toEvaluator.apply(algorithm),
155158
toEvaluator.apply(input)
156159
);
157160
}

0 commit comments

Comments
 (0)