Open PratikBarhate opened 5 months ago
Programming language : Java17 Operating systems : Mac OS 14.3 CPU: M1 Pro FlatBuffer (flatc) version : 23.5.26 JDK : openjdk 17.0.10 2024-01-16 LTS
FlatBuffer Schema
namespace com.example.testing; table Scores { key_col: string (key); score : double; } table Data { id: string (required); test_vector: [double] (required); scores : [Scores] (required); } root_type Data;
De-serialization code :-
public static double [] flatBufferToData(byte[] data) { ByteBuffer byteBuffer = ByteBuffer.wrap(data); Data testFeature = Data.getRootAsTestFeature(byteBuffer); String testId = testFeature.id(); DoubleVector vector = testFeature.embeddingVectorVector(); Scores.Vector scoreVec = testFeature.scoresVector(); System.out.println("Index access " + scoreVec.get(50).score()); System.out.println("Index access key " + scoreVec.get(50).keyCol()); double[] testAccess = new double[4]; testAccess[0] = vector.get(10); System.out.println("key_" + 10); testAccess[1] = scoreVec.getByKey("key_" + 10).score(); testAccess[2] = vector.get(10); testAccess[3] = scoreVec.getByKey("key_" + 10).score(); return testAccess; }
Standard output :-
Index access 0.20687898819703532 Index access key key_14 key_10 <failure> java.lang.NullPointerException: ...
We are able to read the data when accessed using the vector index, although while accessing the data using getByKey returns null.
getByKey
null
Programming language : Java17 Operating systems : Mac OS 14.3 CPU: M1 Pro FlatBuffer (flatc) version : 23.5.26 JDK : openjdk 17.0.10 2024-01-16 LTS
FlatBuffer Schema
De-serialization code :-
Standard output :-
We are able to read the data when accessed using the vector index, although while accessing the data using
getByKey
returnsnull
.