Skip to content

Commit 23731f3

Browse files
committed
Merge remote-tracking branch 'origin/main' into otlp-tsdb-empty-endpoint
2 parents 3526993 + 5f92b97 commit 23731f3

File tree

57 files changed

+1278
-355
lines changed

Some content is hidden

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

57 files changed

+1278
-355
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/exponentialhistogram/ExponentialHistogramMergeBench.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private ExponentialHistogram asCompressedHistogram(ExponentialHistogram histogra
130130
CompressedExponentialHistogram.writeHistogramBytes(histoBytes, histogram.scale(), negativeBuckets, positiveBuckets);
131131
CompressedExponentialHistogram result = new CompressedExponentialHistogram();
132132
BytesRef data = histoBytes.bytes().toBytesRef();
133-
result.reset(histogram.zeroBucket().zeroThreshold(), totalCount, data);
133+
result.reset(histogram.zeroBucket().zeroThreshold(), totalCount, histogram.sum(), data);
134134
return result;
135135
} catch (IOException e) {
136136
throw new RuntimeException(e);

docs/changelog/133397.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 133397
2+
summary: Push down loading of singleton dense double based field types to the …
3+
area: "Codec"
4+
type: enhancement
5+
issues: []

docs/changelog/133601.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pr: 133601
2+
summary: Fix bug in topn
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 133600
7+
- 133574
8+
- 133607

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ public interface EntitlementChecker {
771771

772772
void check$java_io_File$createNewFile(Class<?> callerClass, File file);
773773

774+
void check$java_io_File$$createTempFile(Class<?> callerClass, String prefix, String suffix);
775+
774776
void check$java_io_File$$createTempFile(Class<?> callerClass, String prefix, String suffix, File directory);
775777

776778
void check$java_io_File$delete(Class<?> callerClass, File file);

libs/entitlement/qa/entitlement-test-plugin/src/main/java/org/elasticsearch/entitlement/qa/test/FileCheckActions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ static void fileCreateTempFile() throws IOException {
9797
File.createTempFile("prefix", "suffix", readWriteDir().toFile());
9898
}
9999

100+
@EntitlementTest(expectedAccess = ALWAYS_ALLOWED)
101+
static void fileCreateTempFileSystemTempDirectory() throws IOException {
102+
File.createTempFile("prefix", "suffix");
103+
}
104+
105+
@EntitlementTest(expectedAccess = ALWAYS_ALLOWED)
106+
static void fileCreateTempFileNullDirectory() throws IOException {
107+
// null directory = system temp directory
108+
File.createTempFile("prefix", "suffix", null);
109+
}
110+
100111
@EntitlementTest(expectedAccess = PLUGINS)
101112
static void fileDelete() throws IOException {
102113
var toDelete = EntitledActions.createTempFileForWrite();

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/ElasticsearchEntitlementChecker.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,9 +1489,20 @@ public void checkSelectorProviderOpenSocketChannel(Class<?> callerClass, Selecto
14891489
policyChecker.checkFileWrite(callerClass, file);
14901490
}
14911491

1492+
@Override
1493+
public void check$java_io_File$$createTempFile(Class<?> callerClass, String prefix, String suffix) {
1494+
policyChecker.checkCreateTempFile(callerClass);
1495+
}
1496+
14921497
@Override
14931498
public void check$java_io_File$$createTempFile(Class<?> callerClass, String prefix, String suffix, File directory) {
1494-
policyChecker.checkFileWrite(callerClass, directory);
1499+
// A null value for the directory parameter means using the temp directory (java.io.tmpdir,
1500+
// aka org.elasticsearch.env.Environment#tmpDir, aka PathLookup#TEMP).
1501+
if (directory == null) {
1502+
policyChecker.checkCreateTempFile(callerClass);
1503+
} else {
1504+
policyChecker.checkFileWrite(callerClass, directory);
1505+
}
14951506
}
14961507

14971508
@Override

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ public Buckets negativeBuckets() {
7777
return EmptyBuckets.INSTANCE;
7878
}
7979

80+
@Override
81+
public double sum() {
82+
return 0;
83+
}
84+
8085
@Override
8186
public long ramBytesUsed() {
8287
return 0;

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
*/
4848
public interface ExponentialHistogram extends Accountable {
4949

50-
// TODO(b/128622): support min/max/sum/count storage and merging.
50+
// TODO(b/128622): support min/max storage and merging.
5151
// TODO(b/128622): Add special positive and negative infinity buckets
5252
// to allow representation of explicit bucket histograms with open boundaries.
5353

@@ -93,6 +93,15 @@ public interface ExponentialHistogram extends Accountable {
9393
*/
9494
Buckets negativeBuckets();
9595

96+
/**
97+
* Returns the sum of all values represented by this histogram.
98+
* Note that even if histograms are cumulative, the sum is not guaranteed to be monotonically increasing,
99+
* because histograms support negative values.
100+
*
101+
* @return the sum, guaranteed to be zero for empty histograms
102+
*/
103+
double sum();
104+
96105
/**
97106
* Represents a bucket range of an {@link ExponentialHistogram}, either the positive or the negative range.
98107
*/

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ private void mergeValuesToHistogram() {
123123
}
124124

125125
valueBuffer.reset();
126+
valueBuffer.setSum(rawValuesSum());
126127
int scale = valueBuffer.scale();
127128

128129
// Buckets must be provided with their indices in ascending order.
@@ -161,6 +162,14 @@ private void mergeValuesToHistogram() {
161162
valueCount = 0;
162163
}
163164

165+
private double rawValuesSum() {
166+
double sum = 0;
167+
for (int i = 0; i < valueCount; i++) {
168+
sum += rawValueBuffer[i];
169+
}
170+
return sum;
171+
}
172+
164173
private static long estimateBaseSize(int numBuckets) {
165174
return SHALLOW_SIZE + RamEstimationUtil.estimateDoubleArray(numBuckets);
166175
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public void add(ExponentialHistogram toAdd) {
150150
buffer = FixedCapacityExponentialHistogram.create(bucketLimit, circuitBreaker);
151151
}
152152
buffer.setZeroBucket(zeroBucket);
153+
buffer.setSum(a.sum() + b.sum());
153154

154155
// We attempt to bring everything to the scale of A.
155156
// This might involve increasing the scale for B, which would increase its indices.

0 commit comments

Comments
 (0)