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



##########
File path: lucene/core/src/java/org/apache/lucene/index/BaseCompositeReader.java
##########
@@ -118,6 +121,65 @@ public final Fields getTermVectors(int docID) throws 
IOException {
     return subReaders[i].getTermVectors(docID - starts[i]); // dispatch to 
subreader
   }
 
+  private class CompositeTermVectorsReader extends TermVectorsReader {
+    List<TermVectorsReader> termVectorsReaders;
+
+    public CompositeTermVectorsReader(List<TermVectorsReader> 
termVectorsReaders) {
+      this.termVectorsReaders = termVectorsReaders;
+    }
+
+    @Override
+    public Fields get(int doc) throws IOException {
+      ensureOpen();
+      final int i = readerIndex(doc); // find subreader num
+      return termVectorsReaders.get(i).get(doc - starts[i]); // dispatch to 
subreader
+    }
+
+    @Override
+    public void checkIntegrity() throws IOException {
+      termVectorsReaders.stream()
+          .forEach(
+              r -> {
+                try {
+                  r.checkIntegrity();
+                } catch (IOException e) {
+                  throw new UncheckedIOException(e);
+                }
+              });

Review comment:
       Yeah I think so. Sorry was too used to typing stream these days :D .

##########
File path: lucene/core/src/java/org/apache/lucene/index/BaseCompositeReader.java
##########
@@ -118,6 +121,65 @@ public final Fields getTermVectors(int docID) throws 
IOException {
     return subReaders[i].getTermVectors(docID - starts[i]); // dispatch to 
subreader
   }
 
+  private class CompositeTermVectorsReader extends TermVectorsReader {
+    List<TermVectorsReader> termVectorsReaders;
+
+    public CompositeTermVectorsReader(List<TermVectorsReader> 
termVectorsReaders) {
+      this.termVectorsReaders = termVectorsReaders;
+    }
+
+    @Override
+    public Fields get(int doc) throws IOException {
+      ensureOpen();
+      final int i = readerIndex(doc); // find subreader num
+      return termVectorsReaders.get(i).get(doc - starts[i]); // dispatch to 
subreader
+    }
+
+    @Override
+    public void checkIntegrity() throws IOException {
+      termVectorsReaders.stream()
+          .forEach(
+              r -> {
+                try {
+                  r.checkIntegrity();
+                } catch (IOException e) {
+                  throw new UncheckedIOException(e);
+                }
+              });
+    }
+
+    @Override
+    public TermVectorsReader clone() {
+      List<TermVectorsReader> newTermVectorReaders =
+          termVectorsReaders.stream().map(r -> 
r.clone()).collect(Collectors.toList());

Review comment:
       I updated this section to use `for` loop now, but will prefer to use 
method references in later changes.

##########
File path: lucene/core/src/java/org/apache/lucene/index/BaseCompositeReader.java
##########
@@ -118,6 +121,65 @@ public final Fields getTermVectors(int docID) throws 
IOException {
     return subReaders[i].getTermVectors(docID - starts[i]); // dispatch to 
subreader
   }
 
+  private class CompositeTermVectorsReader extends TermVectorsReader {
+    List<TermVectorsReader> termVectorsReaders;
+
+    public CompositeTermVectorsReader(List<TermVectorsReader> 
termVectorsReaders) {
+      this.termVectorsReaders = termVectorsReaders;
+    }
+
+    @Override
+    public Fields get(int doc) throws IOException {
+      ensureOpen();
+      final int i = readerIndex(doc); // find subreader num
+      return termVectorsReaders.get(i).get(doc - starts[i]); // dispatch to 
subreader
+    }
+
+    @Override
+    public void checkIntegrity() throws IOException {
+      termVectorsReaders.stream()
+          .forEach(
+              r -> {
+                try {
+                  r.checkIntegrity();
+                } catch (IOException e) {
+                  throw new UncheckedIOException(e);
+                }
+              });
+    }
+
+    @Override
+    public TermVectorsReader clone() {
+      List<TermVectorsReader> newTermVectorReaders =
+          termVectorsReaders.stream().map(r -> 
r.clone()).collect(Collectors.toList());
+
+      return new CompositeTermVectorsReader(newTermVectorReaders);
+    }
+
+    @Override
+    public void close() throws IOException {
+      termVectorsReaders.stream()
+          .forEach(
+              r -> {
+                try {
+                  r.close();
+                } catch (IOException e) {
+                  throw new UncheckedIOException(e);
+                }
+              });

Review comment:
       Ah yes. This part is no longer needed in latest changes, but will keep 
it in mind for future changes.




-- 
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