3131import org .elasticsearch .xcontent .XContentBuilder ;
3232import org .elasticsearch .xcontent .XContentFactory ;
3333import org .elasticsearch .xcontent .XContentType ;
34- import org .hamcrest .Matcher ;
3534import org .junit .AssumptionViolatedException ;
3635
3736import java .io .IOException ;
3837import java .util .Collection ;
3938import java .util .Collections ;
4039import java .util .List ;
4140import java .util .Map ;
42- import java .util .function .Function ;
4341import java .util .function .Supplier ;
4442import java .util .stream .Stream ;
4543
4846import static org .hamcrest .Matchers .empty ;
4947import static org .hamcrest .Matchers .equalTo ;
5048import static org .hamcrest .Matchers .is ;
51- import static org .hamcrest .Matchers .notANumber ;
5249
5350public class ScaledFloatFieldMapperTests extends NumberFieldMapperTests {
5451
@@ -382,7 +379,7 @@ public SyntheticSourceExample example(int maxValues) {
382379 if (randomBoolean ()) {
383380 Value v = generateValue ();
384381 if (v .malformedOutput == null ) {
385- return new SyntheticSourceExample (v .input , v .output , roundDocValues ( v . output ), this ::mapping );
382+ return new SyntheticSourceExample (v .input , v .output , this ::mapping );
386383 }
387384 return new SyntheticSourceExample (v .input , v .malformedOutput , null , this ::mapping );
388385 }
@@ -396,9 +393,7 @@ public SyntheticSourceExample example(int maxValues) {
396393 List <Object > outList = Stream .concat (outputFromDocValues .stream (), malformedOutput ).toList ();
397394 Object out = outList .size () == 1 ? outList .get (0 ) : outList ;
398395
399- List <Double > outBlockList = outputFromDocValues .stream ().map (this ::roundDocValues ).sorted ().toList ();
400- Object outBlock = outBlockList .size () == 1 ? outBlockList .get (0 ) : outBlockList ;
401- return new SyntheticSourceExample (in , out , outBlock , this ::mapping );
396+ return new SyntheticSourceExample (in , out , this ::mapping );
402397 }
403398
404399 private record Value (Object input , Double output , Object malformedOutput ) {}
@@ -442,16 +437,6 @@ private double round(double d) {
442437 return decoded ;
443438 }
444439
445- private double roundDocValues (double d ) {
446- // Special case due to rounding, see implementation.
447- if (Math .abs (d ) == Double .MAX_VALUE ) {
448- return d ;
449- }
450-
451- long encoded = Math .round (d * scalingFactor );
452- return encoded * (1 / scalingFactor );
453- }
454-
455440 private void mapping (XContentBuilder b ) throws IOException {
456441 b .field ("type" , "scaled_float" );
457442 b .field ("scaling_factor" , scalingFactor );
@@ -475,14 +460,9 @@ public List<SyntheticSourceInvalidExample> invalidExample() throws IOException {
475460 }
476461 }
477462
478- @ Override
479- protected Function <Object , Object > loadBlockExpected () {
480- return v -> (Number ) v ;
481- }
482-
483- @ Override
484- protected Matcher <?> blockItemMatcher (Object expected ) {
485- return "NaN" .equals (expected ) ? notANumber () : equalTo (expected );
463+ protected BlockReaderSupport getSupportedReaders (MapperService mapper , String loaderFieldName ) {
464+ assumeTrue ("Disabled, tested by ScaledFloatFieldBlockLoaderTests instead" , false );
465+ return null ;
486466 }
487467
488468 @ Override
0 commit comments