You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "alessandrobenedetti (via GitHub)" <gi...@apache.org> on 2023/03/21 16:11:37 UTC

[GitHub] [solr] alessandrobenedetti commented on a diff in pull request #1435: SOLR-16674: Introduce dense vector byte encoding

alessandrobenedetti commented on code in PR #1435:
URL: https://github.com/apache/solr/pull/1435#discussion_r1140498109


##########
solr/core/src/java/org/apache/solr/schema/DenseVectorField.java:
##########
@@ -165,38 +178,69 @@ public void checkSchemaField(final SchemaField field) throws SolrException {
 
   @Override
   public List<IndexableField> createFields(SchemaField field, Object value) {
-    ArrayList<IndexableField> fields = new ArrayList<>();
-    float[] parsedVector;
     try {
-      parsedVector = parseVector(value);
+      ArrayList<IndexableField> fields = new ArrayList<>();
+      VectorValue vectorValue = new VectorValue(value);
+      if (field.indexed()) {
+        fields.add(createField(field, vectorValue));
+      }
+      if (field.stored()) {
+        switch (vectorEncoding) {
+          case FLOAT32:
+            for (float vectorElement : vectorValue.getFloatVector()) {
+              fields.add(getStoredField(field, vectorElement));
+            }
+            break;
+          case BYTE:
+            fields.add(new StoredField(field.getName(), vectorValue.getByteVector()));
+            break;
+        }
+      }
+      return fields;
     } catch (RuntimeException e) {
       throw new SolrException(
           SolrException.ErrorCode.SERVER_ERROR,
           "Error while creating field '"
               + field
               + "' from value '"
               + value
-              + "', expected format:'[f1, f2, f3...fn]' e.g. [1.0, 3.4, 5.6]",
+              + "', expected format:'[f1, f2, f3...fn]'",
           e);
     }
+  }
 
-    if (field.indexed()) {
-      fields.add(createField(field, parsedVector));
-    }
-    if (field.stored()) {
-      fields.ensureCapacity(parsedVector.length + 1);

Review Comment:
   any reason for the removal of 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.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org