|
53 | 53 | import org.elasticsearch.test.ESTestCase; |
54 | 54 | import org.elasticsearch.test.index.IndexVersionUtils; |
55 | 55 | import org.elasticsearch.xcontent.XContentBuilder; |
| 56 | +import org.hamcrest.Matcher; |
56 | 57 | import org.junit.AssumptionViolatedException; |
57 | 58 |
|
58 | 59 | import java.io.IOException; |
|
61 | 62 | import java.util.List; |
62 | 63 | import java.util.Map; |
63 | 64 | import java.util.Set; |
| 65 | +import java.util.function.Function; |
64 | 66 |
|
65 | 67 | import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat.DEFAULT_BEAM_WIDTH; |
66 | 68 | import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat.DEFAULT_MAX_CONN; |
| 69 | +import static org.hamcrest.Matchers.closeTo; |
67 | 70 | import static org.hamcrest.Matchers.containsString; |
68 | 71 | import static org.hamcrest.Matchers.equalTo; |
69 | 72 | import static org.hamcrest.Matchers.instanceOf; |
@@ -2244,6 +2247,26 @@ protected boolean supportsEmptyInputArray() { |
2244 | 2247 | return false; |
2245 | 2248 | } |
2246 | 2249 |
|
| 2250 | + @Override |
| 2251 | + protected BlockReaderSupport getSupportedReaders(MapperService mapper, String loaderFieldName) { |
| 2252 | + return new BlockReaderSupport(true, true, mapper, loaderFieldName); |
| 2253 | + } |
| 2254 | + |
| 2255 | + @Override |
| 2256 | + protected Function<Object, Object> loadBlockExpected(BlockReaderSupport blockReaderSupport, boolean columnReader) { |
| 2257 | + DenseVectorFieldType ft = (DenseVectorFieldType) blockReaderSupport.mapper().fieldType(blockReaderSupport.loaderFieldName()); |
| 2258 | + if (ft.getElementType() != ElementType.FLOAT) { |
| 2259 | + return null; |
| 2260 | + } |
| 2261 | + |
| 2262 | + return Function.identity(); |
| 2263 | + } |
| 2264 | + |
| 2265 | + @Override |
| 2266 | + protected Matcher<?> blockItemMatcher(Object expected) { |
| 2267 | + return closeTo((double) expected, 0.000001); |
| 2268 | + } |
| 2269 | + |
2247 | 2270 | private static class DenseVectorSyntheticSourceSupport implements SyntheticSourceSupport { |
2248 | 2271 | private final int dims = between(5, 1000); |
2249 | 2272 | private final ElementType elementType = randomFrom(ElementType.BYTE, ElementType.FLOAT, ElementType.BIT); |
|
0 commit comments