Apache Solr open-source search software
LUCENE-1878: remove deprecated classes from spatial
Mark Robert Millerb3a00de39c8b
diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/BoundaryBoxFilter.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/BoundaryBoxFilter.javadeleted file mode 100644index 6431e83258d..00000000000--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/BoundaryBoxFilter.java+++ /dev/null@@ -1,212 +0,0 @@-/**- * 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.- */--package org.apache.lucene.spatial.tier;--import java.io.IOException;-import java.util.logging.Logger;--import org.apache.lucene.index.IndexReader;-import org.apache.lucene.index.Term;-import org.apache.lucene.index.TermDocs;-import org.apache.lucene.index.TermEnum;-import org.apache.lucene.search.Filter;-import org.apache.lucene.search.DocIdSet;-import org.apache.lucene.util.NumericUtils;-import org.apache.lucene.util.OpenBitSet;----/**- * An implementation of org.apache.lucene.search.RangeFilter that- * caches values extracted from the index.- * @deprecated- * @see CartesianShapeFilter- */-public class BoundaryBoxFilter extends Filter {-- private static final long serialVersionUID = 1L;- private String fieldName;- private String lowerTerm;- private String upperTerm;- private boolean includeLower;- private boolean includeUpper;- private Logger log = Logger.getLogger(getClass().getName());-- // cache of values extracted from the index- // TODO: add generics- //private Map coords;-- /**- * @param fieldName The field this range applies to- * @param lowerTerm The lower bound on this range- * @param upperTerm The upper bound on this range- * @param includeLower Does this range include the lower bound?- * @param includeUpper Does this range include the upper bound?- * @throws IllegalArgumentException if both terms are null or if- * lowerTerm is null and includeLower is true (similar for upperTerm- * and includeUpper)- */- public BoundaryBoxFilter(String fieldName, String lowerTerm, String upperTerm,- boolean includeLower, boolean includeUpper) {- this.fieldName = fieldName;- this.lowerTerm = lowerTerm;- this.upperTerm = upperTerm;- this.includeLower = includeLower;- this.includeUpper = includeUpper;-- if (null == lowerTerm && null == upperTerm) {- throw new IllegalArgumentException- ("At least one value must be non-null");- }- if (includeLower && null == lowerTerm) {- throw new IllegalArgumentException- ("The lower bound must be non-null to be inclusive");- }- if (includeUpper && null == upperTerm) {- throw new IllegalArgumentException- ("The upper bound must be non-null to be inclusive");- }- }--- /**- * Returns a DocIdSet with true for documents which should be- * permitted in search results, and false for those that should- * not.- */- @Override- public DocIdSet getDocIdSet(IndexReader reader) throws IOException {- long start = System.currentTimeMillis();-- OpenBitSet bits = new OpenBitSet(reader.maxDoc());- TermEnum enumerator =- (null != lowerTerm- ? reader.terms(new Term(fieldName, lowerTerm))- : reader.terms(new Term(fieldName,"")));-- //coords = new HashMap(enumerator.docFreq());-- try {- if (enumerator.term() == null) {- return bits;- }-- boolean checkLower = false;- if (!includeLower) // make adjustments to set to exclusive- checkLower = true;-- TermDocs termDocs = reader.termDocs();- try {- do {- Term term = enumerator.term();- if (term != null && term.field().equals(fieldName)) {- if (!checkLower || null==lowerTerm || term.text().compareTo(lowerTerm) > 0) {- checkLower = false;- if (upperTerm != null) {- int compare = upperTerm.compareTo(term.text());- // if beyond the upper term, or is exclusive and- // this is equal to the upper term, break out- if ((compare < 0) ||- (!includeUpper && compare==0)) {- break;- }- }- // we have a good term, find the docs- termDocs.seek(enumerator.term());- while (termDocs.next()) {- bits.fastSet(termDocs.doc());- }- }- }- else {- break;- }- }- while (enumerator.next());- }- finally {- termDocs.close();- }- }- finally {- enumerator.close();- }-- long end = System.currentTimeMillis();- log.info("BoundaryBox Time Taken: "+ (end - start));- return bits;- }-- @Override- public String toString() {- StringBuffer buffer = new StringBuffer();- buffer.append(fieldName);- buffer.append(":");- buffer.append(includeLower ? "[" : "{");- if (null != lowerTerm) {- buffer.append(NumericUtils.prefixCodedToDouble(lowerTerm));- }- buffer.append("-");- if (null != upperTerm) {- buffer.append(NumericUtils.prefixCodedToDouble(upperTerm));- }- buffer.append(includeUpper ? "]" : "}");- return buffer.toString();- }-- public String getFieldName() {- return fieldName;- }--- /**- * Returns true if <code>o</code> is equal to this.- *- * @see org.apache.lucene.search.RangeFilter#equals- */- @Override- public boolean equals(Object o) {- if (this == o) return true;- if (!(o instanceof BoundaryBoxFilter)) return false;- BoundaryBoxFilter other = (BoundaryBoxFilter) o;-- if (!this.fieldName.equals(other.fieldName)- || this.includeLower != other.includeLower- || this.includeUpper != other.includeUpper- ) { return false; }- if (this.lowerTerm != null ? !this.lowerTerm.equals(other.lowerTerm) : other.lowerTerm != null) return false;- if (this.upperTerm != null ? !this.upperTerm.equals(other.upperTerm) : other.upperTerm != null) return false;- return true;- }-- /**- * Returns a hash code value for this object.- *- * @see org.apache.lucene.search.RangeFilter#hashCode- */- @Override- public int hashCode() {- int h = fieldName.hashCode();- h ^= lowerTerm != null ? lowerTerm.hashCode() : 0xB6ECE882;- h = (h << 1) | (h >>> 31); // rotate to distinguish lower from upper- h ^= (upperTerm != null ? (upperTerm.hashCode()) : 0x91BEC2C2);- h ^= (includeLower ? 0xD484B933 : 0)- ^ (includeUpper ? 0x6AE423AC : 0);- return h;- }-}diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.javaindex 70f328faaba..83568f1a1ac 100644--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java+++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceFieldComparatorSource.java@@ -23,7 +23,6 @@ import org.apache.lucene.index.IndexReader;import org.apache.lucene.search.Filter;import org.apache.lucene.search.FieldComparator;import org.apache.lucene.search.FieldComparatorSource;-import org.apache.lucene.search.SortField;public class DistanceFieldComparatorSource extends FieldComparatorSource {diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.javaindex 4e6165fb78a..ee7b1640c81 100644--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java+++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceHandler.java@@ -24,7 +24,6 @@ import java.util.Map;* Provide a high level access point to distances* Used by DistanceSortSource and DistanceQuery*- * @author pjaol**/public class DistanceHandler {diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.javaindex 1f37b9355ae..c27cd10e8ed 100644--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java+++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java@@ -29,9 +29,6 @@ public class DistanceQueryBuilder {private static final long serialVersionUID = 1L;- public BoundaryBoxFilter latFilter;- public BoundaryBoxFilter lngFilter;-private final double lat;private final double lng;private final double miles;diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceSortSource.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceSortSource.javadeleted file mode 100644index 26805081cf0..00000000000--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceSortSource.java+++ /dev/null@@ -1,93 +0,0 @@-/**- * 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.- */--package org.apache.lucene.spatial.tier;--import java.io.IOException;--import org.apache.lucene.index.IndexReader;-import org.apache.lucene.search.Filter;-import org.apache.lucene.search.ScoreDoc;-import org.apache.lucene.search.ScoreDocComparator;-import org.apache.lucene.search.SortComparatorSource;-import org.apache.lucene.search.SortField;--/**- *- * @deprecated- * @see DistanceFieldComparatorSource- */-public class DistanceSortSource implements SortComparatorSource {-- private static final long serialVersionUID = 1L;-- private DistanceFilter distanceFilter;- private DistanceScoreDocLookupComparator dsdlc;-- public DistanceSortSource (Filter distanceFilter){-- this.distanceFilter = (DistanceFilter)distanceFilter;-- }-- public void cleanUp() {- distanceFilter = null;-- if (dsdlc !=null)- dsdlc.cleanUp();-- dsdlc = null;- }-- public ScoreDocComparator newComparator(IndexReader reader, String field) throws IOException {- dsdlc = new DistanceScoreDocLookupComparator(reader, distanceFilter);- return dsdlc;- }---- private class DistanceScoreDocLookupComparator implements ScoreDocComparator {-- private DistanceFilter distanceFilter;-- public DistanceScoreDocLookupComparator(IndexReader reader, DistanceFilter distanceFilter) {- this.distanceFilter = distanceFilter;- return;- }--- public int compare(ScoreDoc aDoc, ScoreDoc bDoc) {- double a = distanceFilter.getDistance(aDoc.doc);- double b = distanceFilter.getDistance(bDoc.doc);- if (a > b) return 1;- if (a < b) return -1;- return 0;- }-- public int sortType() {- return SortField.DOUBLE;- }-- public Comparable sortValue(ScoreDoc iDoc) {- return distanceFilter.getDistance(iDoc.doc);- }-- public void cleanUp() {- distanceFilter = null;- }- }-}