You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/09/29 20:25:29 UTC

[GitHub] [lucene] rmuir commented on a diff in pull request #11832: Added static factory method for loading VectorValues

rmuir commented on code in PR #11832:
URL: https://github.com/apache/lucene/pull/11832#discussion_r983993590


##########
lucene/core/src/java/org/apache/lucene/index/VectorValues.java:
##########
@@ -35,6 +35,25 @@ public abstract class VectorValues extends DocIdSetIterator {
   /** Sole constructor */
   protected VectorValues() {}
 
+  /**
+   * Returns the {@link VectorValues} index for this field, or {@link #EMPTY} if it has none.
+   *
+   * @param reader Leaf reader instance
+   * @param field Field name
+   * @return VectorValues instance, or an empty instance if {@code field} does not exist in this
+   *     reader
+   * @throws IOException if the field does not have any vector values
+   */
+  public static VectorValues getVectorValues(LeafReader reader, String field) throws IOException {
+    VectorValues values = reader.getVectorValues(field);
+    if (values == null) {
+      return EMPTY;
+    } else if (!reader.getFieldInfos().fieldInfo(field).hasVectorValues()) {

Review Comment:
   this line of code is unreachable. It is actually the null case where you want to check if the field exists, and if so, does it have vector values. See DocValues as an example.



-- 
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@lucene.apache.org

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


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