Skip to content

Commit 38a58cd

Browse files
committed
Merge remote-tracking branch 'upstream/main' into flash1293/date-parsing-settings
2 parents f3932ca + 944b9b6 commit 38a58cd

File tree

133 files changed

+3349
-403
lines changed

Some content is hidden

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

133 files changed

+3349
-403
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionModuleCheckTaskProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class InternalDistributionModuleCheckTaskProvider {
5353
"org.elasticsearch.base",
5454
"org.elasticsearch.cli",
5555
"org.elasticsearch.entitlement",
56+
"org.elasticsearch.exponentialhistogram",
5657
"org.elasticsearch.geo",
5758
"org.elasticsearch.grok",
5859
"org.elasticsearch.logging",

docs/changelog/135961.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135961
2+
summary: Late materialization of dimension fields in time-series
3+
area: TSDB
4+
type: enhancement
5+
issues: []

libs/exponential-histogram/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ dependencies {
1717
api project(':libs:x-content')
1818
api "org.apache.lucene:lucene-core:${versions.lucene}"
1919

20-
testImplementation(project(":test:framework"))
20+
testImplementation(project(":test:framework")) {
21+
exclude group: 'org.elasticsearch', module: 'exponential-histogram'
22+
}
2123
testImplementation('ch.obermuhlner:big-math:2.3.2')
2224
testImplementation('org.apache.commons:commons-math3:3.6.1')
2325
testImplementation project(':libs:x-content:impl')
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
module org.elasticsearch.exponentialhistogram {
21+
requires org.elasticsearch.xcontent;
22+
requires org.apache.lucene.core;
23+
requires org.elasticsearch.base;
24+
25+
exports org.elasticsearch.exponentialhistogram;
26+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static ReleasableExponentialHistogram create(int maxBucketCount, ExponentialHist
270270
static ReleasableExponentialHistogram merge(
271271
int maxBucketCount,
272272
ExponentialHistogramCircuitBreaker breaker,
273-
Iterator<ExponentialHistogram> histograms
273+
Iterator<? extends ExponentialHistogram> histograms
274274
) {
275275
try (ExponentialHistogramMerger merger = ExponentialHistogramMerger.create(maxBucketCount, breaker)) {
276276
while (histograms.hasNext()) {

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ private ExponentialHistogramMerger(int bucketLimit, int maxScale, ExponentialHis
8989
downscaleStats = new DownscaleStats();
9090
}
9191

92-
static ExponentialHistogramMerger createForTesting(int bucketLimit, int maxScale, ExponentialHistogramCircuitBreaker circuitBreaker) {
92+
public static ExponentialHistogramMerger createWithMaxScale(
93+
int bucketLimit,
94+
int maxScale,
95+
ExponentialHistogramCircuitBreaker circuitBreaker
96+
) {
9397
circuitBreaker.adjustBreaker(BASE_SIZE);
9498
return new ExponentialHistogramMerger(bucketLimit, maxScale, circuitBreaker);
9599
}
@@ -137,6 +141,19 @@ public ReleasableExponentialHistogram getAndClear() {
137141
return retVal;
138142
}
139143

144+
/**
145+
* Gets the current merged histogram without clearing this merger.
146+
* Note that the ownership of the returned histogram remains with this merger,
147+
* so the caller must not close it.
148+
* The returned histogram is only valid until the next call to {@link #add(ExponentialHistogram)}, or until the merger is closed.
149+
*
150+
* @return the current merged histogram
151+
*/
152+
public ExponentialHistogram get() {
153+
assert closed == false : "ExponentialHistogramMerger already closed";
154+
return (result == null) ? ExponentialHistogram.empty() : result;
155+
}
156+
140157
// This algorithm is very efficient if B has roughly as many buckets as A.
141158
// However, if B is much smaller we still have to iterate over all buckets of A.
142159
// This can be optimized by buffering the buckets of small histograms and only merging them when we have enough buckets.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public final class ZeroBucket {
6060
*/
6161
private double realThreshold;
6262

63+
/**
64+
* True if the zero threshold was created from an index/scale pair, false if it was created from a real-valued threshold.
65+
*/
66+
private final boolean isIndexBased;
67+
6368
private final long count;
6469
// A singleton for an empty zero bucket with the smallest possible threshold.
6570
private static final ZeroBucket MINIMAL_EMPTY = new ZeroBucket(MIN_INDEX, MIN_SCALE, 0);
@@ -70,6 +75,7 @@ private ZeroBucket(double zeroThreshold, long count) {
7075
this.scale = MAX_SCALE;
7176
this.realThreshold = zeroThreshold;
7277
this.count = count;
78+
this.isIndexBased = false;
7379
}
7480

7581
private ZeroBucket(long index, int scale, long count) {
@@ -79,12 +85,14 @@ private ZeroBucket(long index, int scale, long count) {
7985
this.scale = scale;
8086
this.realThreshold = Double.NaN; // compute lazily when needed
8187
this.count = count;
88+
this.isIndexBased = true;
8289
}
8390

8491
private ZeroBucket(ZeroBucket toCopy, long newCount) {
8592
this.realThreshold = toCopy.realThreshold;
8693
this.index = toCopy.index;
8794
this.scale = toCopy.scale;
95+
this.isIndexBased = toCopy.isIndexBased;
8896
this.count = newCount;
8997
}
9098

@@ -163,6 +171,13 @@ public long count() {
163171
return count;
164172
}
165173

174+
/**
175+
* @return True if the zero threshold was created from an index/scale pair, false if it was created from a real-valued threshold.
176+
*/
177+
public boolean isIndexBased() {
178+
return isIndexBased;
179+
}
180+
166181
/**
167182
* Merges this zero bucket with another one.
168183
* <ul>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
public class ExponentialHistogramMergerTests extends ExponentialHistogramTestCase {
4444

4545
public void testZeroThresholdCollapsesOverlappingBuckets() {
46-
4746
ExponentialHistogram first = createAutoReleasedHistogram(b -> b.zeroBucket(ZeroBucket.create(2.0001, 10)));
4847

4948
ExponentialHistogram second = createAutoReleasedHistogram(
@@ -60,6 +59,7 @@ public void testZeroThresholdCollapsesOverlappingBuckets() {
6059

6160
assertThat(mergeResult.zeroBucket().zeroThreshold(), equalTo(4.0));
6261
assertThat(mergeResult.zeroBucket().count(), equalTo(14L));
62+
assertThat(mergeResult.zeroBucket().isIndexBased(), equalTo(true));
6363

6464
// only the (4, 8] bucket should be left
6565
assertThat(mergeResult.scale(), equalTo(0));
@@ -82,6 +82,7 @@ public void testZeroThresholdCollapsesOverlappingBuckets() {
8282
mergeResult = mergeWithMinimumScale(100, 0, mergeResult, third);
8383
assertThat(mergeResult.zeroBucket().zeroThreshold(), closeTo(45.0, 0.000001));
8484
assertThat(mergeResult.zeroBucket().count(), equalTo(1L + 14L + 42L + 7L));
85+
assertThat(mergeResult.zeroBucket().isIndexBased(), equalTo(false));
8586
assertThat(mergeResult.positiveBuckets().iterator().hasNext(), equalTo(false));
8687
assertThat(mergeResult.negativeBuckets().iterator().hasNext(), equalTo(false));
8788
}
@@ -241,7 +242,7 @@ private void assertBucketsEqual(ExponentialHistogram.Buckets bucketsA, Exponenti
241242
}
242243

243244
private ExponentialHistogram mergeWithMinimumScale(int bucketCount, int scale, ExponentialHistogram... histograms) {
244-
try (ExponentialHistogramMerger merger = ExponentialHistogramMerger.createForTesting(bucketCount, scale, breaker())) {
245+
try (ExponentialHistogramMerger merger = ExponentialHistogramMerger.createWithMaxScale(bucketCount, scale, breaker())) {
245246
Arrays.stream(histograms).forEach(merger::add);
246247
ReleasableExponentialHistogram result = merger.getAndClear();
247248
autoReleaseOnTestEnd(result);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public void testMinimalBucketHasZeroThreshold() {
3333
public void testExactThresholdPreserved() {
3434
ZeroBucket bucket = ZeroBucket.create(3.0, 10);
3535
assertThat(bucket.zeroThreshold(), equalTo(3.0));
36+
assertThat(bucket.isIndexBased(), equalTo(false));
3637
}
3738

3839
public void testMergingPreservesExactThreshold() {
@@ -41,6 +42,7 @@ public void testMergingPreservesExactThreshold() {
4142
ZeroBucket merged = bucketA.merge(bucketB);
4243
assertThat(merged.zeroThreshold(), equalTo(3.5));
4344
assertThat(merged.count(), equalTo(30L));
45+
assertThat(merged.isIndexBased(), equalTo(false));
4446
}
4547

4648
public void testBucketCollapsingPreservesExactThreshold() {
@@ -56,6 +58,7 @@ public void testBucketCollapsingPreservesExactThreshold() {
5658
assertThat(iterator.hasNext(), equalTo(false));
5759
assertThat(merged.zeroThreshold(), equalTo(3.0));
5860
assertThat(merged.count(), equalTo(52L));
61+
assertThat(merged.isIndexBased(), equalTo(false));
5962
}
6063

6164
public void testHashCodeEquality() {

muted-tests.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,6 @@ tests:
510510
- class: org.elasticsearch.xpack.esql.ccq.AllSupportedFieldsIT
511511
method: testFetchDenseVector {pref=null mode=time_series}
512512
issue: https://github.com/elastic/elasticsearch/issues/135762
513-
- class: org.elasticsearch.xpack.logsdb.qa.BulkDynamicMappingChallengeRestIT
514-
method: testMatchAllQuery
515-
issue: https://github.com/elastic/elasticsearch/issues/135820
516513
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryWithPartialResultsIT
517514
method: testOneRemoteClusterPartial
518515
issue: https://github.com/elastic/elasticsearch/issues/124055
@@ -522,9 +519,6 @@ tests:
522519
- class: org.elasticsearch.xpack.ml.integration.RegressionIT
523520
method: testAliasFields
524521
issue: https://github.com/elastic/elasticsearch/issues/135996
525-
- class: org.elasticsearch.xpack.logsdb.qa.BulkDynamicMappingChallengeRestIT
526-
method: testHistogramAggregation
527-
issue: https://github.com/elastic/elasticsearch/issues/136002
528522
- class: org.elasticsearch.xpack.security.authz.microsoft.MicrosoftGraphAuthzPluginIT
529523
method: testConcurrentAuthentication
530524
issue: https://github.com/elastic/elasticsearch/issues/135777
@@ -591,6 +585,9 @@ tests:
591585
- class: org.elasticsearch.xpack.downsample.ILMDownsampleDisruptionIT
592586
method: testILMDownsampleRollingRestart
593587
issue: https://github.com/elastic/elasticsearch/issues/136585
588+
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
589+
method: testManyConcat
590+
issue: https://github.com/elastic/elasticsearch/issues/136728
594591

595592
# Examples:
596593
#

0 commit comments

Comments
 (0)