作者:eea1051113 | 来源:互联网 | 2023-06-05 11:42
本文整理了Java中org.apache.lucene.util.PriorityQueue.spliterator()方法的一些代码示例,展示了PriorityQueue.spliterator()
本文整理了Java中org.apache.lucene.util.PriorityQueue.spliterator()
方法的一些代码示例,展示了PriorityQueue.spliterator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PriorityQueue.spliterator()
方法的具体详情如下:
包路径:org.apache.lucene.util.PriorityQueue
类名称:PriorityQueue
方法名:spliterator
PriorityQueue.spliterator介绍
暂无
代码示例
代码示例来源:origin: org.apache.lucene/lucene-core
static long cost(LongStream costs, int numScorers, int minShouldMatch) {
// the idea here is the following: a boolean query c1,c2,...cn with minShouldMatch=m
// could be rewritten to:
// (c1 AND (c2..cn|msm=m-1)) OR (!c1 AND (c2..cn|msm=m))
// if we assume that clauses come in ascending cost, then
// the cost of the first part is the cost of c1 (because the cost of a conjunction is
// the cost of the least costly clause)
// the cost of the second part is the cost of finding m matches among the c2...cn
// remaining clauses
// since it is a disjunction overall, the total cost is the sum of the costs of these
// two parts
// If we recurse infinitely, we find out that the cost of a msm query is the sum of the
// costs of the num_scorers - minShouldMatch + 1 least costly scorers
final PriorityQueue pq = new PriorityQueue(numScorers - minShouldMatch + 1) {
@Override
protected boolean lessThan(Long a, Long b) {
return a > b;
}
};
costs.forEach(pq::insertWithOverflow);
return StreamSupport.stream(pq.spliterator(), false).mapToLong(Number::longValue).sum();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
static long cost(LongStream costs, int numScorers, int minShouldMatch) {
// the idea here is the following: a boolean query c1,c2,...cn with minShouldMatch=m
// could be rewritten to:
// (c1 AND (c2..cn|msm=m-1)) OR (!c1 AND (c2..cn|msm=m))
// if we assume that clauses come in ascending cost, then
// the cost of the first part is the cost of c1 (because the cost of a conjunction is
// the cost of the least costly clause)
// the cost of the second part is the cost of finding m matches among the c2...cn
// remaining clauses
// since it is a disjunction overall, the total cost is the sum of the costs of these
// two parts
// If we recurse infinitely, we find out that the cost of a msm query is the sum of the
// costs of the num_scorers - minShouldMatch + 1 least costly scorers
final PriorityQueue pq = new PriorityQueue(numScorers - minShouldMatch + 1) {
@Override
protected boolean lessThan(Long a, Long b) {
return a > b;
}
};
costs.forEach(pq::insertWithOverflow);
return StreamSupport.stream(pq.spliterator(), false).mapToLong(Number::longValue).sum();
}