Skip to content

Commit 009fded

Browse files
committed
Merge remote-tracking branch 'es/main' into trim_seqno_points
2 parents ba86d5e + 444d148 commit 009fded

File tree

36 files changed

+3579
-155
lines changed

36 files changed

+3579
-155
lines changed

build-tools/src/integTest/groovy/org/elasticsearch/gradle/test/TestBuildInfoPluginFuncTest.groovy

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import com.fasterxml.jackson.databind.ObjectMapper
55
import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
66
import org.gradle.testkit.runner.TaskOutcome
77

8-
import java.nio.file.Path
9-
108
class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
11-
def "works"() {
9+
def "basic functionality"() {
1210
given:
1311
file("src/main/java/com/example/Example.java") << """
1412
package com.example;
@@ -54,12 +52,70 @@ class TestBuildInfoPluginFuncTest extends AbstractGradleFuncTest {
5452

5553
def location = Map.of(
5654
"module", "com.example",
57-
"representative_class", Path.of("com", "example", "Example.class").toString()
55+
"representative_class", "com/example/Example.class"
5856
)
5957
def expectedOutput = Map.of(
6058
"component", "example-component",
6159
"locations", List.of(location)
6260
)
6361
new ObjectMapper().readValue(output, Map.class) == expectedOutput
6462
}
63+
64+
def "dependencies"() {
65+
buildFile << """
66+
import org.elasticsearch.gradle.plugin.GenerateTestBuildInfoTask;
67+
68+
plugins {
69+
id 'java'
70+
id 'elasticsearch.test-build-info'
71+
}
72+
73+
repositories {
74+
mavenCentral()
75+
}
76+
77+
dependencies {
78+
// We pin to specific versions here because they are known to have the properties we want to test.
79+
// We're not actually running this code.
80+
implementation "org.ow2.asm:asm:9.7.1" // has module-info.class
81+
implementation "junit:junit:4.13" // has Automatic-Module-Name, and brings in hamcrest which does not
82+
}
83+
84+
tasks.withType(GenerateTestBuildInfoTask.class) {
85+
componentName = 'example-component'
86+
outputFile = new File('build/generated-build-info/plugin-test-build-info.json')
87+
}
88+
"""
89+
90+
when:
91+
def result = gradleRunner('generateTestBuildInfo').build()
92+
def task = result.task(":generateTestBuildInfo")
93+
94+
95+
then:
96+
task.outcome == TaskOutcome.SUCCESS
97+
98+
def output = file("build/generated-build-info/plugin-test-build-info.json")
99+
output.exists() == true
100+
101+
def locationFromModuleInfo = Map.of(
102+
"module", "org.objectweb.asm",
103+
"representative_class", 'org/objectweb/asm/AnnotationVisitor.class'
104+
)
105+
def locationFromManifest = Map.of(
106+
"module", "junit",
107+
"representative_class", 'junit/textui/TestRunner.class'
108+
)
109+
def locationFromJarFileName = Map.of(
110+
"module", "hamcrest.core",
111+
"representative_class", 'org/hamcrest/BaseDescription.class'
112+
)
113+
def expectedOutput = Map.of(
114+
"component", "example-component",
115+
"locations", List.of(locationFromModuleInfo, locationFromManifest, locationFromJarFileName)
116+
)
117+
118+
def value = new ObjectMapper().readValue(output, Map.class)
119+
value == expectedOutput
120+
}
65121
}

build-tools/src/main/java/org/elasticsearch/gradle/plugin/GenerateTestBuildInfoTask.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import java.nio.file.attribute.BasicFileAttributes;
4242
import java.security.CodeSource;
4343
import java.util.ArrayList;
44-
import java.util.Arrays;
44+
import java.util.Comparator;
4545
import java.util.List;
4646
import java.util.jar.JarEntry;
4747
import java.util.jar.JarFile;
@@ -209,17 +209,16 @@ private String extractModuleNameFromJar(File file, JarFile jarFile) throws IOExc
209209
* @return a {@link StringBuilder} with the {@code META-INF/versions/<version number>} if it exists; otherwise null
210210
*/
211211
private static StringBuilder versionDirectoryIfExists(JarFile jarFile) {
212+
Comparator<Integer> numericOrder = Integer::compareTo;
212213
List<Integer> versions = jarFile.stream()
213214
.filter(je -> je.getName().startsWith(META_INF_VERSIONS_PREFIX) && je.getName().endsWith("/module-info.class"))
214215
.map(
215216
je -> Integer.parseInt(
216217
je.getName().substring(META_INF_VERSIONS_PREFIX.length(), je.getName().length() - META_INF_VERSIONS_PREFIX.length())
217218
)
218219
)
220+
.sorted(numericOrder.reversed())
219221
.toList();
220-
versions = new ArrayList<>(versions);
221-
versions.sort(Integer::compareTo);
222-
versions = versions.reversed();
223222
int major = Runtime.version().feature();
224223
StringBuilder path = new StringBuilder(META_INF_VERSIONS_PREFIX);
225224
for (int version : versions) {
@@ -300,7 +299,10 @@ private String extractClassNameFromDirectory(File dir) throws IOException {
300299
public @NotNull FileVisitResult visitFile(@NotNull Path candidate, @NotNull BasicFileAttributes attrs) {
301300
String name = candidate.getFileName().toString(); // Just the part after the last dir separator
302301
if (name.endsWith(".class") && (name.equals("module-info.class") || name.contains("$")) == false) {
303-
result = candidate.toAbsolutePath().toString().substring(dir.getAbsolutePath().length() + 1);
302+
result = candidate.toAbsolutePath()
303+
.toString()
304+
.substring(dir.getAbsolutePath().length() + 1)
305+
.replace(File.separatorChar, '/');
304306
return TERMINATE;
305307
} else {
306308
return CONTINUE;
@@ -316,20 +318,24 @@ private String extractClassNameFromDirectory(File dir) throws IOException {
316318
* if it exists or the preset one derived from the jar task
317319
*/
318320
private String extractModuleNameFromDirectory(File dir) throws IOException {
319-
List<File> files = new ArrayList<>(List.of(dir));
320-
while (files.isEmpty() == false) {
321-
File find = files.removeFirst();
322-
if (find.exists()) {
323-
if (find.getName().equals("module-info.class")) {
324-
try (InputStream inputStream = new FileInputStream(find)) {
325-
return extractModuleNameFromModuleInfo(inputStream);
321+
var visitor = new SimpleFileVisitor<Path>() {
322+
private String result = getModuleName().getOrNull();
323+
324+
@Override
325+
public @NotNull FileVisitResult visitFile(@NotNull Path candidate, @NotNull BasicFileAttributes attrs) throws IOException {
326+
String name = candidate.getFileName().toString(); // Just the part after the last dir separator
327+
if (name.equals("module-info.class")) {
328+
try (InputStream inputStream = new FileInputStream(candidate.toFile())) {
329+
result = extractModuleNameFromModuleInfo(inputStream);
330+
return TERMINATE;
326331
}
327-
} else if (find.isDirectory()) {
328-
files.addAll(Arrays.asList(find.listFiles()));
332+
} else {
333+
return CONTINUE;
329334
}
330335
}
331-
}
332-
return getModuleName().getOrNull();
336+
};
337+
Files.walkFileTree(dir.toPath(), visitor);
338+
return visitor.result;
333339
}
334340

335341
/**

docs/changelog/128259.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 128259
2+
summary: Added geometry validation for GEO types to exit early on invalid latitudes
3+
area: Geo
4+
type: bug
5+
issues:
6+
- 128234

docs/changelog/128263.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128263
2+
summary: Allow lookup join on mixed numeric fields
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/changelog/128320.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128320
2+
summary: Use new source loader when lower `docId` is accessed
3+
area: Codec
4+
type: bug
5+
issues: []

docs/reference/aggregations/search-aggregations-bucket-significantterms-aggregation.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ Like most design decisions, this is the basis of a trade-off in which we have ch
253253
The JLH score can be used as a significance score by adding the parameter
254254

255255
```js
256-
"jlh": {
257-
}
256+
"jlh": {
257+
}
258258
```
259259

260260
The scores are derived from the doc frequencies in *foreground* and *background* sets. The *absolute* change in popularity (foregroundPercent - backgroundPercent) would favor common terms whereas the *relative* change in popularity (foregroundPercent/ backgroundPercent) would favor rare terms. Rare vs common is essentially a precision vs recall balance and so the absolute and relative changes are multiplied to provide a sweet spot between precision and recall.
@@ -265,9 +265,9 @@ The scores are derived from the doc frequencies in *foreground* and *background*
265265
Mutual information as described in "Information Retrieval", Manning et al., Chapter 13.5.1 can be used as significance score by adding the parameter
266266

267267
```js
268-
"mutual_information": {
269-
"include_negatives": true
270-
}
268+
"mutual_information": {
269+
"include_negatives": true
270+
}
271271
```
272272

273273
Mutual information does not differentiate between terms that are descriptive for the subset or for documents outside the subset. The significant terms therefore can contain terms that appear more or less frequent in the subset than outside the subset. To filter out the terms that appear less often in the subset than in documents outside the subset, `include_negatives` can be set to `false`.
@@ -284,8 +284,8 @@ Per default, the assumption is that the documents in the bucket are also contain
284284
Chi square as described in "Information Retrieval", Manning et al., Chapter 13.5.2 can be used as significance score by adding the parameter
285285

286286
```js
287-
"chi_square": {
288-
}
287+
"chi_square": {
288+
}
289289
```
290290

291291
Chi square behaves like mutual information and can be configured with the same parameters `include_negatives` and `background_is_superset`.
@@ -296,8 +296,8 @@ Chi square behaves like mutual information and can be configured with the same p
296296
Google normalized distance as described in ["The Google Similarity Distance", Cilibrasi and Vitanyi, 2007](https://arxiv.org/pdf/cs/0412098v3.pdf) can be used as significance score by adding the parameter
297297

298298
```js
299-
"gnd": {
300-
}
299+
"gnd": {
300+
}
301301
```
302302

303303
`gnd` also accepts the `background_is_superset` parameter.
@@ -394,8 +394,8 @@ The benefit of this heuristic is that the scoring logic is simple to explain to
394394
It would be hard for a seasoned boxer to win a championship if the prize was awarded purely on the basis of percentage of fights won - by these rules a newcomer with only one fight under their belt would be impossible to beat. Multiple observations are typically required to reinforce a view so it is recommended in these cases to set both `min_doc_count` and `shard_min_doc_count` to a higher value such as 10 in order to filter out the low-frequency terms that otherwise take precedence.
395395

396396
```js
397-
"percentage": {
398-
}
397+
"percentage": {
398+
}
399399
```
400400

401401

@@ -413,11 +413,11 @@ If none of the above measures suits your usecase than another option is to imple
413413
Customized scores can be implemented via a script:
414414

415415
```js
416-
"script_heuristic": {
416+
"script_heuristic": {
417417
"script": {
418-
"lang": "painless",
419-
"source": "params._subset_freq/(params._superset_freq - params._subset_freq + 1)"
420-
}
418+
"lang": "painless",
419+
"source": "params._subset_freq/(params._superset_freq - params._subset_freq + 1)"
420+
}
421421
}
422422
```
423423

docs/reference/elasticsearch-plugins/discovery-azure-classic-scale.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mapped_pages:
33
- https://www.elastic.co/guide/en/elasticsearch/plugins/current/discovery-azure-classic-scale.html
44
---
55

6-
# Scaling out! [discovery-azure-classic-scale]
6+
# Scaling out [discovery-azure-classic-scale]
77

88
You need first to create an image of your previous machine. Disconnect from your machine and run locally the following commands:
99

muted-tests.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,21 @@ tests:
474474
- class: org.elasticsearch.packaging.test.TemporaryDirectoryConfigTests
475475
method: test21AcceptsCustomPathInDocker
476476
issue: https://github.com/elastic/elasticsearch/issues/128114
477-
- class: org.elasticsearch.reservedstate.service.FileSettingsServiceIT
478-
method: testSymlinkUpdateTriggerReload
479-
issue: https://github.com/elastic/elasticsearch/issues/128369
477+
- class: org.elasticsearch.xpack.esql.qa.single_node.PushQueriesIT
478+
method: testEqualityAndOther {semantic_text}
479+
issue: https://github.com/elastic/elasticsearch/issues/128414
480+
- class: org.elasticsearch.xpack.ml.integration.InferenceIngestIT
481+
method: testPipelineIngestWithModelAliases
482+
issue: https://github.com/elastic/elasticsearch/issues/128417
483+
- class: org.elasticsearch.xpack.search.CrossClusterAsyncSearchIT
484+
method: testCCSClusterDetailsWhereAllShardsSkippedInCanMatch
485+
issue: https://github.com/elastic/elasticsearch/issues/128418
486+
- class: org.elasticsearch.xpack.esql.action.ForkIT
487+
method: testProfile
488+
issue: https://github.com/elastic/elasticsearch/issues/128377
489+
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryWithFiltersIT
490+
method: testTimestampFilterFromQuery
491+
issue: https://github.com/elastic/elasticsearch/issues/127332
480492

481493
# Examples:
482494
#

0 commit comments

Comments
 (0)