You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/04/05 21:20:48 UTC
[GitHub] [lucene] gautamworah96 commented on a diff in pull request #762: LUCENE-10482 Allow users to create their own DirectoryTaxonomyReaders with empty taxoArrays instead of letting the taxoEpoch decide
gautamworah96 commented on code in PR #762:
URL: https://github.com/apache/lucene/pull/762#discussion_r843271841
##########
lucene/facet/src/test/org/apache/lucene/facet/taxonomy/directory/TestAlwaysRefreshDirectoryTaxonomyReader.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.facet.taxonomy.directory;
+
+import java.io.IOException;
+import org.apache.lucene.facet.FacetTestCase;
+import org.apache.lucene.facet.taxonomy.FacetLabel;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.IOUtils;
+import org.junit.Test;
+
+public class TestAlwaysRefreshDirectoryTaxonomyReader extends FacetTestCase {
+
+ @Test
+ /**
+ * Tests the expert constructors in {@link DirectoryTaxonomyReader} and checks the {@link
+ * DirectoryTaxonomyReader#getInternalIndexReader()} API. Also demonstrates the need for the
+ * constructor and the API.
+ *
+ * <p>It does not check whether the private taxoArrays were actually recreated or no. We are
+ * (correctly) hiding away that complexity away from the user.
+ */
+ public void testAlwaysRefreshDirectoryTaxonomyReader() throws IOException {
+ Directory dir = newDirectory();
+ DirectoryTaxonomyWriter tw = new DirectoryTaxonomyWriter(dir);
+ tw.addCategory(new FacetLabel("a"));
+ tw.commit();
+
+ DirectoryTaxonomyReader dtr1 = new AlwaysRefreshDirectoryTaxonomyReader(dir);
+ tw.addCategory(new FacetLabel("b"));
+ tw.commit();
+ DirectoryTaxonomyReader dtr2 = dtr1.doOpenIfChanged();
Review Comment:
> his is not really testing the unique capability of AlwaysRefreshDTR
Yes and that was the cause of my hesitation in the first comment (I had also mentioned this in the first commit javadoc). The next commit adds the correct test case where DTR fails to pass the use case.
> maybe by creating a method returning taxoArray == null?
That was another way but I did not want to add another API to just be able to demonstrate a rare/expert use case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org