saurabhd336 commented on code in PR #12568: URL: https://github.com/apache/pinot/pull/12568#discussion_r1517130691
########## pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java: ########## @@ -564,6 +566,39 @@ public Object convert(String value) { } } + /** + * Compares the given values of the data type. + * + * return 0 if the values are equal + * return -1 if value1 is less than value2 + * return 1 if value1 is greater than value2 + */ + public int compare(Object value1, Object value2) { + switch (this) { + case INT: + return Integer.compare((int) value1, (int) value2); + case LONG: + return Long.compare((long) value1, (long) value2); + case FLOAT: + return Float.compare((float) value1, (float) value2); + case DOUBLE: + return Double.compare((double) value1, (double) value2); + case BIG_DECIMAL: + return ((BigDecimal) value1).compareTo((BigDecimal) value2); + case BOOLEAN: + return Boolean.compare((boolean) value1, (boolean) value2); + case TIMESTAMP: + return Long.compare((long) value1, (long) value2); + case STRING: + case JSON: + return StringUtils.compare((String) value1, (String) value2); + case BYTES: + return new ByteArray((byte[]) value1).compareTo(new ByteArray((byte[]) value2)); Review Comment: ack -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org