From 91e37bf1fb8958ec5b7b9f20a7a7543f1dcd32ca Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Thu, 23 Jul 2009 00:02:48 +0000 Subject: [PATCH] LUCENE-1609: un-deprecate IndexReader.getTermInfosIndexDivisor git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@796916 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/index/DirectoryReader.java | 4 ++++ src/java/org/apache/lucene/index/IndexReader.java | 7 +++---- src/java/org/apache/lucene/index/SegmentReader.java | 3 +++ src/test/org/apache/lucene/index/TestIndexReader.java | 1 + src/test/org/apache/lucene/index/TestSegmentTermDocs.java | 1 + 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/lucene/index/DirectoryReader.java b/src/java/org/apache/lucene/index/DirectoryReader.java index aac91210b4c..60d4525840b 100644 --- a/src/java/org/apache/lucene/index/DirectoryReader.java +++ b/src/java/org/apache/lucene/index/DirectoryReader.java @@ -846,6 +846,10 @@ class DirectoryReader extends IndexReader implements Cloneable { return directory; } + public int getTermInfosIndexDivisor() { + return termInfosIndexDivisor; + } + /** * Expert: return the IndexCommit that this reader has opened. *

diff --git a/src/java/org/apache/lucene/index/IndexReader.java b/src/java/org/apache/lucene/index/IndexReader.java index 960813e2878..0c4e28db114 100644 --- a/src/java/org/apache/lucene/index/IndexReader.java +++ b/src/java/org/apache/lucene/index/IndexReader.java @@ -736,12 +736,11 @@ public abstract class IndexReader implements Cloneable { /**

For IndexReader implementations that use * TermInfosReader to read terms, this returns the - * current indexDivisor. - * @see #setTermInfosIndexDivisor - * @deprecated Please use {@link IndexReader#open(Directory, IndexDeletionPolicy, boolean, int)} to specify the required TermInfos index divisor instead. + * current indexDivisor as specified when the reader was + * opened. */ public int getTermInfosIndexDivisor() { - throw new UnsupportedOperationException("Please pass termInfosIndexDivisor up-front when opening IndexReader"); + throw new UnsupportedOperationException("This reader does not support this method."); } /** diff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.java index ab6698c2a72..6735b33a92f 100644 --- a/src/java/org/apache/lucene/index/SegmentReader.java +++ b/src/java/org/apache/lucene/index/SegmentReader.java @@ -1355,4 +1355,7 @@ public class SegmentReader extends IndexReader implements Cloneable { throw new IllegalArgumentException(reader + " is not a SegmentReader or a single-segment DirectoryReader"); } + public int getTermInfosIndexDivisor() { + return core.termsIndexDivisor; + } } diff --git a/src/test/org/apache/lucene/index/TestIndexReader.java b/src/test/org/apache/lucene/index/TestIndexReader.java index 2e3e3ff0530..90593558348 100644 --- a/src/test/org/apache/lucene/index/TestIndexReader.java +++ b/src/test/org/apache/lucene/index/TestIndexReader.java @@ -1821,6 +1821,7 @@ public class TestIndexReader extends LuceneTestCase } assertFalse(((SegmentReader) r.getSequentialSubReaders()[0]).termsIndexLoaded()); + assertEquals(-1, r.getTermInfosIndexDivisor()); writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED); writer.addDocument(doc); writer.close(); diff --git a/src/test/org/apache/lucene/index/TestSegmentTermDocs.java b/src/test/org/apache/lucene/index/TestSegmentTermDocs.java index 1b44b293aa9..752f36007d7 100644 --- a/src/test/org/apache/lucene/index/TestSegmentTermDocs.java +++ b/src/test/org/apache/lucene/index/TestSegmentTermDocs.java @@ -54,6 +54,7 @@ public class TestSegmentTermDocs extends LuceneTestCase { //After adding the document, we should be able to read it back in SegmentReader reader = SegmentReader.get(true, info, indexDivisor); assertTrue(reader != null); + assertEquals(indexDivisor, reader.getTermInfosIndexDivisor()); SegmentTermDocs segTermDocs = new SegmentTermDocs(reader); assertTrue(segTermDocs != null); segTermDocs.seek(new Term(DocHelper.TEXT_FIELD_2_KEY, "field"));