File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 1313import org .elasticsearch .action .index .IndexRequestBuilder ;
1414import org .elasticsearch .cluster .metadata .IndexMetadata ;
1515import org .elasticsearch .common .settings .Settings ;
16+ import org .elasticsearch .index .codec .vectors .BFloat16 ;
1617import org .elasticsearch .index .mapper .vectors .DenseVectorFieldMapper ;
1718import org .elasticsearch .index .mapper .vectors .DenseVectorFieldMapper .ElementType ;
1819import org .elasticsearch .script .field .vectors .DenseVector ;
@@ -250,6 +251,15 @@ public void setup() throws IOException {
250251 buffer .asFloatBuffer ().put (array );
251252 yield Base64 .getEncoder ().encodeToString (buffer .array ());
252253 }
254+ case BFLOAT16 -> {
255+ float [] array = new float [numDims ];
256+ for (int k = 0 ; k < numDims ; k ++) {
257+ array [k ] = vector .get (k ).floatValue ();
258+ }
259+ final ByteBuffer buffer = ByteBuffer .allocate (BFloat16 .BYTES * numDims );
260+ BFloat16 .floatToBFloat16 (array , buffer .asShortBuffer ());
261+ yield Base64 .getEncoder ().encodeToString (buffer .array ());
262+ }
253263 case BYTE , BIT -> {
254264 byte [] array = new byte [numDims ];
255265 for (int k = 0 ; k < numDims ; k ++) {
You can’t perform that action at this time.
0 commit comments