Skip to content

Commit f665d9f

Browse files
Merge branch 'main' into ml-allow-null-function-name
2 parents db40e3b + 5447909 commit f665d9f

File tree

166 files changed

+4116
-719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+4116
-719
lines changed

docs/changelog/125479.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 125479
2+
summary: ES|QL - Allow full text functions to be used in STATS
3+
area: ES|QL
4+
type: enhancement
5+
issues:
6+
- 125481

docs/changelog/127355.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127355
2+
summary: '`text ==` and `text !=` pushdown'
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/changelog/127877.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127877
2+
summary: Check hidden frames in entitlements
3+
area: Infra/Core
4+
type: bug
5+
issues: []

docs/changelog/127921.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127921
2+
summary: "[9.x] Revert \"Enable madvise by default for all builds\""
3+
area: Vector Search
4+
type: bug
5+
issues: []

docs/changelog/127949.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127949
2+
summary: Ensure ordinal builder emit ordinal blocks
3+
area: ES|QL
4+
type: bug
5+
issues: []

libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/Util.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
package org.elasticsearch.entitlement.bridge;
1111

1212
import java.util.Optional;
13+
import java.util.Set;
1314

1415
import static java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE;
16+
import static java.lang.StackWalker.Option.SHOW_HIDDEN_FRAMES;
1517

