GetPartStatResponseWrapper.java 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package io.milvus.Response;
  2. import io.milvus.grpc.GetPartitionStatisticsResponse;
  3. import io.milvus.grpc.KeyValuePair;
  4. import io.milvus.param.Constant;
  5. import lombok.NonNull;
  6. import java.util.List;
  7. /**
  8. * Utility class to wrap response of <code>getPartitionStatistics</code> interface.
  9. */
  10. public class GetPartStatResponseWrapper {
  11. private final GetPartitionStatisticsResponse stat;
  12. public GetPartStatResponseWrapper(@NonNull GetPartitionStatisticsResponse stat) {
  13. this.stat = stat;
  14. }
  15. /**
  16. * Gets the row count of a field.
  17. * Throw {@link NumberFormatException} if the row count is not a number.
  18. *
  19. * @return <code>int</code> dimension of the vector field
  20. */
  21. public long getRowCount() throws NumberFormatException {
  22. List<KeyValuePair> stats = stat.getStatsList();
  23. for (KeyValuePair kv : stats) {
  24. if (kv.getKey().compareTo(Constant.ROW_COUNT) == 0) {
  25. return Long.parseLong(kv.getValue());
  26. }
  27. }
  28. return 0;
  29. }
  30. }