本文整理了Java中org.apache.lucene.util.PriorityQueue.updateTop()
方法的一些代码示例,展示了PriorityQueue.updateTop()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PriorityQueue.updateTop()
方法的具体详情如下:
包路径:org.apache.lucene.util.PriorityQueue
类名称:PriorityQueue
方法名:updateTop
PriorityQueue.updateTop介绍
[英]Should be called when the Object at top changes values. Still log(n) worst case, but it's at least twice as fast to
pq.top().change();
pq.updateTop();
instead of
o = pq.pop();
o.change();
pq.push(o);
[中]应在顶部的对象更改值时调用。在最坏的情况下仍会记录(n),但速度至少是<<0$>>的两倍,而不是<<1$>>
代码示例
代码示例来源:origin: org.apache.lucene/lucene-core
final void updateBottom(int doc) {
// bottom.score is already set to Float.NaN in add().
bottom.doc = docBase + doc;
bottom = pq.updateTop();
}
代码示例来源:origin: org.apache.lucene/lucene-core
final void updateBottom(int doc, float score) {
bottom.doc = docBase + doc;
bottom.score = score;
bottom = pq.updateTop();
}
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Replace the top of the pq with {@code newTop} and run {@link #updateTop()}.
*/
public final T updateTop(T newTop) {
heap[1] = newTop;
return updateTop();
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public void collect(int doc) throws IOException {
float score = scorer.score();
// This collector cannot handle these scores:
assert score != Float.NEGATIVE_INFINITY;
assert !Float.isNaN(score);
totalHits++;
if (score <= pqTop.score) {
// Since docs are returned in-order (i.e., increasing doc Id), a document
// with equal score to pqTop.score cannot compete since HitQueue favors
// documents with lower doc Ids. Therefore reject those docs too.
return;
}
pqTop.doc = doc + docBase;
pqTop.score = score;
pqTop = pq.updateTop();
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public void collect(int doc) throws IOException {
float score = scorer.score();
// This collector cannot handle these scores:
assert score != Float.NEGATIVE_INFINITY;
assert !Float.isNaN(score);
totalHits++;
if (score > after.score || (score == after.score && doc <= afterDoc)) {
// hit was collected on a previous page
return;
}
if (score <= pqTop.score) {
// Since docs are returned in-order (i.e., increasing doc Id), a document
// with equal score to pqTop.score cannot compete since HitQueue favors
// documents with lower doc Ids. Therefore reject those docs too.
return;
}
collectedHits++;
pqTop.doc = doc + docBase;
pqTop.score = score;
pqTop = pq.updateTop();
}
};
代码示例来源:origin: org.apache.lucene/lucene-core
/**
* Adds an Object to a PriorityQueue in log(size) time.
* It returns the object (if any) that was
* dropped off the heap because it was full. This can be
* the given parameter (in case it is smaller than the
* full heap's minimum, and couldn't be added), or another
* object that was previously the smallest value in the
* heap and now has been replaced by a larger one, or null
* if the queue wasn't yet full with maxSize elements.
*/
public T insertWithOverflow(T element) {
if (size add(element);
return null;
} else if (size > 0 && !lessThan(element, heap[1])) {
T ret = heap[1];
heap[1] = element;
updateTop();
return ret;
} else {
return element;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public boolean next() throws IOException {
if (started == false) {
return started = true;
}
if (queue.top().next() == false) {
queue.pop();
}
if (queue.size() > 0) {
queue.updateTop();
return true;
}
return false;
}
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public T next() throws IOException {
T top = queue.top();
while (true) {
int docID = top.nextDoc();
if (docID == NO_MORE_DOCS) {
queue.pop();
top = queue.top();
break;
}
int mappedDocID = top.docMap.get(docID);
if (mappedDocID == -1) {
// doc was deleted
continue;
} else {
top.mappedDocID = mappedDocID;
top = queue.updateTop();
break;
}
}
return top;
}
}
代码示例来源:origin: org.apache.lucene/lucene-core
queue.updateTop();
} else {
queue.pop();
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public int nextDoc() {
// Advance all sub iterators past current doc
while (true) {
if (queue.size() == 0) {
doc = NO_MORE_DOCS;
break;
}
int newDoc = queue.top().docID();
if (newDoc != doc) {
assert newDoc > doc: "doc=" + doc + " newDoc=" + newDoc;
doc = newDoc;
break;
}
if (queue.top().nextDoc() == NO_MORE_DOCS) {
queue.pop();
} else {
queue.updateTop();
}
}
return doc;
}
代码示例来源:origin: org.apache.lucene/lucene-core
queue.updateTop();
} else {
queue.pop();
代码示例来源:origin: org.apache.lucene/lucene-core
@Override
public int nextPosition() throws IOException {
if (started == false) {
started = true;
return posQueue.top().pos;
}
if (posQueue.top().upto == 1) {
posQueue.pop();
return posQueue.top().pos;
}
posQueue.top().pos = posQueue.top().pe.nextPosition();
posQueue.top().upto--;
posQueue.updateTop();
return posQueue.top().pos;
}
代码示例来源:origin: org.apache.lucene/lucene-core
assert top.values[j] != null;
queue.updateTop();
} else {
queue.pop();
代码示例来源:origin: org.elasticsearch/elasticsearch
private void updateTop(CandidateSet[] candidates, Candidate[] path, PriorityQueue corrections, double cutoffScore, double score)
throws IOException {
score = Math.exp(score);
assert Math.abs(score - score(path, candidates)) <0.00001;
if (score > cutoffScore) {
if (corrections.size() Candidate[] c = new Candidate[candidates.length];
System.arraycopy(path, 0, c, 0, path.length);
corrections.add(new Correction(score, c));
} else if (corrections.top().compareTo(score, path) <0) {
Correction top = corrections.top();
System.arraycopy(path, 0, top.candidates, 0, path.length);
top.score = score;
corrections.updateTop();
}
}
}
代码示例来源:origin: org.elasticsearch/elasticsearch
if (seen.contains(collapseValue)) {
if (ref.hitIndex queue.updateTop();
} else {
queue.pop();
queue.updateTop();
} else {
queue.pop();
代码示例来源:origin: org.elasticsearch/elasticsearch
assert next.key > top.current.key : "shards must return data sorted by key";
top.current = next;
pq.updateTop();
} else {
pq.pop();
代码示例来源:origin: org.elasticsearch/elasticsearch
assert Double.compare(next.key, top.current.key) > 0 : "shards must return data sorted by key";
top.current = next;
pq.updateTop();
} else {
pq.pop();
代码示例来源:origin: org.elasticsearch/elasticsearch
assert next.key > top.current.key : "shards must return data sorted by key";
top.current = next;
pq.updateTop();
} else {
pq.pop();
代码示例来源:origin: org.apache.lucene/lucene-core
queue.updateTop();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene
/**
* Replace the top of the pq with {@code newTop} and run {@link #updateTop()}.
*/
public final T updateTop(T newTop) {
heap[1] = newTop;
return updateTop();
}