17
17
import org .elasticsearch .index .mapper .MappedFieldType ;
18
18
19
19
import java .nio .ByteOrder ;
20
- import java .util .ArrayList ;
21
20
import java .util .Comparator ;
22
21
import java .util .List ;
23
22
import java .util .Map ;
@@ -30,10 +29,7 @@ public GeoPointFieldBlockLoaderTests(BlockLoaderTestCase.Params params) {
30
29
31
30
@ Override
32
31
@ SuppressWarnings ("unchecked" )
33
- protected Object expected (Map <String , Object > fieldMapping , Object value , TestContext testContext ) {
34
- var extractedFieldValues = (ExtractedFieldValues ) value ;
35
- var values = extractedFieldValues .values ();
36
-
32
+ protected Object expected (Map <String , Object > fieldMapping , Object values , TestContext testContext ) {
37
33
var rawNullValue = fieldMapping .get ("null_value" );
38
34
39
35
GeoPoint nullValue ;
@@ -80,9 +76,6 @@ protected Object expected(Map<String, Object> fieldMapping, Object value, TestCo
80
76
if (syntheticSourceKeep .equals ("all" )) {
81
77
return exactValuesFromSource (values , nullValue , false );
82
78
}
83
- if (syntheticSourceKeep .equals ("arrays" ) && extractedFieldValues .documentHasObjectArrays ()) {
84
- return exactValuesFromSource (values , nullValue , false );
85
- }
86
79
87
80
// synthetic source and doc_values are present
88
81
if (hasDocValues (fieldMapping , true )) {
@@ -117,61 +110,6 @@ private Object exactValuesFromSource(Object value, GeoPoint nullValue, boolean n
117
110
return maybeFoldList (resultList );
118
111
}
119
112
120
- private record ExtractedFieldValues (Object values , boolean documentHasObjectArrays ) {}
121
-
122
- @ Override
123
- protected Object getFieldValue (Map <String , Object > document , String fieldName ) {
124
- var extracted = new ArrayList <>();
125
- var documentHasObjectArrays = processLevel (document , fieldName , extracted , false );
126
-
127
- if (extracted .size () == 1 ) {
128
- return new ExtractedFieldValues (extracted .get (0 ), documentHasObjectArrays );
129
- }
130
-
131
- return new ExtractedFieldValues (extracted , documentHasObjectArrays );
132
- }
133
-
134
- @ SuppressWarnings ("unchecked" )
135
- private boolean processLevel (Map <String , Object > level , String field , ArrayList <Object > extracted , boolean documentHasObjectArrays ) {
136
- if (field .contains ("." ) == false ) {
137
- var value = level .get (field );
138
- processLeafLevel (value , extracted );
139
- return documentHasObjectArrays ;
140
- }
141
-
142
- var nameInLevel = field .split ("\\ ." )[0 ];
143
- var entry = level .get (nameInLevel );
144
- if (entry instanceof Map <?, ?> m ) {
145
- return processLevel ((Map <String , Object >) m , field .substring (field .indexOf ('.' ) + 1 ), extracted , documentHasObjectArrays );
146
- }
147
- if (entry instanceof List <?> l ) {
148
- for (var object : l ) {
149
- processLevel ((Map <String , Object >) object , field .substring (field .indexOf ('.' ) + 1 ), extracted , true );
150
- }
151
- return true ;
152
- }
153
-
154
- assert false : "unexpected document structure" ;
155
- return false ;
156
- }
157
-
158
- private void processLeafLevel (Object value , ArrayList <Object > extracted ) {
159
- if (value instanceof List <?> l ) {
160
- if (l .size () > 0 && l .get (0 ) instanceof Double ) {
161
- // this must be a single point in array form
162
- // we'll put it into a different form here to make our lives a bit easier while implementing `expected`
163
- extracted .add (Map .of ("type" , "point" , "coordinates" , l ));
164
- } else {
165
- // this is actually an array of points but there could still be points in array form inside
166
- for (var arrayValue : l ) {
167
- processLeafLevel (arrayValue , extracted );
168
- }
169
- }
170
- } else {
171
- extracted .add (value );
172
- }
173
- }
174
-
175
113
@ SuppressWarnings ("unchecked" )
176
114
private GeoPoint convert (Object value , GeoPoint nullValue , boolean needsMultifieldAdjustment ) {
177
115
if (value == null ) {
0 commit comments