Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-1748: makes Spans abstract class

Mark Robert Millerf3bf13f48089
diff --git a/CHANGES.txt b/CHANGES.txt
index 6b0b3553a3f..20809d1d1b6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -88,7 +88,9 @@ Changes in backwards compatibility policy
compat break and caused custom SpanQuery implementations to fail at runtime
in a variety of ways. This issue attempts to remedy things by causing
a compile time break on custom SpanQuery implementations and removing
- the PayloadSpans class, with its functionality now moved to Spans.
+ the PayloadSpans class, with its functionality now moved to Spans. To
+ help in alleviating future back compat pain, Spans has been changed from
+ an interface to an abstract class.
(Hugh Cayless, Mark Miller)
Changes in runtime behavior
@@ -374,7 +376,9 @@ API Changes
compat break and caused custom SpanQuery implementations to fail at runtime
in a variety of ways. This issue attempts to remedy things by causing
a compile time break on custom SpanQuery implementations and removing
- the PayloadSpans class, with its functionality now moved to Spans.
+ the PayloadSpans class, with its functionality now moved to Spans. To
+ help in alleviating future back compat pain, Spans has been changed from
+ an interface to an abstract class.
(Hugh Cayless, Mark Miller)
Bug fixes
diff --git a/common-build.xml b/common-build.xml
index c255b874d24..1b78495e060 100644
--- a/common-build.xml
+++ b/common-build.xml
@@ -42,7 +42,7 @@
<property name="Name" value="Lucene"/>
<property name="dev.version" value="2.9-dev"/>
<property name="version" value="${dev.version}"/>
- <property name="compatibility.tag" value="lucene_2_4_back_compat_tests_20090811"/>
+ <property name="compatibility.tag" value="lucene_2_4_back_compat_tests_20090812"/>
<property name="spec.version" value="${version}"/>
<property name="year" value="2000-${current.year}"/>
<property name="final.name" value="lucene-${name}-${version}"/>
diff --git a/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java b/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java
index 9d0a760b569..f2fe15d640e 100644
--- a/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java
+++ b/src/java/org/apache/lucene/search/spans/NearSpansOrdered.java
@@ -51,7 +51,7 @@ import java.util.Set;
* Expert:
* Only public for subclassing. Most implementations should not need this class
*/
-public class NearSpansOrdered implements Spans {
+public class NearSpansOrdered extends Spans {
private final int allowedSlop;
private boolean firstTime = true;
private boolean more = false;
diff --git a/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java b/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java
index bef60fa3c45..ec95b50d2ac 100644
--- a/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java
+++ b/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java
@@ -31,7 +31,7 @@ import java.util.HashSet;
* Expert:
* Only public for subclassing. Most implementations should not need this class
*/
-public class NearSpansUnordered implements Spans {
+public class NearSpansUnordered extends Spans {
private SpanNearQuery query;
private List ordered = new ArrayList(); // spans in query order
@@ -67,7 +67,7 @@ public class NearSpansUnordered implements Spans {
/** Wraps a Spans, and can be used to form a linked list. */
- private class SpansCell implements Spans {
+ private class SpansCell extends Spans {
private Spans spans;
private SpansCell next;
private int length = -1;
diff --git a/src/java/org/apache/lucene/search/spans/Spans.java b/src/java/org/apache/lucene/search/spans/Spans.java
index 1e00a8664ca..bdc98c198e6 100644
--- a/src/java/org/apache/lucene/search/spans/Spans.java
+++ b/src/java/org/apache/lucene/search/spans/Spans.java
@@ -24,9 +24,9 @@ import java.util.Collection;
* Each span represents a range of term positions within a document. Matches
* are enumerated in order, by increasing document number, within that by
* increasing start position and finally by increasing end position. */
-public interface Spans {
+public abstract class Spans {
/** Move to the next match, returning true iff any such exists. */
- boolean next() throws IOException;
+ public abstract boolean next() throws IOException;
/** Skips to the first match beyond the current, whose document number is
* greater than or equal to <i>target</i>. <p>Returns true iff there is such
@@ -41,16 +41,16 @@ public interface Spans {
* </pre>
* Most implementations are considerably more efficient than that.
*/
- boolean skipTo(int target) throws IOException;
+ public abstract boolean skipTo(int target) throws IOException;
/** Returns the document number of the current match. Initially invalid. */
- int doc();
+ public abstract int doc();
/** Returns the start position of the current match. Initially invalid. */
- int start();
+ public abstract int start();
/** Returns the end position of the current match. Initially invalid. */
- int end();
+ public abstract int end();
/**
* Returns the payload data for the current span.
@@ -75,22 +75,16 @@ public interface Spans {
* @throws java.io.IOException
*/
// TODO: Remove warning after API has been finalized
- Collection/*<byte[]>*/ getPayload() throws IOException;
+ public abstract Collection/*<byte[]>*/ getPayload() throws IOException;
/**
* Checks if a payload can be loaded at this position.
* <p/>
* Payloads can only be loaded once per call to
* {@link #next()}.
- * <p/>
- * <p><font color="#FF0000">
- * WARNING: The status of the <b>Payloads</b> feature is experimental.
- * The APIs introduced here might change in the future and will not be
- * supported anymore in such a case.</font>
*
* @return true if there is a payload available at this position that can be loaded
*/
- // TODO: Remove warning after API has been finalized
- public boolean isPayloadAvailable();
+ public abstract boolean isPayloadAvailable();
}
diff --git a/src/java/org/apache/lucene/search/spans/TermSpans.java b/src/java/org/apache/lucene/search/spans/TermSpans.java
index 7127f56e8dc..bd88b217804 100644
--- a/src/java/org/apache/lucene/search/spans/TermSpans.java
+++ b/src/java/org/apache/lucene/search/spans/TermSpans.java
@@ -27,7 +27,7 @@ import java.util.Collection;
* Expert:
* Public for extension only
*/
-public class TermSpans implements Spans {
+public class TermSpans extends Spans {
protected TermPositions positions;
protected Term term;
protected int doc;
diff --git a/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java b/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java
index 4633b3316f1..d790354d8ec 100644
--- a/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java
+++ b/src/test/org/apache/lucene/search/spans/JustCompileSearchSpans.java
@@ -35,7 +35,7 @@ final class JustCompileSearchSpans {
private static final String UNSUPPORTED_MSG = "unsupported: used for back-compat testing only !";
- static final class JustCompileSpans implements Spans {
+ static final class JustCompileSpans extends Spans {
public int doc() {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
@@ -88,7 +88,7 @@ final class JustCompileSearchSpans {
}
- static final class JustCompilePayloadSpans implements Spans {
+ static final class JustCompilePayloadSpans extends Spans {
public Collection getPayload() throws IOException {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);