From 9741c16721ceb805d3f653b7293a466bd4b9457a Mon Sep 17 00:00:00 2001 From: Alan Woodward Date: Mon, 15 Jun 2015 16:18:22 +0000 Subject: [PATCH] LUCENE-6371: Remove deprecated SpanNearPayloadCheckQuery git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1685614 13f79535-47bb-0310-9956-ffa450edef68 --- .../payloads/SpanNearPayloadCheckQuery.java | 79 ------------------- .../search/payloads/TestPayloadBasics.java | 20 ++--- 2 files changed, 10 insertions(+), 89 deletions(-) delete mode 100644 lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java diff --git a/lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java b/lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java deleted file mode 100644 index 90eb4023b56..00000000000 --- a/lucene/core/src/java/org/apache/lucene/search/payloads/SpanNearPayloadCheckQuery.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.lucene.search.payloads; -/* - * 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.search.spans.SpanNearQuery; -import org.apache.lucene.util.ToStringUtils; - -import java.util.Collection; - - -/** - * Only return those matches that have a specific payload at - * the given position. - * - * @deprecated Use {@link SpanPayloadCheckQuery} - */ -@Deprecated -public class SpanNearPayloadCheckQuery extends SpanPayloadCheckQuery { - - /** - * @param match The underlying {@link org.apache.lucene.search.spans.SpanQuery} to check - * @param payloadToMatch The {@link java.util.Collection} of payloads to match - */ - public SpanNearPayloadCheckQuery(SpanNearQuery match, Collection payloadToMatch) { - super(match, payloadToMatch); - } - - @Override - public String toString(String field) { - StringBuilder buffer = new StringBuilder(); - buffer.append("spanPayCheck("); - buffer.append(match.toString(field)); - buffer.append(", payloadRef: "); - for (byte[] bytes : payloadToMatch) { - ToStringUtils.byteArray(buffer, bytes); - buffer.append(';'); - } - buffer.append(")"); - buffer.append(ToStringUtils.boost(getBoost())); - return buffer.toString(); - } - - @Override - public SpanNearPayloadCheckQuery clone() { - SpanNearPayloadCheckQuery result = new SpanNearPayloadCheckQuery((SpanNearQuery) match.clone(), payloadToMatch); - result.setBoost(getBoost()); - return result; - } - - @Override - public boolean equals(Object o) { - if (! super.equals(o)) { - return false; - } - SpanNearPayloadCheckQuery other = (SpanNearPayloadCheckQuery) o; - return this.payloadToMatch.equals(other.payloadToMatch); - } - - @Override - public int hashCode() { - int h = super.hashCode(); - h = (h * 15) ^ payloadToMatch.hashCode(); - return h; - } -} \ No newline at end of file diff --git a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadBasics.java b/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadBasics.java index b9a7fae6640..a2613ac4025 100644 --- a/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadBasics.java +++ b/lucene/core/src/test/org/apache/lucene/search/payloads/TestPayloadBasics.java @@ -17,6 +17,13 @@ package org.apache.lucene.search.payloads; * limitations under the License. */ +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.SimplePayloadFilter; @@ -41,13 +48,6 @@ import org.apache.lucene.util.TestUtil; import org.junit.AfterClass; import org.junit.BeforeClass; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - /** basic test of payload-spans */ public class TestPayloadBasics extends LuceneTestCase { private static IndexSearcher searcher; @@ -114,7 +114,7 @@ public class TestPayloadBasics extends LuceneTestCase { list = new ArrayList<>(); list.add(pay.bytes); list.add(pay2.bytes); - query = new SpanNearPayloadCheckQuery(snq, list); + query = new SpanPayloadCheckQuery(snq, list); checkHits(query, new int[] {500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599}); clauses = new SpanQuery[3]; @@ -129,7 +129,7 @@ public class TestPayloadBasics extends LuceneTestCase { list.add(pay.bytes); list.add(pay2.bytes); list.add(pay3.bytes); - query = new SpanNearPayloadCheckQuery(snq, list); + query = new SpanPayloadCheckQuery(snq, list); checkHits(query, new int[] {505}); } @@ -161,7 +161,7 @@ public class TestPayloadBasics extends LuceneTestCase { payloads.add(pay2.bytes); payloads.add(pay3.bytes); payloads.add(pay4.bytes); - query = new SpanNearPayloadCheckQuery(oneThousHunThree, payloads); + query = new SpanPayloadCheckQuery(oneThousHunThree, payloads); checkHits(query, new int[]{1103, 1203,1303,1403,1503,1603,1703,1803,1903}); }