[GitHub] [lucene] zacharymorn commented on a change in pull request #534: LUCENE-10183: KnnVectorsWriter#writeField to take KnnVectorsReader instead of VectorValues

2022-01-05 Thread GitBox


zacharymorn commented on a change in pull request #534:
URL: https://github.com/apache/lucene/pull/534#discussion_r779299155



##
File path: 
lucene/core/src/test/org/apache/lucene/codecs/perfield/TestPerFieldKnnVectorsFormat.java
##
@@ -172,9 +171,14 @@ public KnnVectorsWriter fieldsWriter(SegmentWriteState 
state) throws IOException
   KnnVectorsWriter writer = delegate.fieldsWriter(state);
   return new KnnVectorsWriter() {
 @Override
-public void writeField(FieldInfo fieldInfo, VectorValues values) 
throws IOException {
+public void writeField(FieldInfo fieldInfo, KnnVectorsReader 
knnVectorsReader)
+throws IOException {
   fieldsWritten.add(fieldInfo.name);
-  writer.writeField(fieldInfo, values);
+  // assert that knnVectorsReader#getVectorValues returns different 
instances upon repeated
+  // calls

Review comment:
   Ah right. I've moved it to `AssertingKnnVectorsReader`.




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

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



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



[GitHub] [lucene] zacharymorn commented on a change in pull request #534: LUCENE-10183: KnnVectorsWriter#writeField to take KnnVectorsReader instead of VectorValues

2022-01-03 Thread GitBox


zacharymorn commented on a change in pull request #534:
URL: https://github.com/apache/lucene/pull/534#discussion_r777817835



##
File path: lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java
##
@@ -107,7 +110,36 @@ private void mergeVectors(FieldInfo mergeFieldInfo, final 
MergeState mergeState)
 }
 // Create a new VectorValues by iterating over the sub vectors, mapping 
the resulting
 // docids using docMaps in the mergeState.
-writeField(mergeFieldInfo, new VectorValuesMerger(subs, mergeState));
+writeField(
+mergeFieldInfo,
+new KnnVectorsReader() {
+  @Override
+  public long ramBytesUsed() {
+return 0;
+  }
+
+  @Override
+  public void close() throws IOException {
+throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public void checkIntegrity() throws IOException {
+throw new UnsupportedOperationException();
+  }
+
+  @Override
+  public VectorValues getVectorValues(String field) throws IOException 
{
+return new VectorValuesMerger(subs, mergeState);

Review comment:
   Ops sorry, I should have realized this when fixing for 
`VectorValuesWriter`. I've fixed this one as well and asserted for new 
`VectorValues` to be created upon calls in a test.




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

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



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



[GitHub] [lucene] zacharymorn commented on a change in pull request #534: LUCENE-10183: KnnVectorsWriter#writeField to take KnnVectorsReader instead of VectorValues

2021-12-14 Thread GitBox


zacharymorn commented on a change in pull request #534:
URL: https://github.com/apache/lucene/pull/534#discussion_r769243295



##
File path: lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java
##
@@ -40,7 +41,8 @@
   protected KnnVectorsWriter() {}
 
   /** Write all values contained in the provided reader */
-  public abstract void writeField(FieldInfo fieldInfo, VectorValues values) 
throws IOException;
+  public abstract void writeField(FieldInfo fieldInfo, KnnVectorsReader 
knnVectorReader)

Review comment:
   Good suggestion! I've updated them to use `knnVectorsReader`. 

##
File path: lucene/core/src/java/org/apache/lucene/index/VectorValuesWriter.java
##
@@ -109,11 +110,15 @@ private void updateBytesUsed() {
   public void flush(Sorter.DocMap sortMap, KnnVectorsWriter knnVectorsWriter) 
throws IOException {
 VectorValues vectorValues =
 new BufferedVectorValues(docsWithField, vectors, 
fieldInfo.getVectorDimension());
-if (sortMap != null) {
-  knnVectorsWriter.writeField(fieldInfo, new 
SortingVectorValues(vectorValues, sortMap));
-} else {
-  knnVectorsWriter.writeField(fieldInfo, vectorValues);
-}
+KnnVectorsReader vectorsReader =
+new EmptyKnnVectorsReader() {
+  @Override
+  public VectorValues getVectorValues(String field) throws IOException 
{
+return sortMap != null ? new SortingVectorValues(vectorValues, 
sortMap) : vectorValues;

Review comment:
   Ops sorry good catch! I've fixed it. 




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

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



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



[GitHub] [lucene] zacharymorn commented on a change in pull request #534: LUCENE-10183: KnnVectorsWriter#writeField to take KnnVectorsReader instead of VectorValues

2021-12-14 Thread GitBox


zacharymorn commented on a change in pull request #534:
URL: https://github.com/apache/lucene/pull/534#discussion_r769243208



##
File path: 
lucene/core/src/java/org/apache/lucene/index/EmptyKnnVectorsReader.java
##
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.index;
+
+import java.io.IOException;
+import org.apache.lucene.codecs.KnnVectorsReader;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.util.Bits;
+
+/** Abstract base class implementing a {@link KnnVectorsReader} that has no 
vector values. */
+public abstract class EmptyKnnVectorsReader extends KnnVectorsReader {

Review comment:
   Ah makes sense. Thanks for the context! I've removed it and extended 
directly. 




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

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



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



[GitHub] [lucene] zacharymorn commented on a change in pull request #534: LUCENE-10183: KnnVectorsWriter#writeField to take KnnVectorsReader instead of VectorValues

2021-12-11 Thread GitBox


zacharymorn commented on a change in pull request #534:
URL: https://github.com/apache/lucene/pull/534#discussion_r767087199



##
File path: 
lucene/core/src/java/org/apache/lucene/index/EmptyKnnVectorsReader.java
##
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.index;
+
+import java.io.IOException;
+import org.apache.lucene.codecs.KnnVectorsReader;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.util.Bits;
+
+/** Abstract base class implementing a {@link KnnVectorsReader} that has no 
vector values. */
+public abstract class EmptyKnnVectorsReader extends KnnVectorsReader {

Review comment:
   This class mirrors 
https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/index/EmptyDocValuesProducer.java
 for doc values.




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

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



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



[GitHub] [lucene] zacharymorn commented on a change in pull request #534: LUCENE-10183: KnnVectorsWriter#writeField to take KnnVectorsReader instead of VectorValues

2021-12-10 Thread GitBox


zacharymorn commented on a change in pull request #534:
URL: https://github.com/apache/lucene/pull/534#discussion_r767087199



##
File path: 
lucene/core/src/java/org/apache/lucene/index/EmptyKnnVectorsReader.java
##
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.index;
+
+import java.io.IOException;
+import org.apache.lucene.codecs.KnnVectorsReader;
+import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.util.Bits;
+
+/** Abstract base class implementing a {@link KnnVectorsReader} that has no 
vector values. */
+public abstract class EmptyKnnVectorsReader extends KnnVectorsReader {

Review comment:
   This class mirrors 
https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/index/EmptyDocValuesProducer.java
 for doc values.




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

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



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