Package org.apache.lucene.facet.taxonomy.directory

Examples of org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader.refresh()


    assertSame(newca, ca); // we got exactly the same object
    assertEquals(3, tr.getSize());
    assertEquals(3, ca.getOlderSiblingArray().length);
    assertEquals(3, ca.getYoungestChildArray().length);
    // After the refresh, things change:
    tr.refresh();
    ca = tr.getChildrenArrays();
    assertEquals(5, tr.getSize());
    assertEquals(5, ca.getOlderSiblingArray().length);
    assertEquals(5, ca.getYoungestChildArray().length);
    assertTrue(Arrays.equals(new int[] { 4, 3, -1, -1, -1 }, ca.getYoungestChildArray()));
View Full Code Here


    for (int i=0; i < 1<<10; i++) { //1024 facets
      twBase.addCategory(new CategoryPath("a", "b", Integer.toString(i)));
    }
    twBase.commit();
   
    trBase.refresh();
   
    final ChildrenArrays ca2 = trBase.getChildrenArrays();
    final int abYoungChildBase2 = ca2.getYoungestChildArray()[abOrd];
   
    for (int retry=0; retry<100; retry++) {
View Full Code Here

      }
    };
    thread.start();
   
    indexDir.setSleepMillis(1); // some delay for refresh
    tr.refresh();
   
    stop[0] = true;
    thread.join();
    assertNull("Unexpcted exception at retry "+retry+" retrieval "+retrieval[0]+": \n"+stackTraceStr(error[0]), error[0]);
   
View Full Code Here

      fail("Before commit() and refresh(), getParent for "+author+" should still throw exception");
    } catch (ArrayIndexOutOfBoundsException e) {
      // ok
    }
    assertEquals(1, tr.getSize()); // still root only...
    tr.refresh(); // 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
View Full Code Here

      fail("Before refresh(), getParent for "+author+" should still throw exception");
    } catch (ArrayIndexOutOfBoundsException e) {
      // ok
    }
    assertEquals(1, tr.getSize()); // still root only...
    tr.refresh();
    try {
      assertEquals(TaxonomyReader.ROOT_ORDINAL, tr.getParent(author));
      // ok
    } catch (ArrayIndexOutOfBoundsException e) {
      fail("After category addition, commit() and refresh(), getParent for "+author+" should NOT throw exception");
View Full Code Here

    // to correctly update its prefetched parent vector), and that the
    // old information also wasn't ruined:
    tw.addCategory(new CategoryPath("Author", "Richard Dawkins"));
    int dawkins = 2;
    tw.commit();
    tr.refresh();
    assertEquals(author, tr.getParent(dawkins));
    assertEquals(TaxonomyReader.ROOT_ORDINAL, tr.getParent(author));
    assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getParent(TaxonomyReader.ROOT_ORDINAL));
    assertEquals(3, tr.getSize());
    tw.close();
View Full Code Here

    assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getOrdinal(author));
    tw.addCategory(author);
    // before commit and refresh, no change:
    assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getOrdinal(author));
    assertEquals(1, tr.getSize()); // still root only...
    tr.refresh(); // this is not enough, because tw.commit() hasn't been done yet
    assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getOrdinal(author));
    assertEquals(1, tr.getSize()); // still root only...
    tw.commit();
    // still not enough before refresh:
    assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getOrdinal(author));
View Full Code Here

    assertEquals(1, tr.getSize()); // still root only...
    tw.commit();
    // still not enough before refresh:
    assertEquals(TaxonomyReader.INVALID_ORDINAL, tr.getOrdinal(author));
    assertEquals(1, tr.getSize()); // still root only...
    tr.refresh(); // finally
    assertEquals(1, tr.getOrdinal(author));
    assertEquals(2, tr.getSize()); // still root only...
    tw.close();
    tr.close();
    indexDir.close();
View Full Code Here

    DirectoryTaxonomyWriter.unlock(indexDir);
    TaxonomyWriter tw2 = new DirectoryTaxonomyWriter(indexDir);
    tw2.addCategory(new CategoryPath("hey"));
    tw2.close();
    // See that the writer indeed wrote:
    tr.refresh();
    assertEquals(3, tr.getOrdinal(new CategoryPath("hey")));
    tr.close();
    tw.close();
    indexDir.close();
  }
View Full Code Here

    tw.close();
    assertEquals(0, checker.nopen());

    DirectoryTaxonomyReader tr = checker.openReader(dir);
    tr.getPath(1);
    tr.refresh();
    tr.close();
    assertEquals(0, checker.nopen());

    tr = checker.openReader(dir);
    tw = checker.openWriter(dir);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.