Skip to content

Commit 98a7fa6

Browse files
Merge branch 'master' into reincarnate-log4j2-update
2 parents 0f07251 + 89fdf47 commit 98a7fa6

File tree

35 files changed

+404
-565
lines changed

35 files changed

+404
-565
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/xcontent/FilterContentBenchmark.java

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
package org.elasticsearch.benchmark.xcontent;
1010

11+
import org.elasticsearch.common.Strings;
1112
import org.elasticsearch.common.bytes.BytesReference;
1213
import org.elasticsearch.common.io.Streams;
1314
import org.elasticsearch.common.io.stream.BytesStreamOutput;
1415
import org.elasticsearch.common.util.Maps;
1516
import org.elasticsearch.common.xcontent.XContentHelper;
17+
import org.elasticsearch.common.xcontent.support.XContentMapValues;
18+
import org.elasticsearch.search.fetch.subphase.FetchSourcePhase;
1619
import org.elasticsearch.xcontent.XContentBuilder;
1720
import org.elasticsearch.xcontent.XContentParser;
1821
import org.elasticsearch.xcontent.XContentParserConfiguration;
@@ -39,8 +42,8 @@
3942
import java.util.stream.Collectors;
4043

4144
@Fork(1)
42-
@Warmup(iterations = 2)
43-
@Measurement(iterations = 3)
45+
@Warmup(iterations = 1)
46+
@Measurement(iterations = 2)
4447
@BenchmarkMode(Mode.AverageTime)
4548
@OutputTimeUnit(TimeUnit.NANOSECONDS)
4649
@State(Scope.Benchmark)
@@ -122,6 +125,47 @@ public BytesReference filterWithNewParserConfig() throws IOException {
122125
return filter(contentParserConfiguration);
123126
}
124127