1618
public class Util {
1719
/**
@@ -23,6 +25,8 @@ public class Util {
2325
public static final Class<?> NO_CLASS = new Object() {
2426
}.getClass();
2527

28+
private static final Set<String> skipInternalPackages = Set.of("java.lang.invoke", "java.lang.reflect", "jdk.internal.reflect");
29+
2630
/**
2731
* Why would we write this instead of using {@link StackWalker#getCallerClass()}?
2832
* Because that method throws {@link IllegalCallerException} if called from the "outermost frame",
@@ -32,9 +36,10 @@ public class Util {
3236
*/
3337
@SuppressWarnings("unused") // Called reflectively from InstrumenterImpl
3438
public static Class<?> getCallerClass() {
35-
Optional<Class<?>> callerClassIfAny = StackWalker.getInstance(RETAIN_CLASS_REFERENCE)
39+
Optional<Class<?>> callerClassIfAny = StackWalker.getInstance(Set.of(RETAIN_CLASS_REFERENCE, SHOW_HIDDEN_FRAMES))
3640
.walk(
3741
frames -> frames.skip(2) // Skip this method and its caller
42+
.filter(frame -> skipInternalPackages.contains(frame.getDeclaringClass().getPackageName()) == false)
3843
.findFirst()
3944
.map(StackWalker.StackFrame::getDeclaringClass)
4045
);

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/entitlements/FilesEntitlement.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ private static BaseDir parseBaseDir(String baseDir) {
182182
case "config" -> BaseDir.CONFIG;
183183
case "data" -> BaseDir.DATA;
184184
case "home" -> BaseDir.USER_HOME;
185-
// NOTE: shared_repo is _not_ accessible to policy files, only internally
185+
// it would be nice to limit this to just ES modules, but we don't have a way to plumb that through to here
186+
// however, we still don't document in the error case below that shared_repo is valid
187+
case "shared_repo" -> BaseDir.SHARED_REPO;
186188
default -> throw new PolicyValidationException(
187189
"invalid relative directory: " + baseDir + ", valid values: [config, data, home]"
188190
);

server/src/main/java/org/elasticsearch/common/text/Text.java renamed to libs/x-content/src/main/java/org/elasticsearch/xcontent/Text.java

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,17 @@
66
* your election, the "Elastic License 2.0", the "GNU Affero General Public
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
9-
package org.elasticsearch.common.text;
10-
11-
import org.apache.lucene.util.BytesRef;
12-
import org.elasticsearch.common.bytes.BytesArray;
13-
import org.elasticsearch.common.bytes.BytesReference;
14-
import org.elasticsearch.xcontent.ToXContentFragment;
15-
import org.elasticsearch.xcontent.XContentBuilder;
9+
package org.elasticsearch.xcontent;
1610

1711
import java.io.IOException;
12+
import java.nio.ByteBuffer;
1813
import java.nio.charset.StandardCharsets;
1914

2015
/**
21-
* Both {@link String} and {@link BytesReference} representation of the text. Starts with one of those, and if
16+
* Both {@link String} and {@link ByteBuffer} representation of the text. Starts with one of those, and if
2217
* the other is requests, caches the other one in a local reference so no additional conversion will be needed.
2318
*/
24-
public final class Text implements Comparable<Text>, ToXContentFragment {
19+
public final class Text implements XContentString, Comparable<Text>, ToXContentFragment {
2520

2621
public static final Text[] EMPTY_ARRAY = new Text[0];
2722

@@ -36,31 +31,43 @@ public static Text[] convertFromStringArray(String[] strings) {
3631
return texts;
3732
}
3833

39-
private BytesReference bytes;
34+
private ByteBuffer bytes;
4035
private String text;
4136
private int hash;
37+
private int stringLength = -1;
38+
39+
/**
40+
* Construct a Text from a UTF-8 encoded ByteBuffer. Since no string length is specified, {@link #stringLength()}
41+
* will perform a string conversion to measure the string length.
42+
*/
43+
public Text(ByteBuffer bytes) {
44+
this.bytes = bytes;
45+
}
4246

43-
public Text(BytesReference bytes) {
47+
/**
48+
* Construct a Text from a UTF-8 encoded ByteBuffer and an explicit string length. Used to avoid string conversion
49+
* in {@link #stringLength()}.
50+
*/
51+
public Text(ByteBuffer bytes, int stringLength) {
4452
this.bytes = bytes;
53+
this.stringLength = stringLength;
4554
}
4655

4756
public Text(String text) {
4857
this.text = text;
4958
}
5059

5160
/**
52-
* Whether a {@link BytesReference} view of the data is already materialized.
61+
* Whether a {@link ByteBuffer} view of the data is already materialized.
5362
*/
5463
public boolean hasBytes() {
5564
return bytes != null;
5665
}
5766

58-
/**
59-
* Returns a {@link BytesReference} view of the data.
60-
*/
61-
public BytesReference bytes() {
67+
@Override
68+
public ByteBuffer bytes() {
6269
if (bytes == null) {
63-
bytes = new BytesArray(text.getBytes(StandardCharsets.UTF_8));
70+
bytes = StandardCharsets.UTF_8.encode(text);
6471
}
6572
return bytes;
6673
}
@@ -72,11 +79,20 @@ public boolean hasString() {
7279
return text != null;
7380
}
7481

75-
/**
76-
* Returns a {@link String} view of the data.
77-
*/
82+
@Override
7883
public String string() {
79-
return text == null ? bytes.utf8ToString() : text;
84+
if (text == null) {
85+
text = StandardCharsets.UTF_8.decode(bytes).toString();
86+
}
87+
return text;
88+
}
89+
90+
@Override
91+
public int stringLength() {
92+
if (stringLength < 0) {
93+
stringLength = string().length();
94+
}
95+
return stringLength;
8096
}
8197

8298
@Override
@@ -115,8 +131,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
115131
} else {
116132
// TODO: TextBytesOptimization we can use a buffer here to convert it? maybe add a
117133
// request to jackson to support InputStream as well?
118-
BytesRef br = this.bytes().toBytesRef();
119-
return builder.utf8Value(br.bytes, br.offset, br.length);
134+
assert bytes.hasArray();
135+
return builder.utf8Value(bytes.array(), bytes.arrayOffset() + bytes.position(), bytes.remaining());
120136
}
121137
}
122138
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.xcontent;
11+
12+
import java.nio.ByteBuffer;
13+
14+
public interface XContentString {
15+
/**
16+
* Returns a {@link String} view of the data.
17+
*/
18+
String string();
19+
20+
/**
21+
* Returns a UTF8-encoded {@link ByteBuffer} view of the data.
22+
*/
23+
ByteBuffer bytes();
24+
25+
/**
26+
* Returns the number of characters in the represented string.
27+
*/
28+
int stringLength();
29+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
org.elasticsearch.repository.url:
2+
- outbound_network
3+
- files:
4+
- relative_path: .
5+
relative_to: shared_repo
6+
mode: read
17
org.apache.httpcomponents.httpclient:
28
- outbound_network # for URLHttpClient

0 commit comments

Comments
 (0)