No longer needed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/0b846572 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/0b846572 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/0b846572 Branch: refs/heads/0.2-dev Commit: 0b846572d881921edc1e0856def49bb94a311765 Parents: a6879d2 Author: Aaron McCurry <[email protected]> Authored: Thu Nov 29 21:49:16 2012 -0500 Committer: Aaron McCurry <[email protected]> Committed: Thu Nov 29 21:49:16 2012 -0500 ---------------------------------------------------------------------- .../apache/blur/lucene/search/FairSimilarity.java | 60 ------- .../apache/blur/lucene/search/PagingCollector.java | 120 --------------- 2 files changed, 0 insertions(+), 180 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0b846572/src/blur-core/src/main/java/org/apache/blur/lucene/search/FairSimilarity.java ---------------------------------------------------------------------- diff --git a/src/blur-core/src/main/java/org/apache/blur/lucene/search/FairSimilarity.java b/src/blur-core/src/main/java/org/apache/blur/lucene/search/FairSimilarity.java deleted file mode 100644 index dc8f59a..0000000 --- a/src/blur-core/src/main/java/org/apache/blur/lucene/search/FairSimilarity.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.blur.lucene.search; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import org.apache.lucene.index.FieldInvertState; -import org.apache.lucene.index.Norm; -import org.apache.lucene.search.similarities.TFIDFSimilarity; -import org.apache.lucene.util.BytesRef; - -public class FairSimilarity extends TFIDFSimilarity { - - @Override - public float coord(int overlap, int maxOverlap) { - return 1; - } - - @Override - public float idf(long docFreq, long numDocs) { - return 1; - } - - @Override - public float queryNorm(float sumOfSquaredWeights) { - return 1; - } - - @Override - public float sloppyFreq(int distance) { - return 1; - } - - @Override - public float tf(float freq) { - return 1; - } - - @Override - public void computeNorm(FieldInvertState state, Norm norm) { - } - - @Override - public float scorePayload(int doc, int start, int end, BytesRef payload) { - return 1; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/0b846572/src/blur-core/src/main/java/org/apache/blur/lucene/search/PagingCollector.java ---------------------------------------------------------------------- diff --git a/src/blur-core/src/main/java/org/apache/blur/lucene/search/PagingCollector.java b/src/blur-core/src/main/java/org/apache/blur/lucene/search/PagingCollector.java deleted file mode 100644 index 385c29d..0000000 --- a/src/blur-core/src/main/java/org/apache/blur/lucene/search/PagingCollector.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.apache.blur.lucene.search; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import java.io.IOException; - -import org.apache.lucene.index.AtomicReaderContext; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.TopDocs; -import org.apache.lucene.search.TopDocsCollector; -import org.apache.lucene.util.PriorityQueue; - -/** - * The {@link PagingCollector} allows for paging through lucene hits. - */ -public class PagingCollector extends TopDocsCollector<ScoreDoc> { - - private ScoreDoc pqTop; - private int docBase; - private Scorer scorer; - private ScoreDoc previousPassLowest; - private int numHits; - - public PagingCollector(int numHits) { - // creates an empty score doc so that i don't have to check for null - // each time. - this(numHits, new ScoreDoc(-1, Float.MAX_VALUE)); - } - - public PagingCollector(int numHits, ScoreDoc previousPassLowest) { - super(new HitQueue(numHits, true)); - this.pqTop = pq.top(); - this.numHits = numHits; - this.previousPassLowest = previousPassLowest; - } - - @Override - public boolean acceptsDocsOutOfOrder() { - return true; - } - - @Override - public void collect(int doc) throws IOException { - float score = scorer.score(); - totalHits++; - doc += docBase; - if (score > previousPassLowest.score) { - // this hit was gathered on a previous page. - return; - } else if (score == previousPassLowest.score && doc <= previousPassLowest.doc) { - // if the scores are the same and the doc is less than or equal to the - // previous pass lowest hit doc then skip because this collector favors - // lower number documents. - return; - } else if (score < pqTop.score || (score == pqTop.score && doc > pqTop.doc)) { - return; - } - pqTop.doc = doc; - pqTop.score = score; - pqTop = pq.updateTop(); - } - - @Override - public void setNextReader(AtomicReaderContext context) throws IOException { - this.docBase = context.docBase; - } - - @Override - public void setScorer(Scorer scorer) throws IOException { - this.scorer = scorer; - } - - public ScoreDoc getLastScoreDoc(TopDocs topDocs) { - return topDocs.scoreDocs[(totalHits < numHits ? totalHits : numHits) - 1]; - } - - public ScoreDoc getLastScoreDoc(ScoreDoc[] scoreDocs) { - return scoreDocs[(totalHits < numHits ? totalHits : numHits) - 1]; - } - - public static class HitQueue extends PriorityQueue<ScoreDoc> { - - private boolean prePopulate; - - HitQueue(int size, boolean prePopulate) { - super(size); - this.prePopulate = prePopulate; - } - - @Override - protected ScoreDoc getSentinelObject() { - return !prePopulate ? null : new ScoreDoc(Integer.MAX_VALUE, Float.NEGATIVE_INFINITY); - } - - @Override - protected final boolean lessThan(ScoreDoc hitA, ScoreDoc hitB) { - if (hitA.score == hitB.score) { - return hitA.doc > hitB.doc; - } else { - return hitA.score < hitB.score; - } - } - } - -}
