Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentType;
import org.hamcrest.Matcher;
import org.junit.AssumptionViolatedException;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;

Expand All @@ -48,7 +46,6 @@
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notANumber;

public class ScaledFloatFieldMapperTests extends NumberFieldMapperTests {

Expand Down Expand Up @@ -382,7 +379,7 @@ public SyntheticSourceExample example(int maxValues) {
if (randomBoolean()) {
Value v = generateValue();
if (v.malformedOutput == null) {
return new SyntheticSourceExample(v.input, v.output, roundDocValues(v.output), this::mapping);
return new SyntheticSourceExample(v.input, v.output, this::mapping);
}
return new SyntheticSourceExample(v.input, v.malformedOutput, null, this::mapping);
}
Expand All @@ -396,9 +393,7 @@ public SyntheticSourceExample example(int maxValues) {
List<Object> outList = Stream.concat(outputFromDocValues.stream(), malformedOutput).toList();
Object out = outList.size() == 1 ? outList.get(0) : outList;

List<Double> outBlockList = outputFromDocValues.stream().map(this::roundDocValues).sorted().toList();
Object outBlock = outBlockList.size() == 1 ? outBlockList.get(0) : outBlockList;
return new SyntheticSourceExample(in, out, outBlock, this::mapping);
return new SyntheticSourceExample(in, out, this::mapping);
}

private record Value(Object input, Double output, Object malformedOutput) {}
Expand Down Expand Up @@ -442,16 +437,6 @@ private double round(double d) {
return decoded;
}

private double roundDocValues(double d) {
// Special case due to rounding, see implementation.
if (Math.abs(d) == Double.MAX_VALUE) {
return d;
}

long encoded = Math.round(d * scalingFactor);
return encoded * (1 / scalingFactor);
}

private void mapping(XContentBuilder b) throws IOException {
b.field("type", "scaled_float");
b.field("scaling_factor", scalingFactor);
Expand All @@ -475,14 +460,9 @@ public List<SyntheticSourceInvalidExample> invalidExample() throws IOException {
}
}

@Override
protected Function<Object, Object> loadBlockExpected() {
return v -> (Number) v;
}

@Override
protected Matcher<?> blockItemMatcher(Object expected) {
return "NaN".equals(expected) ? notANumber() : equalTo(expected);
protected BlockReaderSupport getSupportedReaders(MapperService mapper, String loaderFieldName) {
assumeTrue("Disabled, tested by ScaledFloatFieldBlockLoaderTests instead", false);
return null;
}

@Override
Expand Down
9 changes: 0 additions & 9 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,9 @@ tests:
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryWithPartialResultsIT
method: testPartialResults
issue: https://github.com/elastic/elasticsearch/issues/123101
- class: org.elasticsearch.index.mapper.extras.ScaledFloatFieldMapperTests
method: testBlockLoaderFromRowStrideReader
issue: https://github.com/elastic/elasticsearch/issues/123126
- class: org.elasticsearch.index.mapper.extras.ScaledFloatFieldMapperTests
method: testBlockLoaderFromRowStrideReaderWithSyntheticSource
issue: https://github.com/elastic/elasticsearch/issues/123145
- class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT
method: testStopQueryLocal
issue: https://github.com/elastic/elasticsearch/issues/121672
- class: org.elasticsearch.index.mapper.extras.ScaledFloatFieldMapperTests
method: testBlockLoaderFromColumnReaderWithSyntheticSource
issue: https://github.com/elastic/elasticsearch/issues/123149

# Examples:
#
Expand Down