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

Examples of org.apache.lucene.facet.taxonomy.lucene.LuceneTaxonomyWriter.commit()


      throws Exception {
    SlowRAMDirectory indexDir =  new SlowRAMDirectory(-1,null); // no slowness for intialization
    TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
    tw.addCategory(new CategoryPath("a", "0"));
    tw.addCategory(abPath);
    tw.commit();
   
    final TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
    for (int i=0; i < 1<<10; i++) { //1024 facets
      final CategoryPath cp = new CategoryPath("a", "b", Integer.toString(i));
      tw.addCategory(cp);
View Full Code Here


    for (int i=0; i < 1<<10; i++) { //1024 facets
      final CategoryPath cp = new CategoryPath("a", "b", Integer.toString(i));
      tw.addCategory(cp);
      assertEquals("Ordinal of "+cp+" must be invalid until Taxonomy Reader was refreshed", TaxonomyReader.INVALID_ORDINAL, tr.getOrdinal(cp));
    }
    tw.commit();
   
    final boolean[] stop = new boolean[] { false };
    final Throwable[] error = new Throwable[] { null };
    final int retrieval[] = { 0 };
   
View Full Code Here

   */
  @Test
  public void testSeparateReaderAndWriter() throws Exception {
    Directory indexDir = newDirectory();
    TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
    tw.commit();
    TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);

    int author = 1;

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

    // the parent of this category is correct (this requires the reader
    // 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());
View Full Code Here

 
  @Test
  public void testSeparateReaderAndWriter2() throws Exception {
    Directory indexDir = newDirectory();
    TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
    tw.commit();
    TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);

    // Test getOrdinal():
    CategoryPath author = new CategoryPath("Author");
View Full Code Here

    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));
    assertEquals(1, tr.getSize()); // still root only...
    tr.refresh(); // finally
    assertEquals(1, tr.getOrdinal(author));
View Full Code Here

  public void testWriterLock() throws Exception {
    // native fslock impl gets angry if we use it, so use RAMDirectory explicitly.
    Directory indexDir = new RAMDirectory();
    TaxonomyWriter tw = new LuceneTaxonomyWriter(indexDir);
    tw.addCategory(new CategoryPath("hi", "there"));
    tw.commit();
    // we deliberately not close the write now, and keep it open and
    // locked.
    // Verify that the writer worked:
    TaxonomyReader tr = new LuceneTaxonomyReader(indexDir);
    assertEquals(2, tr.getOrdinal(new CategoryPath("hi", "there")));
View Full Code Here

    PerDimensionIndexingParams iParams = new PerDimensionIndexingParams();

    seedIndex(iw, tw, iParams);

    IndexReader ir = iw.getReader();
    tw.commit();

    // prepare index reader and taxonomy.
    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
View Full Code Here

    iParams.addCategoryListParams(new CategoryPath("Author"),
        new CategoryListParams(new Term("$author", "Authors")));
    seedIndex(iw, tw, iParams);

    IndexReader ir = iw.getReader();
    tw.commit();

    // prepare index reader and taxonomy.
    TaxonomyReader tr = new LuceneTaxonomyReader(dirs[0][1]);

    // prepare searcher to search against
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.