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


Java Collector.setNextReader方法代码示例

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


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

示例1: testNullCollectors

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
@Test
public void testNullCollectors() throws Exception {
  // Tests that the collector rejects all null collectors.
  try {
    MultiCollector.wrap(null, null);
    fail("only null collectors should not be supported");
  } catch (IllegalArgumentException e) {
    // expected
  }

  // Tests that the collector handles some null collectors well. If it
  // doesn't, an NPE would be thrown.
  Collector c = MultiCollector.wrap(new DummyCollector(), null, new DummyCollector());
  assertTrue(c instanceof MultiCollector);
  assertTrue(c.acceptsDocsOutOfOrder());
  c.collect(1);
  c.setNextReader(null);
  c.setScorer(null);
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:MultiCollectorTest.java

示例2: testCollector

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
@Test
public void testCollector() throws Exception {
  // Tests that the collector delegates calls to input collectors properly.

  // Tests that the collector handles some null collectors well. If it
  // doesn't, an NPE would be thrown.
  DummyCollector[] dcs = new DummyCollector[] { new DummyCollector(), new DummyCollector() };
  Collector c = MultiCollector.wrap(dcs);
  assertTrue(c.acceptsDocsOutOfOrder());
  c.collect(1);
  c.setNextReader(null);
  c.setScorer(null);

  for (DummyCollector dc : dcs) {
    assertTrue(dc.acceptsDocsOutOfOrderCalled);
    assertTrue(dc.collectCalled);
    assertTrue(dc.setNextReaderCalled);
    assertTrue(dc.setScorerCalled);
  }

}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:MultiCollectorTest.java

示例3: getSecureCollector

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
protected Collector getSecureCollector(final Collector collector) {
  return new Collector() {

    @Override
    public void setScorer(Scorer scorer) throws IOException {
      collector.setScorer(scorer);
    }

    @Override
    public void setNextReader(AtomicReaderContext context) throws IOException {
      Object key = context.reader().getCoreCacheKey();
      AtomicReaderContext atomicReaderContext = _leaveMap.get(key);
      collector.setNextReader(atomicReaderContext);
    }

    @Override
    public void collect(int doc) throws IOException {
      collector.collect(doc);
    }

    @Override
    public boolean acceptsDocsOutOfOrder() {
      return collector.acceptsDocsOutOfOrder();
    }
  };
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:27,代码来源:SecureIndexSearcher.java

示例4: setNextReader

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
@Override
public void setNextReader(AtomicReaderContext context) throws IOException {
  for (Collector c : collectors) {
    c.setNextReader(context);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:MultiCollector.java

示例5: getDocSet

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
/**
 * Returns the set of document ids matching all queries.
 * This method is cache-aware and attempts to retrieve the answer from the cache if possible.
 * If the answer was not cached, it may have been inserted into the cache as a result of this call.
 * This method can handle negative queries.
 * <p>
 * The DocSet returned should <b>not</b> be modified.
 */
public DocSet getDocSet(List<Query> queries) throws IOException {

  if(queries != null) {
    for(Query q : queries) {
      if(q instanceof ScoreFilter) {
        return getDocSetScore(queries);
      }
    }
  }

  ProcessedFilter pf = getProcessedFilter(null, queries);
  if (pf.answer != null) return pf.answer;


  DocSetCollector setCollector = new DocSetCollector(maxDoc()>>6, maxDoc());
  Collector collector = setCollector;
  if (pf.postFilter != null) {
    pf.postFilter.setLastDelegate(collector);
    collector = pf.postFilter;
  }

  for (final AtomicReaderContext leaf : leafContexts) {
    final AtomicReader reader = leaf.reader();
    final Bits liveDocs = reader.getLiveDocs();   // TODO: the filter may already only have liveDocs...
    DocIdSet idSet = null;
    if (pf.filter != null) {
      idSet = pf.filter.getDocIdSet(leaf, liveDocs);
      if (idSet == null) continue;
    }
    DocIdSetIterator idIter = null;
    if (idSet != null) {
      idIter = idSet.iterator();
      if (idIter == null) continue;
    }

    collector.setNextReader(leaf);
    int max = reader.maxDoc();

    if (idIter == null) {
      for (int docid = 0; docid<max; docid++) {
        if (liveDocs != null && !liveDocs.get(docid)) continue;
        collector.collect(docid);
      }
    } else {
      for (int docid = -1; (docid = idIter.advance(docid+1)) < max; ) {
        collector.collect(docid);
      }
    }
  }

  if(collector instanceof DelegatingCollector) {
    ((DelegatingCollector) collector).finish();
  }

  return setCollector.getDocSet();
}
 
开发者ID:europeana,项目名称:search,代码行数:65,代码来源:SolrIndexSearcher.java

示例6: setNextReader

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
public void setNextReader(AtomicReaderContext context) throws IOException {
  this.docBase = context.docBase;
  for (Collector c : collectors) {
    c.setNextReader(context);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:7,代码来源:ExpandComponent.java

示例7: getDocSet

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
/**
 * Returns the set of document ids matching all queries.
 * This method is cache-aware and attempts to retrieve the answer from the cache if possible.
 * If the answer was not cached, it may have been inserted into the cache as a result of this call.
 * This method can handle negative queries.
 * <p>
 * The DocSet returned should <b>not</b> be modified.
 */
public DocSet getDocSet(List<Query> queries) throws IOException {
  ProcessedFilter pf = getProcessedFilter(null, queries);
  if (pf.answer != null) return pf.answer;


  DocSetCollector setCollector = new DocSetCollector(maxDoc()>>6, maxDoc());
  Collector collector = setCollector;
  if (pf.postFilter != null) {
    pf.postFilter.setLastDelegate(collector);
    collector = pf.postFilter;
  }

  for (final AtomicReaderContext leaf : leafContexts) {
    final AtomicReader reader = leaf.reader();
    final Bits liveDocs = reader.getLiveDocs();   // TODO: the filter may already only have liveDocs...
    DocIdSet idSet = null;
    if (pf.filter != null) {
      idSet = pf.filter.getDocIdSet(leaf, liveDocs);
      if (idSet == null) continue;
    }
    DocIdSetIterator idIter = null;
    if (idSet != null) {
      idIter = idSet.iterator();
      if (idIter == null) continue;
    }

    collector.setNextReader(leaf);
    int max = reader.maxDoc();

    if (idIter == null) {
      for (int docid = 0; docid<max; docid++) {
        if (liveDocs != null && !liveDocs.get(docid)) continue;
        collector.collect(docid);
      }
    } else {
      for (int docid = -1; (docid = idIter.advance(docid+1)) < max; ) {
        collector.collect(docid);
      }
    }
  }

  return setCollector.getDocSet();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:52,代码来源:SolrIndexSearcher.java

示例8: getDocSet

import org.apache.lucene.search.Collector; //导入方法依赖的package包/类
/**
 * Returns the set of document ids matching all queries. This method is cache-aware and attempts
 * to retrieve the answer from the cache if possible. If the answer was not cached, it may have
 * been inserted into the cache as a result of this call. This method can handle negative
 * queries.
 * <p>
 * The DocSet returned should <b>not</b> be modified.
 */
public DocSet getDocSet(List<Query> queries) throws IOException {
	ProcessedFilter pf = getProcessedFilter(null, queries);
	if(pf.answer != null)
		return pf.answer;

	DocSetCollector setCollector = new DocSetCollector(maxDoc() >> 6, maxDoc());
	Collector collector = setCollector;
	if(pf.postFilter != null) {
		pf.postFilter.setLastDelegate(collector);
		collector = pf.postFilter;
	}

	for(final AtomicReaderContext leaf : leafContexts) {
		final AtomicReader reader = leaf.reader();
		final Bits liveDocs = reader.getLiveDocs(); // TODO: the filter may already only have liveDocs...
		DocIdSet idSet = null;
		if(pf.filter != null) {
			idSet = pf.filter.getDocIdSet(leaf, liveDocs);
			if(idSet == null)
				continue;
		}
		DocIdSetIterator idIter = null;
		if(idSet != null) {
			idIter = idSet.iterator();
			if(idIter == null)
				continue;
		}

		collector.setNextReader(leaf);
		int max = reader.maxDoc();

		if(idIter == null) {
			for(int docid = 0; docid < max; docid++) {
				if(liveDocs != null && !liveDocs.get(docid))
					continue;
				collector.collect(docid);
			}
		} else {
			for(int docid = -1; (docid = idIter.advance(docid + 1)) < max;) {
				collector.collect(docid);
			}
		}
	}

	return setCollector.getDocSet();
}
 
开发者ID:netboynb,项目名称:search-core,代码行数:55,代码来源:SolrIndexSearcher.java


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