LUCENE-5156: remove seek-by-ord from CompressingTermVectors

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1511009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-08-06 15:50:50 +00:00
parent 74549edd2f
commit e375cfa331
3 changed files with 47 additions and 11 deletions

View File

@ -146,6 +146,9 @@ API Changes
should match for its high and low frequent sub-queries. Previously this was only
supported 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.

View File

@ -851,16 +851,7 @@ public final class CompressingTermVectorsReader extends TermVectorsReader implem
@Override
public 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
@Override
public long ord() throws IOException {
return ord;
throw new UnsupportedOperationException();
}
@Override

View File

@ -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 BaseTermVectorsFormatTestC
return 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();
}
}