Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java, FlatBuffers 23.5.26, Mac OS 14.3] getByKey returns null while accessing using vector index works #8233

Open
PratikBarhate opened this issue Feb 8, 2024 · 0 comments

Comments

@PratikBarhate
Copy link

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.

@PratikBarhate PratikBarhate changed the title [Java17, FlatBuffers 23.5.26, Mac OS 14.3] getByKey returns null while accessing using vector index works [Java, FlatBuffers 23.5.26, Mac OS 14.3] getByKey returns null while accessing using vector index works Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant