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



##########
File path: lucene/core/src/java/org/apache/lucene/index/TermVectors.java
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.Closeable;
+import java.io.IOException;
+import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
+
+/** Index API to access TermVectors */
+public abstract class TermVectors implements Cloneable, Closeable {

Review comment:
       Ok I was a bit unsure on these earlier as well. 
   
   For `Cloneable`, I feel it may still be needed / recommended to have on 
`TermVectorsReader`, if we would like to invoke 
`core.termVectorsReader.clone()` directly from inside 
`SegmentReader#getTermVectorsReader`? 
   
   For `Closeable`, I added it here originally since I thought we may need to 
close the resources used by the cloned readers (such as `vectorsStream`) from 
this new API. However, after reading your comment and more digging, I also saw 
this java doc in `IndexInput`:
   
https://github.com/apache/lucene/blob/065026b74e60301e09f409e67d41ff42ebc36bb2/lucene/core/src/java/org/apache/lucene/store/IndexInput.java#L32-L33
 . So I guess closing here is not actually needed. I've moved back the 
`Closeable` interface to `TermVectorsReader`.

##########
File path: lucene/core/src/java/org/apache/lucene/index/FilterCodecReader.java
##########
@@ -152,6 +152,11 @@ public Bits getLiveDocs() {
         return liveDocs;
       }
 
+      @Override
+      public TermVectorsReader getTermVectorsReader() {
+        return null;

Review comment:
       Ops sorry I missed this one. This is redundant as the forwarding / 
delegation was already handled in `FilterCodecReader` class above. I've removed 
it.

##########
File path: lucene/core/src/java/org/apache/lucene/index/SegmentReader.java
##########
@@ -310,6 +304,12 @@ public Directory directory() {
 
   private final Set<ClosedListener> readerClosedListeners = new 
CopyOnWriteArraySet<>();
 
+  @Override
+  public TermVectorsReader getTermVectorsReader() {
+    ensureOpen();
+    return core.termVectorsReader;

Review comment:
       Done. 

##########
File path: 
lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java
##########
@@ -615,11 +607,10 @@ protected FieldInfo getFieldInfo(String field) {
           if (content == null) {
             continue;
           }
-          IndexReader indexReader =
-              (fieldHighlighter.getOffsetSource() == OffsetSource.TERM_VECTORS
-                      && indexReaderWithTermVecCache != null)
-                  ? indexReaderWithTermVecCache
-                  : searcher.getIndexReader();
+          // nocommit TermVectorReusingLeafReader is no longer valid given

Review comment:
       Thanks for the detailed information and suggestion. I have done some 
searches, and it looks like these are two places that need to be changed:
   
   
https://github.com/apache/lucene/blob/d5d6dc079395c47cd6d12dcce3bcfdd2c7d9dc63/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/PostingsWithTermVectorsOffsetStrategy.java#L38
   
   
https://github.com/apache/lucene/blob/d5d6dc079395c47cd6d12dcce3bcfdd2c7d9dc63/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/TermVectorOffsetStrategy.java#L43
   
   I'll work on adding this caching back via the new API.




-- 
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:
us...@infra.apache.org



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

Reply via email to