128+
@Benchmark
129+
public BytesReference filterWithMap() throws IOException {
130+
Map<String, Object> sourceMap = XContentHelper.convertToMap(source, false).v2();
131+
String[] includes;
132+
String[] excludes;
133+
if (inclusive) {
134+
includes = filters.toArray(Strings.EMPTY_ARRAY);
135+
excludes = null;
136+
} else {
137+
includes = null;
138+
excludes = filters.toArray(Strings.EMPTY_ARRAY);
139+
}
140+
Map<String, Object> filterMap = XContentMapValues.filter(sourceMap, includes, excludes);
141+
return FetchSourcePhase.objectToBytes(filterMap, XContentType.JSON, Math.min(1024, source.length()));
142+
}
143+
144+
@Benchmark
145+
public BytesReference filterWithBuilder() throws IOException {
146+
BytesStreamOutput streamOutput = new BytesStreamOutput(Math.min(1024, source.length()));
147+
Set<String> includes;
148+
Set<String> excludes;
149+
if (inclusive) {
150+
includes = filters;
151+
excludes = Set.of();
152+
} else {
153+
includes = Set.of();
154+
excludes = filters;
155+
}
156+
XContentBuilder builder = new XContentBuilder(
157+
XContentType.JSON.xContent(),
158+
streamOutput,
159+
includes,
160+
excludes,
161+
XContentType.JSON.toParsedMediaType()
162+
);
163+
try (XContentParser parser = XContentType.JSON.xContent().createParser(XContentParserConfiguration.EMPTY, source.streamInput())) {
164+
builder.copyCurrentStructure(parser);
165+
return BytesReference.bytes(builder);
166+
}
167+
}
168+
125169
private XContentParserConfiguration buildParseConfig() {
126170
Set<String> includes;
127171
Set<String> excludes;

docs/reference/ml/trained-models/apis/start-trained-model-deployment.asciidoc

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,25 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
3939
`inference_threads`::
4040
(Optional, integer)
4141
Sets the number of threads used by the inference process. This generally increases
42-
the inference speed. The inference process is a compute-bound process; any number
43-
greater than the number of available CPU cores on the machine does not increase the
44-
inference speed.
42+
the inference speed. The inference process is a compute-bound process; any number
43+
greater than the number of available hardware threads on the machine does not increase the
44+
inference speed. If this setting is greater than the number of hardware threads
45+
it will automatically be changed to a value less than the number of hardware threads.
4546
Defaults to 1.
4647

4748
`model_threads`::
4849
(Optional, integer)
49-
Indicates how many threads are used when sending inference requests to
50-
the model. Increasing this value generally increases the throughput. Defaults to
51-
1.
50+
The number of threads used when sending inference requests to the model.
51+
Increasing this value generally increases the throughput.
52+
If this setting is greater than the number of hardware threads
53+
it will automatically be changed to a value less than the number of hardware threads.
54+
Defaults to 1.
55+
56+
[NOTE]
57+
=============================================
58+
If the sum of `inference_threads` and `model_threads` is greater than the number of
59+
hardware threads then the number of `inference_threads` will be reduced.
60+
=============================================
5261

5362
`queue_capacity`::
5463
(Optional, integer)

docs/reference/redirects.asciidoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,21 @@ See <<grok,Grokking grok>>.
158158

159159
// [START] Security redirects
160160

161+
[role="exclude",id="security-minimal-setup"]
162+
=== Set up minimal security for {es}
163+
164+
Refer to <<manually-configure-security,Manually configure security for the {stack}>>.
165+
161166
[role="exclude",id="get-started-users"]
162-
=== Create users
167+
==== Create users
168+
169+
Refer to the <<reset-password,`elasticsearch-reset-password`>> tool for resetting
170+
passwords of built-in users.
171+
172+
[role="exclude",id="add-built-in-users"]
173+
==== Configure {kib} to connect to {es} with a password
163174

164-
See <<security-create-builtin-users,Create passwords for built-in users>>.
175+
Refer to <<configuring-stack-security,Start the {stack} with security enabled>>.
165176

166177
[role="exclude",id="encrypting-communications-certificates"]
167178
=== Generate certificates

docs/reference/search/search.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ http://www.geojson.org[GeoJSON]
409409
{wikipedia}/Well-known_text_representation_of_geometry[Well Known Text]
410410
411411
`mvt(<zoom>/<x>/<y>@<extent>)` or `mvt(<zoom>/<x>/<y>)`:::
412-
experimental:[] Binary
412+
Binary
413413
https://docs.mapbox.com/vector-tiles/specification[Mapbox vector tile]. The API
414414
returns the tile as a base64-encoded string.
415415
+

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/AbstractStringProcessor.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ public final IngestDocument execute(IngestDocument document) {
5858
throw new IllegalArgumentException("field [" + field + "] is null, cannot process it.");
5959
}
6060

61-
if (val instanceof List) {
62-
List<?> list = (List<?>) val;
61+
if (val instanceof List<?> list) {
6362
List<Object> newList = new ArrayList<>(list.size());
6463
for (Object value : list) {
65-
if (value instanceof String) {
66-
newList.add(process((String) value));
64+
if (value instanceof String string) {
65+
newList.add(process(string));
6766
} else {
6867
throw new IllegalArgumentException(
6968
"value ["
@@ -80,8 +79,8 @@ public final IngestDocument execute(IngestDocument document) {
8079
}
8180
newValue = newList;
8281
} else {
83-
if (val instanceof String) {
84-
newValue = process((String) val);
82+
if (val instanceof String string) {
83+
newValue = process(string);
8584
} else {
8685
throw new IllegalArgumentException(
8786
"field [" + field + "] of type [" + val.getClass().getName() + "] cannot be cast to [" + String.class.getName() + "]"

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CommunityIdProcessor.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ static byte[] toUint16(int num) {
271271
static int parseIntFromObjectOrString(Object o, String fieldName) {
272272
if (o == null) {
273273
return 0;
274-
} else if (o instanceof Number) {
275-
return ((Number) o).intValue();
276-
} else if (o instanceof String) {
274+
} else if (o instanceof Number number) {
275+
return number.intValue();
276+
} else if (o instanceof String string) {
277277
try {
278-
return Integer.parseInt((String) o);
278+
return Integer.parseInt(string);
279279
} catch (NumberFormatException e) {
280280
// fall through to IllegalArgumentException below
281281
}
@@ -468,11 +468,9 @@ public static Transport fromNumber(int transportNumber) {
468468
}
469469

470470
public static Transport fromObject(Object o) {
471-
if (o instanceof Number) {
472-
return fromNumber(((Number) o).intValue());
473-
} else if (o instanceof String) {
474-
String protocolStr = (String) o;
475-
471+
if (o instanceof Number number) {
472+
return fromNumber(number.intValue());
473+
} else if (o instanceof String protocolStr) {
476474
// check if matches protocol name
477475
if (TRANSPORT_NAMES.containsKey(protocolStr.toLowerCase(Locale.ROOT))) {
478476
return TRANSPORT_NAMES.get(protocolStr.toLowerCase(Locale.ROOT));

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ConvertProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ public IngestDocument execute(IngestDocument document) {
191191
throw new IllegalArgumentException("Field [" + field + "] is null, cannot be converted to type [" + convertType + "]");
192192
}
193193

194-
if (oldValue instanceof List) {
195-
List<?> list = (List<?>) oldValue;
194+
if (oldValue instanceof List<?> list) {
196195
List<Object> newList = new ArrayList<>(list.size());
197196
for (Object value : list) {
198197
newList.add(convertType.convert(value));

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/FingerprintProcessor.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
9494
// iteratively traverse document fields
9595
while (values.isEmpty() == false) {
9696
var value = values.pop();
97-
if (value instanceof List) {
98-
var list = (List<?>) value;
97+
if (value instanceof List<?> list) {
9998
for (int k = list.size() - 1; k >= 0; k--) {
10099
values.push(list.get(k));
101100
}
@@ -111,13 +110,13 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
111110
} else if (value instanceof Map) {
112111
var map = (Map<String, Object>) value;
113112
// process map entries in consistent order
113+
@SuppressWarnings("rawtypes")
114114
var entryList = new ArrayList<>(map.entrySet());
115115
entryList.sort(Map.Entry.comparingByKey(Comparator.naturalOrder()));
116116
for (int k = entryList.size() - 1; k >= 0; k--) {
117117
values.push(entryList.get(k));
118118
}
119-
} else if (value instanceof Map.Entry) {
120-
var entry = (Map.Entry<?, ?>) value;
119+
} else if (value instanceof Map.Entry<?, ?> entry) {
121120
hasher.update(DELIMITER);
122121
hasher.update(toBytes(entry.getKey()));
123122
values.push(entry.getValue());
@@ -135,37 +134,36 @@ public IngestDocument execute(IngestDocument ingestDocument) throws Exception {
135134
}
136135

137136
static byte[] toBytes(Object value) {
138-
if (value instanceof String) {
139-
return ((String) value).getBytes(StandardCharsets.UTF_8);
137+
if (value instanceof String string) {
138+
return string.getBytes(StandardCharsets.UTF_8);
140139
}
141-
if (value instanceof byte[]) {
142-
return (byte[]) value;
140+
if (value instanceof byte[] bytes) {
141+
return bytes;
143142
}
144-
if (value instanceof Integer) {
143+
if (value instanceof Integer integer) {
145144
byte[] intBytes = new byte[4];
146-
ByteUtils.writeIntLE((Integer) value, intBytes, 0);
145+
ByteUtils.writeIntLE(integer, intBytes, 0);
147146
return intBytes;
148147
}
149-
if (value instanceof Long) {
148+
if (value instanceof Long longValue) {
150149
byte[] longBytes = new byte[8];
151-
ByteUtils.writeLongLE((Long) value, longBytes, 0);
150+
ByteUtils.writeLongLE(longValue, longBytes, 0);
152151
return longBytes;
153152
}
154-
if (value instanceof Float) {
153+
if (value instanceof Float floatValue) {
155154
byte[] floatBytes = new byte[4];
156-
ByteUtils.writeFloatLE((Float) value, floatBytes, 0);
155+
ByteUtils.writeFloatLE(floatValue, floatBytes, 0);
157156
return floatBytes;
158157
}
159-
if (value instanceof Double) {
158+
if (value instanceof Double doubleValue) {
160159
byte[] doubleBytes = new byte[8];
161-
ByteUtils.writeDoubleLE((Double) value, doubleBytes, 0);
160+
ByteUtils.writeDoubleLE(doubleValue, doubleBytes, 0);
162161
return doubleBytes;
163162
}
164-
if (value instanceof Boolean) {
165-
return (Boolean) value ? TRUE_BYTES : FALSE_BYTES;
163+
if (value instanceof Boolean b) {
164+
return b ? TRUE_BYTES : FALSE_BYTES;
166165
}
167-
if (value instanceof ZonedDateTime) {
168-
ZonedDateTime zdt = (ZonedDateTime) value;
166+
if (value instanceof ZonedDateTime zdt) {
169167
byte[] zoneIdBytes = zdt.getZone().getId().getBytes(StandardCharsets.UTF_8);
170168
byte[] zdtBytes = new byte[32 + zoneIdBytes.length];
171169
ByteUtils.writeIntLE(zdt.getYear(), zdtBytes, 0);
@@ -179,9 +177,9 @@ static byte[] toBytes(Object value) {
179177
System.arraycopy(zoneIdBytes, 0, zdtBytes, 32, zoneIdBytes.length);
180178
return zdtBytes;
181179
}
182-
if (value instanceof Date) {
180+
if (value instanceof Date date) {
183181
byte[] dateBytes = new byte[8];
184-
ByteUtils.writeLongLE(((Date) value).getTime(), dateBytes, 0);
182+
ByteUtils.writeLongLE(date.getTime(), dateBytes, 0);
185183
return dateBytes;
186184
}
187185
if (value == null) {

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ForEachProcessor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ public void execute(IngestDocument ingestDocument, BiConsumer<IngestDocument, Ex
6363
} else {
6464
handler.accept(null, new IllegalArgumentException("field [" + field + "] is null, cannot loop over its elements."));
6565
}
66-
} else if (o instanceof Map) {
67-
Map<?, ?> map = (Map<?, ?>) o;
66+
} else if (o instanceof Map<?, ?> map) {
6867
List<?> keys = new ArrayList<>(map.keySet());
6968
innerExecuteMap(0, new HashMap<Object, Object>(map), keys, new HashMap<>(map.size()), ingestDocument, handler);
70-
} else if (o instanceof List) {
71-
List<?> list = (List<?>) o;
69+
} else if (o instanceof List<?> list) {
7270
innerExecuteList(0, new ArrayList<>(list), new ArrayList<>(list.size()), ingestDocument, handler);
7371
} else {
7472
throw new IllegalArgumentException(

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/GeoIpProcessor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ public IngestDocument execute(IngestDocument ingestDocument) throws IOException
131131
return ingestDocument;
132132
}
133133

134-
if (ip instanceof String) {
135-
Map<String, Object> geoData = getGeoData(lazyLoader, (String) ip);
134+
if (ip instanceof String ipString) {
135+
Map<String, Object> geoData = getGeoData(lazyLoader, ipString);
136136
if (geoData.isEmpty() == false) {
137137
ingestDocument.setFieldValue(targetField, geoData);
138138
}
139-
} else if (ip instanceof List) {
139+
} else if (ip instanceof List<?> ipList) {
140140
boolean match = false;
141-
List<Map<String, Object>> geoDataList = new ArrayList<>(((List) ip).size());
142-
for (Object ipAddr : (List) ip) {
141+
List<Map<String, Object>> geoDataList = new ArrayList<>(ipList.size());
142+
for (Object ipAddr : ipList) {
143143
if (ipAddr instanceof String == false) {
144144
throw new IllegalArgumentException("array in field [" + field + "] should only contain strings");
145145
}

modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentCache.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ private static final class CompositeCacheKey {
4040

4141
@Override
4242
public boolean equals(Object obj) {
43-
if (obj != null && obj instanceof CompositeCacheKey) {
44-
CompositeCacheKey s = (CompositeCacheKey) obj;
45-
return parserName.equals(s.parserName) && userAgent.equals(s.userAgent);
43+
if (obj instanceof CompositeCacheKey cck) {
44+
return parserName.equals(cck.parserName) && userAgent.equals(cck.userAgent);
4645
}
4746
return false;
4847
}

modules/legacy-geo/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Side Public License, v 1.
77
*/
88

9+
import org.elasticsearch.gradle.internal.info.BuildParams
10+
911
apply plugin: 'elasticsearch.internal-cluster-test'
1012
apply plugin: 'nebula.optional-base'
1113

@@ -21,6 +23,12 @@ dependencies {
2123
testImplementation project(":test:framework")
2224
}
2325

26+
if (BuildParams.isSnapshotBuild() == false) {
27+
tasks.named("test").configure {
28+
systemProperty 'es.index_mode_feature_flag_registered', 'true'
29+
}
30+
}
31+
2432
tasks.named("thirdPartyAudit").configure {
2533
ignoreMissingClasses(
2634

qa/multi-cluster-search/src/test/resources/rest-api-spec/test/multi_cluster/100_tsdb.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ setup:
6060
---
6161
teardown:
6262
- skip:
63-
version: " - 7.99.99"
64-
reason: introduced in 8.0.0
63+
version: " - 8.0.99"
64+
reason: introduced in 8.1.0
6565

6666
- do:
6767
indices.delete:
@@ -71,8 +71,8 @@ teardown:
7171
---
7272
aggregate tsid:
7373
- skip:
74-
version: " - 7.99.99"
75-
reason: introduced in 8.0.0
74+
version: " - 8.0.99"
75+
reason: introduced in 8.1.0
7676

7777
- do:
7878
search:

0 commit comments

Comments
 (0)