Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ API Changes
TopFieldCollectorManager. Clarify thread-safety documentation. (Prudhvi Godithi)

* GITHUB#16052: Remove IOException from LeafReader#getPointValues, LeafReader#terms,
LeafReader#getDocCount signatures. (Ignacio Vera)
LeafReader#getDocCount, LeafReader#getSumDocFreq and LeafReader#getSumTotalTermFreq
signatures. (Ignacio Vera)

New Features
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public long getSumTotalTermFreq() {
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return sumDocFreq;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
return delegateTerms.getSumTotalTermFreq();
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return delegateTerms.getSumDocFreq();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public long getSumTotalTermFreq() {
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return sumDocFreq;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public long getSumTotalTermFreq() {
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return sumDocFreq;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import static org.apache.lucene.codecs.simpletext.SimpleTextTermVectorsWriter.VECTORS_EXTENSION;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -296,18 +297,22 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
// TODO: make it constant-time
long ttf = 0;
TermsEnum iterator = iterator();
for (BytesRef b = iterator.next(); b != null; b = iterator.next()) {
ttf += iterator.totalTermFreq();
public long getSumTotalTermFreq() {
try {
// TODO: make it constant-time by pre-computing during indexing
long ttf = 0;
TermsEnum iterator = iterator();
for (BytesRef b = iterator.next(); b != null; b = iterator.next()) {
ttf += iterator.totalTermFreq();
}
return ttf;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
return ttf;
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return terms.size();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,12 +1017,12 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
return totalTermFreq;
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return numTerms;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
return in.getSumTotalTermFreq();
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return in.getSumDocFreq();
}

Expand Down
4 changes: 2 additions & 2 deletions lucene/core/src/java/org/apache/lucene/index/LeafReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public final long totalTermFreq(Term term) throws IOException {
}

@Override
public final long getSumDocFreq(String field) throws IOException {
public final long getSumDocFreq(String field) {
final Terms terms = terms(field);
if (terms == null) {
return 0;
Expand All @@ -122,7 +122,7 @@ public final int getDocCount(String field) {
}

@Override
public final long getSumTotalTermFreq(String field) throws IOException {
public final long getSumTotalTermFreq(String field) {
final Terms terms = terms(field);
if (terms == null) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
throw new UnsupportedOperationException();
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
throw new UnsupportedOperationException();
}

Expand Down
4 changes: 2 additions & 2 deletions lucene/core/src/java/org/apache/lucene/index/MultiTerms.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public long size() {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
long sum = 0;
for (Terms terms : subs) {
final long v = terms.getSumTotalTermFreq();
Expand All @@ -211,7 +211,7 @@ public long getSumTotalTermFreq() throws IOException {
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
long sum = 0;
for (Terms terms : subs) {
final long v = terms.getSumDocFreq();
Expand Down
8 changes: 4 additions & 4 deletions lucene/core/src/java/org/apache/lucene/index/Terms.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ protected BytesRef nextSeekTerm(BytesRef term) throws IOException {
* Returns the sum of {@link TermsEnum#totalTermFreq} for all terms in this field. Note that, just
* like other term measures, this measure does not take deleted documents into account.
*/
public abstract long getSumTotalTermFreq() throws IOException;
public abstract long getSumTotalTermFreq();

/**
* Returns the sum of {@link TermsEnum#docFreq()} for all terms in this field. Note that, just
* like other term measures, this measure does not take deleted documents into account.
*/
public abstract long getSumDocFreq() throws IOException;
public abstract long getSumDocFreq();

/**
* Returns the number of documents that have at least one term for this field. Note that, just
Expand Down Expand Up @@ -237,12 +237,12 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
return 0;
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
throw new UnsupportedOperationException();
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
throw new UnsupportedOperationException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ public long size() throws IOException {
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
throw new UnsupportedOperationException();
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return numValues;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public long getSumTotalTermFreq() {
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
return sumDocFreq;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ public int getDocCount() {
}

@Override
public long getSumDocFreq() throws IOException {
public long getSumDocFreq() {
assertThread("Terms", creationThread);
final long sumDf = in.getSumDocFreq();
assert sumDf >= getDocCount();
return sumDf;
}

@Override
public long getSumTotalTermFreq() throws IOException {
public long getSumTotalTermFreq() {
assertThread("Terms", creationThread);
final long sumTtf = in.getSumTotalTermFreq();
if (hasFreqs() == false) {
Expand Down
Loading