当前位置: 首页>>代码示例>>Java>>正文


Java TaxonomyReader.incRef方法代码示例

本文整理汇总了Java中org.apache.lucene.facet.taxonomy.TaxonomyReader.incRef方法的典型用法代码示例。如果您正苦于以下问题:Java TaxonomyReader.incRef方法的具体用法?Java TaxonomyReader.incRef怎么用?Java TaxonomyReader.incRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.facet.taxonomy.TaxonomyReader的用法示例。


在下文中一共展示了TaxonomyReader.incRef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testOpenIfChangedAndRefCount

import org.apache.lucene.facet.taxonomy.TaxonomyReader; //导入方法依赖的package包/类
@Test
public void testOpenIfChangedAndRefCount() throws Exception {
  Directory dir = new RAMDirectory(); // no need for random directories here

  DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(dir);
  taxoWriter.addCategory(new FacetLabel("a"));
  taxoWriter.commit();

  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(dir);
  assertEquals("wrong refCount", 1, taxoReader.getRefCount());

  taxoReader.incRef();
  assertEquals("wrong refCount", 2, taxoReader.getRefCount());

  taxoWriter.addCategory(new FacetLabel("a", "b"));
  taxoWriter.commit();
  TaxonomyReader newtr = TaxonomyReader.openIfChanged(taxoReader);
  assertNotNull(newtr);
  taxoReader.close();
  taxoReader = newtr;
  assertEquals("wrong refCount", 1, taxoReader.getRefCount());

  taxoWriter.close();
  taxoReader.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:TestDirectoryTaxonomyReader.java

示例2: testOpenIfChangedAndRefCount

import org.apache.lucene.facet.taxonomy.TaxonomyReader; //导入方法依赖的package包/类
@Test
public void testOpenIfChangedAndRefCount() throws Exception {
  Directory dir = new RAMDirectory(); // no need for random directories here

  DirectoryTaxonomyWriter taxoWriter = new DirectoryTaxonomyWriter(dir);
  taxoWriter.addCategory(new CategoryPath("a"));
  taxoWriter.commit();

  TaxonomyReader taxoReader = new DirectoryTaxonomyReader(dir);
  assertEquals("wrong refCount", 1, taxoReader.getRefCount());

  taxoReader.incRef();
  assertEquals("wrong refCount", 2, taxoReader.getRefCount());

  taxoWriter.addCategory(new CategoryPath("a", "b"));
  taxoWriter.commit();
  TaxonomyReader newtr = TaxonomyReader.openIfChanged(taxoReader);
  assertNotNull(newtr);
  taxoReader.close();
  taxoReader = newtr;
  assertEquals("wrong refCount", 1, taxoReader.getRefCount());

  taxoWriter.close();
  taxoReader.close();
  dir.close();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:TestDirectoryTaxonomyReader.java

示例3: setTaxonomyReader

import org.apache.lucene.facet.taxonomy.TaxonomyReader; //导入方法依赖的package包/类
/**
 * Set the taxonomy reader. Takes ownership of that taxonomy reader, that is,
 * internally performs taxoReader.incRef() (If caller no longer needs that 
 * reader it should decRef()/close() it after calling this method, otherwise, 
 * the reader will remain open). 
 * @param taxoReader The taxonomy reader to set.
 */
public synchronized void setTaxonomyReader(TaxonomyReader taxoReader) throws IOException {
  if (taxoReader == this.taxonomyReader) {
    return;
  }
  if (taxonomyReader != null) {
    taxonomyReader.decRef();
  }
  
  if (taxoReader != null) {
    taxoReader.incRef();
  }
  this.taxonomyReader = taxoReader;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:PerfRunData.java


注:本文中的org.apache.lucene.facet.taxonomy.TaxonomyReader.incRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。