Apache Lucene open-source search software
LUCENE-5156: remove seek-by-ord from CompressingTermVectors
Robert Muire375cfa3313b
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 2b5ad3035e1..903e57e40dd 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -146,6 +146,9 @@ API Changesshould match for its high and low frequent sub-queries. Previously this was onlysupported on the low frequent terms query. (Simon Willnauer)+* LUCENE-5156: CompressingTermVectors TermsEnum no longer supports ord().+ (Robert Muir)+Optimizations* LUCENE-5088: Added TermFilter to filter docs by a specific term.diff --git a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.javaindex 22706a2fd5b..073e60c5327 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/compressing/CompressingTermVectorsReader.java@@ -851,16 +851,7 @@ public final class CompressingTermVectorsReader extends TermVectorsReader implem@Overridepublic void seekExact(long ord) throws IOException {- if (ord < -1 || ord >= numTerms) {- throw new IOException("ord is out of range: ord=" + ord + ", numTerms=" + numTerms);- }- if (ord < this.ord) {- reset();- }- for (int i = this.ord; i < ord; ++i) {- next();- }- assert ord == this.ord();+ throw new UnsupportedOperationException();}@Override@@ -870,7 +861,7 @@ public final class CompressingTermVectorsReader extends TermVectorsReader implem@Overridepublic long ord() throws IOException {- return ord;+ throw new UnsupportedOperationException();}@Overridediff --git a/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingTermVectorsFormat.java b/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingTermVectorsFormat.javaindex 7a9536210a9..7294315a26a 100644--- a/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingTermVectorsFormat.java+++ b/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestCompressingTermVectorsFormat.java@@ -1,7 +1,18 @@package org.apache.lucene.codecs.compressing;import org.apache.lucene.codecs.Codec;+import org.apache.lucene.document.Document;+import org.apache.lucene.document.Field;+import org.apache.lucene.document.FieldType;+import org.apache.lucene.document.TextField;+import org.apache.lucene.index.AtomicReader;import org.apache.lucene.index.BaseTermVectorsFormatTestCase;+import org.apache.lucene.index.RandomIndexWriter;+import org.apache.lucene.index.Terms;+import org.apache.lucene.index.TermsEnum;+import org.apache.lucene.index.TermsEnum.SeekStatus;+import org.apache.lucene.store.Directory;+import org.apache.lucene.util.BytesRef;/** Licensed to the Apache Software Foundation (ASF) under one or more@@ -27,4 +38,35 @@ public class TestCompressingTermVectorsFormat extends BaseTermVectorsFormatTestCreturn CompressingCodec.randomInstance(random());}+ // https://issues.apache.org/jira/browse/LUCENE-5156+ public void testNoOrds() throws Exception {+ Directory dir = newDirectory();+ RandomIndexWriter iw = new RandomIndexWriter(random(), dir);+ Document doc = new Document();+ FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);+ ft.setStoreTermVectors(true);+ doc.add(new Field("foo", "this is a test", ft));+ iw.addDocument(doc);+ AtomicReader ir = getOnlySegmentReader(iw.getReader());+ Terms terms = ir.getTermVector(0, "foo");+ assertNotNull(terms);+ TermsEnum termsEnum = terms.iterator(null);+ assertEquals(SeekStatus.FOUND, termsEnum.seekCeil(new BytesRef("this")));+ try {+ termsEnum.ord();+ fail();+ } catch (UnsupportedOperationException expected) {+ // expected exception+ }++ try {+ termsEnum.seekExact(0);+ fail();+ } catch (UnsupportedOperationException expected) {+ // expected exception+ }+ ir.close();+ iw.close();+ dir.close();+ }}