siddharthteotia commented on a change in pull request #6728:
URL: https://github.com/apache/incubator-pinot/pull/6728#discussion_r604762376
##########
File path: pinot-spi/src/main/java/org/apache/pinot/spi/data/FieldSpec.java
##########
@@ -398,6 +390,58 @@ public boolean isFixedWidth() {
public boolean isNumeric() {
return this == INT || this == LONG || this == FLOAT || this == DOUBLE;
}
+
+ /**
+ * Converts the given string value to the data type. Returns byte[] for
BYTES.
+ */
+ public Object convert(String value) {
+ try {
+ switch (this) {
+ case INT:
+ return Integer.valueOf(value);
+ case LONG:
+ return Long.valueOf(value);
+ case FLOAT:
+ return Float.valueOf(value);
+ case DOUBLE:
+ return Double.valueOf(value);
+ case STRING:
+ return value;
+ case BYTES:
+ return BytesUtils.toBytes(value);
+ default:
+ throw new IllegalStateException();
Review comment:
can also return a single element array if `isSingleValueField` is false
for `this` ?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]