alessandrobenedetti commented on code in PR #1435:
URL: https://github.com/apache/solr/pull/1435#discussion_r1154173619
##########
solr/core/src/java/org/apache/solr/schema/DenseVectorField.java:
##########
@@ -205,53 +257,144 @@ public IndexableField createField(SchemaField field,
Object parsedVector) {
* org.apache.solr.handler.loader.CSVLoader} produces an ArrayList of String
- {@link
* org.apache.solr.handler.loader.JsonLoader} produces an ArrayList of
Double - {@link
* org.apache.solr.handler.loader.JavabinLoader} produces an ArrayList of
Float
- *
- * @param inputValue - An {@link ArrayList} containing the elements of the
vector
- * @return the vector parsed
*/
- float[] parseVector(Object inputValue) {
- if (!(inputValue instanceof List)) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- "incorrect vector format."
- + " The expected format is an array :'[f1,f2..f3]' where each
element f is a float");
+ public VectorBuilder getVectorBuilder(Object inputValue) {
+ switch (vectorEncoding) {
+ case FLOAT32:
+ return new VectorBuilder.Float32VectorBuilder(dimension, inputValue);
+ case BYTE:
+ return new VectorBuilder.ByteVectorBuilder(dimension, inputValue);
+ default:
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR,
+ "Unexpected state. Vector Encoding: " + vectorEncoding);
}
- List<?> inputVector = (List<?>) inputValue;
- if (inputVector.size() != dimension) {
- throw new SolrException(
- SolrException.ErrorCode.BAD_REQUEST,
- "incorrect vector dimension."
- + " The vector value has size "
- + inputVector.size()
- + " while it is expected a vector with size "
- + dimension);
+ }
+
+ abstract static class VectorBuilder {
+
+ protected int dimension;
+ protected Object inputValue;
+
+ public float[] getFloatVector() {
+ throw new RuntimeException("Not implemented");
Review Comment:
check if "throw new UnsupportedOperationException" is better
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]