Index: lucene/CHANGES.txt =================================================================== --- lucene/CHANGES.txt (revision 1457553) +++ lucene/CHANGES.txt (working copy) @@ -91,7 +91,12 @@ * LUCENE-4819: Added Sorted[Set]DocValues.termsEnum(), and optimized the default codec for improved enumeration performance. (Robert Muir) + +API Changes +* LUCENE-4844: removed TaxonomyReader.getParent(), you should use + TaxonomyReader.getParallelArrays().parents() instead. (Shai Erera) + Bug Fixes * LUCENE-4819: seekExact(BytesRef, boolean) did not work correctly with Index: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java =================================================================== --- lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java (revision 1457553) +++ lucene/facet/src/java/org/apache/lucene/facet/taxonomy/TaxonomyReader.java (working copy) @@ -186,25 +186,6 @@ */ public abstract int getOrdinal(CategoryPath categoryPath) throws IOException; - /** - * Returns the ordinal of the parent category of the category with the given - * ordinal, according to the following rules: - * - * - * - * @throws ArrayIndexOutOfBoundsException - * if an invalid ordinal is given (negative or beyond the last - * available ordinal) - */ - public abstract int getParent(int ordinal) throws IOException; - /** Returns the path name of the category with the given ordinal. */ public abstract CategoryPath getPath(int ordinal) throws IOException; Index: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java =================================================================== --- lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java (revision 1457553) +++ lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java (working copy) @@ -293,12 +293,6 @@ } @Override - public int getParent(int ordinal) throws IOException { - ensureOpen(); - return getParallelTaxonomyArrays().parents()[ordinal]; - } - - @Override public CategoryPath getPath(int ordinal) throws IOException { ensureOpen(); Index: lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java =================================================================== --- lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java (revision 1457553) +++ lucene/facet/src/test/org/apache/lucene/facet/taxonomy/TestTaxonomyCombined.java (working copy) @@ -35,7 +35,6 @@ * limitations under the License. */ -// TODO: remove this suppress if we fix the TaxoWriter Codec to a non-default (see todo in DirTW) @SuppressCodecs("SimpleText") public class TestTaxonomyCombined extends FacetTestCase { @@ -305,7 +304,7 @@ TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir); assertEquals(1, tr.getSize()); assertEquals(0, tr.getPath(0).length); - assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(0)); + assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParallelTaxonomyArrays().parents()[0]); assertEquals(0, tr.getOrdinal(CategoryPath.EMPTY)); tr.close(); indexDir.close(); @@ -324,7 +323,7 @@ TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir); assertEquals(1, tr.getSize()); assertEquals(0, tr.getPath(0).length); - assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(0)); + assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParallelTaxonomyArrays().parents()[0]); assertEquals(0, tr.getOrdinal(CategoryPath.EMPTY)); tw.close(); tr.close(); @@ -404,12 +403,13 @@ TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir); // check that the parent of the root ordinal is the invalid ordinal: - assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(0)); + int[] parents = tr.getParallelTaxonomyArrays().parents(); + assertEquals(TaxonomyReader.INVALID_ORDINAL, parents[0]); // check parent of non-root ordinals: for (int ordinal=1; ordinali; j--) { - if (tr.getParent(j)==i) { + if (parents[j]==i) { break; // found youngest child } } @@ -687,7 +648,7 @@ // Find the youngest older sibling: int j; for (j=i-1; j>=0; j--) { - if (tr.getParent(j)==tr.getParent(i)) { + if (parents[j]==parents[i]) { break; // found youngest older sibling } } @@ -879,47 +840,21 @@ tw.commit(); TaxonomyReader tr = new DirectoryTaxonomyReader(indexDir); - int author = 1; - - // getParent() and getSize() test: - try { - tr.getParent(author); - fail("Initially, getParent for "+author+" should throw exception"); - } catch (ArrayIndexOutOfBoundsException e) { - // ok - } assertEquals(1, tr.getSize()); // the empty taxonomy has size 1 (the root) tw.addCategory(new CategoryPath("Author")); - try { - tr.getParent(author); - fail("Before commit() and refresh(), getParent for "+author+" should still throw exception"); - } catch (ArrayIndexOutOfBoundsException e) { - // ok - } assertEquals(1, tr.getSize()); // still root only... assertNull(TaxonomyReader.openIfChanged(tr)); // this is not enough, because tw.commit() hasn't been done yet - try { - tr.getParent(author); - fail("Before commit() and refresh(), getParent for "+author+" should still throw exception"); - } catch (ArrayIndexOutOfBoundsException e) { - // ok - } assertEquals(1, tr.getSize()); // still root only... tw.commit(); - try { - tr.getParent(author); - fail("Before refresh(), getParent for "+author+" should still throw exception"); - } catch (ArrayIndexOutOfBoundsException e) { - // ok - } assertEquals(1, tr.getSize()); // still root only... TaxonomyReader newTaxoReader = TaxonomyReader.openIfChanged(tr); assertNotNull(newTaxoReader); tr.close(); tr = newTaxoReader; + int author = 1; try { - assertEquals(TaxonomyReader.ROOT_ORDINAL, tr.getParent(author)); + assertEquals(TaxonomyReader.ROOT_ORDINAL, tr.getParallelTaxonomyArrays().parents()[author]); // ok } catch (ArrayIndexOutOfBoundsException e) { fail("After category addition, commit() and refresh(), getParent for "+author+" should NOT throw exception"); @@ -937,9 +872,10 @@ assertNotNull(newTaxoReader); tr.close(); tr = newTaxoReader; - assertEquals(author, tr.getParent(dawkins)); - assertEquals(TaxonomyReader.ROOT_ORDINAL, tr.getParent(author)); - assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(TaxonomyReader.ROOT_ORDINAL)); + int[] parents = tr.getParallelTaxonomyArrays().parents(); + assertEquals(author, parents[dawkins]); + assertEquals(TaxonomyReader.ROOT_ORDINAL, parents[author]); + assertEquals(TaxonomyReader.INVALID_ORDINAL, parents[TaxonomyReader.ROOT_ORDINAL]); assertEquals(3, tr.getSize()); tw.close(); tr.close();