2
0

GetVectorByIdResponse.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package io.milvus.client;
  2. import java.nio.ByteBuffer;
  3. import java.util.List;
  4. import java.util.Optional;
  5. /**
  6. * Contains the returned <code>response</code> and either a <code>floatVector</code> or a <code>
  7. * binaryVector</code> for <code>getVectorById</code>. If the id does not exist, both returned
  8. * vectors will be empty.
  9. */
  10. public class GetVectorByIdResponse {
  11. private final Response response;
  12. private final List<Float> floatVector;
  13. private final ByteBuffer binaryVector;
  14. GetVectorByIdResponse(Response response, List<Float> floatVector, ByteBuffer binaryVector) {
  15. this.response = response;
  16. this.floatVector = floatVector;
  17. this.binaryVector = binaryVector;
  18. }
  19. public List<Float> getFloatVector() {
  20. return floatVector;
  21. }
  22. /**
  23. * @return an <code>Optional</code> object which may or may not contain a <code>ByteBuffer</code>
  24. * object
  25. * @see Optional
  26. */
  27. public Optional<ByteBuffer> getBinaryVector() {
  28. return Optional.ofNullable(binaryVector);
  29. }
  30. /** @return <code>true</code> if the id corresponds to a float vector */
  31. public boolean isFloatVector() {
  32. return !floatVector.isEmpty();
  33. }
  34. /** @return <code>true</code> if the id corresponds to a binary vector */
  35. public boolean isBinaryVector() {
  36. return binaryVector != null && binaryVector.hasRemaining();
  37. }
  38. /** @return <code>true</code> if the id's corresponding vector exists */
  39. public boolean exists() {
  40. return isFloatVector() || isBinaryVector();
  41. }
  42. public Response getResponse() {
  43. return response;
  44. }
  45. /** @return <code>true</code> if the response status equals SUCCESS */
  46. public boolean ok() {
  47. return response.ok();
  48. }
  49. }