Skip to content

Commit dc80a35

Browse files
Merge branch 'main' into esql/stats_lookup_no_local_idx_test
2 parents a1e95bd + 258f7fe commit dc80a35

File tree

37 files changed

+1002
-1172
lines changed

37 files changed

+1002
-1172
lines changed

.buildkite/pipelines/periodic-fwc.template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
steps:
2-
- label: "{{matrix.FWC_VERSION}}" / fwc
2+
- label: "{{matrix.FWC_VERSION}} / fwc"
33
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
44
timeout_in_minutes: 300
55
agents:

.buildkite/pipelines/periodic-fwc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is auto-generated. See .buildkite/pipelines/periodic-fwc.template.yml
22
steps:
3-
- label: "{{matrix.FWC_VERSION}}" / fwc
3+
- label: "{{matrix.FWC_VERSION}} / fwc"
44
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
55
timeout_in_minutes: 300
66
agents:

distribution/docker/src/docker/dockerfiles/cloud_ess_fips/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Extract Elasticsearch artifact
2626
################################################################################
2727
28-
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:d9382de1615bfd6fe66348a9c80258c63fa311b1f583a607addde8ec5bf0f343 AS builder
28+
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:e5602c71dfc1c1d9009f7368615e8a25480aa1c2c6e61ef7c00ce130a40def17 AS builder
2929
3030
# Install required packages to extract the Elasticsearch distribution
3131
RUN <%= retry.loop(package_manager, "export DEBIAN_FRONTEND=noninteractive && ${package_manager} update && ${package_manager} update && ${package_manager} add --no-cache curl") %>
@@ -104,7 +104,7 @@ WORKDIR /usr/share/elasticsearch/config
104104
# Add entrypoint
105105
################################################################################
106106

107-
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:d9382de1615bfd6fe66348a9c80258c63fa311b1f583a607addde8ec5bf0f343
107+
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest@sha256:e5602c71dfc1c1d9009f7368615e8a25480aa1c2c6e61ef7c00ce130a40def17
108108

109109
RUN <%= retry.loop(package_manager,
110110
"export DEBIAN_FRONTEND=noninteractive && \n" +

distribution/docker/src/docker/dockerfiles/wolfi/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Extract Elasticsearch artifact
2626
################################################################################
2727
28-
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:4dbe94045c967ec89afcee3727cfb746820bd3f699bbbb621e529bde1ce122b1 AS builder
28+
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:bb3bb9491f564296956a879033da287961829c431fc8dc68222c2b60f9bfa052 AS builder
2929
3030
# Install required packages to extract the Elasticsearch distribution
3131
RUN <%= retry.loop(package_manager, "export DEBIAN_FRONTEND=noninteractive && ${package_manager} update && ${package_manager} update && ${package_manager} add --no-cache curl") %>
@@ -80,7 +80,7 @@ RUN sed -i -e 's/ES_DISTRIBUTION_TYPE=tar/ES_DISTRIBUTION_TYPE=docker/' bin/elas
8080
# Add entrypoint
8181
################################################################################
8282

83-
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:4dbe94045c967ec89afcee3727cfb746820bd3f699bbbb621e529bde1ce122b1
83+
FROM docker.elastic.co/wolfi/chainguard-base:latest@sha256:bb3bb9491f564296956a879033da287961829c431fc8dc68222c2b60f9bfa052
8484

8585
RUN <%= retry.loop(package_manager,
8686
"export DEBIAN_FRONTEND=noninteractive && \n" +

docs/reference/elasticsearch/mapping-reference/semantic-text.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,14 @@ inference data that `semantic_text` typically hides using `fields`.
530530
```console
531531
POST test-index/_search
532532
{
533-
"query": {
534-
"match": {
535-
"my_semantic_field": "Which country is Paris in?"
536-
},
537-
"fields": [
538-
"_inference_fields"
539-
]
533+
"query": {
534+
"match": {
535+
"my_semantic_field": "Which country is Paris in?"
540536
}
537+
},
538+
"fields": [
539+
"_inference_fields"
540+
]
541541
}
542542
```
543543

libs/exponential-histogram/src/main/java/org/elasticsearch/exponentialhistogram/ExponentialHistogram.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ static ExponentialHistogramBuilder builder(int scale, ExponentialHistogramCircui
216216
return new ExponentialHistogramBuilder(scale, breaker);
217217
}
218218

219+
/**
220+
* Create a builder for an exponential histogram, which is initialized to copy the given histogram.
221+
* @param toCopy the histogram to copy
222+
* @param breaker the circuit breaker to use
223+
* @return a new builder
224+
*/
225+
static ExponentialHistogramBuilder builder(ExponentialHistogram toCopy, ExponentialHistogramCircuitBreaker breaker) {
226+
return new ExponentialHistogramBuilder(toCopy, breaker);
227+
}
228+
219229
/**
220230
* Creates a histogram representing the distribution of the given values with at most the given number of buckets.
221231
* If the given {@code maxBucketCount} is greater than or equal to the number of values, the resulting histogram will have a

libs/exponential-histogram/src/main/java/org/elasticsearch/exponentialhistogram/ExponentialHistogramBuilder.java

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
/**
2929
* A builder for building a {@link ReleasableExponentialHistogram} directly from buckets.
30-
* Note that this class is not optimized regarding memory allocations, so it is not intended for high-throughput usage.
30+
* Note that this class is not optimized regarding memory allocations or performance, so it is not intended for high-throughput usage.
3131
*/
3232
public class ExponentialHistogramBuilder {
3333

3434
private final ExponentialHistogramCircuitBreaker breaker;
3535

36-
private final int scale;
36+
private int scale;
3737
private ZeroBucket zeroBucket = ZeroBucket.minimalEmpty();
3838
private Double sum;
3939
private Double min;
@@ -47,6 +47,29 @@ public class ExponentialHistogramBuilder {
4747
this.scale = scale;
4848
}
4949

50+
ExponentialHistogramBuilder(ExponentialHistogram toCopy, ExponentialHistogramCircuitBreaker breaker) {
51+
this(toCopy.scale(), breaker);
52+
zeroBucket(toCopy.zeroBucket());
53+
sum(toCopy.sum());
54+
min(toCopy.min());
55+
max(toCopy.max());
56+
BucketIterator negBuckets = toCopy.negativeBuckets().iterator();
57+
while (negBuckets.hasNext()) {
58+
setNegativeBucket(negBuckets.peekIndex(), negBuckets.peekCount());
59+
negBuckets.advance();
60+
}
61+
BucketIterator posBuckets = toCopy.positiveBuckets().iterator();
62+
while (posBuckets.hasNext()) {
63+
setPositiveBucket(posBuckets.peekIndex(), posBuckets.peekCount());
64+
posBuckets.advance();
65+
}
66+
}
67+
68+
public ExponentialHistogramBuilder scale(int scale) {
69+
this.scale = scale;
70+
return this;
71+
}
72+
5073
public ExponentialHistogramBuilder zeroBucket(ZeroBucket zeroBucket) {
5174
this.zeroBucket = zeroBucket;
5275
return this;
@@ -83,39 +106,33 @@ public ExponentialHistogramBuilder max(double max) {
83106
}
84107

85108
/**
86-
* Adds the given bucket to the positive buckets.
87-
* Buckets may be added in arbitrary order, but each bucket can only be added once.
109+
* Sets the given bucket of the positive buckets.
110+
* Buckets may be set in arbitrary order. If the bucket already exists, it will be replaced.
88111
*
89112
* @param index the index of the bucket
90113
* @param count the count of the bucket, must be at least 1
91114
* @return the builder
92115
*/
93-
public ExponentialHistogramBuilder addPositiveBucket(long index, long count) {
116+
public ExponentialHistogramBuilder setPositiveBucket(long index, long count) {
94117
if (count < 1) {
95118
throw new IllegalArgumentException("Bucket count must be at least 1");
96119
}
97-
if (positiveBuckets.containsKey(index)) {
98-
throw new IllegalArgumentException("Positive bucket already exists: " + index);
99-
}
100120
positiveBuckets.put(index, count);
101121
return this;
102122
}
103123

104124
/**
105-
* Adds the given bucket to the negative buckets.
106-
* Buckets may be added in arbitrary order, but each bucket can only be added once.
125+
* Sets the given bucket of the negative buckets.
126+
* Buckets may be set in arbitrary order. If the bucket already exists, it will be replaced.
107127
*
108128
* @param index the index of the bucket
109129
* @param count the count of the bucket, must be at least 1
110130
* @return the builder
111131
*/
112-
public ExponentialHistogramBuilder addNegativeBucket(long index, long count) {
132+
public ExponentialHistogramBuilder setNegativeBucket(long index, long count) {
113133
if (count < 1) {
114134
throw new IllegalArgumentException("Bucket count must be at least 1");
115135
}
116-
if (negativeBuckets.containsKey(index)) {
117-
throw new IllegalArgumentException("Negative bucket already exists: " + index);
118-
}
119136
negativeBuckets.put(index, count);
120137
return this;
121138
}
@@ -152,8 +169,6 @@ public ReleasableExponentialHistogram build() {
152169
Releasables.close(result);
153170
}
154171
}
155-
156-
// Create histogram
157172
return result;
158173
}
159174
}

libs/exponential-histogram/src/test/java/org/elasticsearch/exponentialhistogram/ExponentialHistogramBuilderTests.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727

2828
public class ExponentialHistogramBuilderTests extends ExponentialHistogramTestCase {
2929

30-
public void testBuildWithAllFieldsSet() {
30+
public void testBuildAndCopyWithAllFieldsSet() {
3131
ZeroBucket zeroBucket = ZeroBucket.create(1, 2);
3232
ExponentialHistogramBuilder builder = ExponentialHistogram.builder(3, breaker())
3333
.zeroBucket(zeroBucket)
3434
.sum(100.0)
3535
.min(1.0)
3636
.max(50.0)
37-
.addPositiveBucket(2, 10)
38-
.addPositiveBucket(0, 1)
39-
.addPositiveBucket(5, 2)
40-
.addNegativeBucket(-2, 5)
41-
.addNegativeBucket(1, 2);
37+
.setPositiveBucket(2, 10)
38+
.setPositiveBucket(0, 1)
39+
.setPositiveBucket(5, 2)
40+
.setNegativeBucket(-2, 5)
41+
.setNegativeBucket(1, 2);
4242

4343
try (ReleasableExponentialHistogram histogram = builder.build()) {
4444
assertThat(histogram.scale(), equalTo(3));
@@ -48,14 +48,19 @@ public void testBuildWithAllFieldsSet() {
4848
assertThat(histogram.max(), equalTo(50.0));
4949
assertBuckets(histogram.positiveBuckets(), List.of(0L, 2L, 5L), List.of(1L, 10L, 2L));
5050
assertBuckets(histogram.negativeBuckets(), List.of(-2L, 1L), List.of(5L, 2L));
51+
52+
try (ReleasableExponentialHistogram copy = ExponentialHistogram.builder(histogram, breaker()).build()) {
53+
assertThat(copy, equalTo(histogram));
54+
}
5155
}
56+
5257
}
5358

5459
public void testBuildWithEstimation() {
5560
ExponentialHistogramBuilder builder = ExponentialHistogram.builder(0, breaker())
56-
.addPositiveBucket(0, 1)
57-
.addPositiveBucket(1, 1)
58-
.addNegativeBucket(0, 4);
61+
.setPositiveBucket(0, 1)
62+
.setPositiveBucket(1, 1)
63+
.setNegativeBucket(0, 4);
5964

6065
try (ReleasableExponentialHistogram histogram = builder.build()) {
6166
assertThat(histogram.scale(), equalTo(0));
@@ -68,16 +73,16 @@ public void testBuildWithEstimation() {
6873
}
6974
}
7075

71-
public void testAddDuplicatePositiveBucketThrows() {
76+
public void testDuplicateBucketOverrides() {
7277
ExponentialHistogramBuilder builder = ExponentialHistogram.builder(0, breaker());
73-
builder.addPositiveBucket(1, 10);
74-
expectThrows(IllegalArgumentException.class, () -> builder.addPositiveBucket(1, 5));
75-
}
76-
77-
public void testAddDuplicateNegativeBucketThrows() {
78-
ExponentialHistogramBuilder builder = ExponentialHistogram.builder(0, breaker());
79-
builder.addNegativeBucket(-1, 10);
80-
expectThrows(IllegalArgumentException.class, () -> builder.addNegativeBucket(-1, 5));
78+
builder.setPositiveBucket(1, 10);
79+
builder.setNegativeBucket(2, 1);
80+
builder.setPositiveBucket(1, 100);
81+
builder.setNegativeBucket(2, 123);
82+
try (ReleasableExponentialHistogram histogram = builder.build()) {
83+
assertBuckets(histogram.positiveBuckets(), List.of(1L), List.of(100L));
84+
assertBuckets(histogram.negativeBuckets(), List.of(2L), List.of(123L));
85+
}
8186
}
8287

8388
private static void assertBuckets(ExponentialHistogram.Buckets buckets, List<Long> indices, List<Long> counts) {

0 commit comments

Comments
 (0)