Apache Solr open-source search software
LUCENE-2417: changed IndexCommit methods to abstract
Shai Erera9f2cd93b93cb
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 94882d8f39f..23ec8684d4a 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -284,8 +284,9 @@ Bug fixescalled. (Ruben Laguna, Uwe Schindler, Mike McCandless)* LUCENE-2417: IndexCommit did not implement hashCode() and equals()- consitently. Now they both take Directory and version into consideration.- (Shai Erera)+ consitently. Now they both take Directory and version into consideration. In+ addition, all of IndexComnmit methods which threw+ UnsupportedOperationException are now abstract. (Shai Erera)* LUCENE-2424: Fix FieldDoc.toString to actually return its fields(Stephen Green via Mike McCandless)diff --git a/lucene/src/java/org/apache/lucene/index/DirectoryReader.java b/lucene/src/java/org/apache/lucene/index/DirectoryReader.javaindex 7abf4c71854..75d319a3b35 100644--- a/lucene/src/java/org/apache/lucene/index/DirectoryReader.java+++ b/lucene/src/java/org/apache/lucene/index/DirectoryReader.java@@ -1125,6 +1125,11 @@ class DirectoryReader extends IndexReader implements Cloneable {public Map<String,String> getUserData() {return userData;}++ @Override+ public void delete() {+ throw new UnsupportedOperationException("This IndexCommit does not support deletions");+ }}// @deprecated This is pre-flex APIdiff --git a/lucene/src/java/org/apache/lucene/index/IndexCommit.java b/lucene/src/java/org/apache/lucene/index/IndexCommit.javaindex db100541ed6..26318c430ea 100644--- a/lucene/src/java/org/apache/lucene/index/IndexCommit.java+++ b/lucene/src/java/org/apache/lucene/index/IndexCommit.java@@ -70,24 +70,14 @@ public abstract class IndexCommit {* and therefore this should only be called by its {@link IndexDeletionPolicy#onInit onInit()} or* {@link IndexDeletionPolicy#onCommit onCommit()} methods.*/- public void delete() {- throw new UnsupportedOperationException("This IndexCommit does not support this method.");- }+ public abstract void delete();- public boolean isDeleted() {- throw new UnsupportedOperationException("This IndexCommit does not support this method.");- }+ public abstract boolean isDeleted();- /**- * Returns true if this commit is an optimized index.- */- public boolean isOptimized() {- throw new UnsupportedOperationException("This IndexCommit does not support this method.");- }+ /** Returns true if this commit is an optimized index. */+ public abstract boolean isOptimized();- /**- * Two IndexCommits are equal if both their Directory and versions are equal.- */+ /** Two IndexCommits are equal if both their Directory and versions are equal. */@Overridepublic boolean equals(Object other) {if (other instanceof IndexCommit) {@@ -105,15 +95,11 @@ public abstract class IndexCommit {/** Returns the version for this IndexCommit. This is the* same value that {@link IndexReader#getVersion} would* return if it were opened on this commit. */- public long getVersion() {- throw new UnsupportedOperationException("This IndexCommit does not support this method.");- }+ public abstract long getVersion();/** Returns the generation (the _N in segments_N) for this* IndexCommit */- public long getGeneration() {- throw new UnsupportedOperationException("This IndexCommit does not support this method.");- }+ public abstract long getGeneration();/** Convenience method that returns the last modified time* of the segments_N file corresponding to this index@@ -126,7 +112,6 @@ public abstract class IndexCommit {/** Returns userData, previously passed to {@link* IndexWriter#commit(Map)} for this commit. Map is* String -> String. */- public Map<String,String> getUserData() throws IOException {- throw new UnsupportedOperationException("This IndexCommit does not support this method.");- }+ public abstract Map<String,String> getUserData() throws IOException;+}diff --git a/lucene/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java b/lucene/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.javaindex e067e70ecf1..5c6528d2fb1 100644--- a/lucene/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java+++ b/lucene/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java@@ -132,6 +132,10 @@ public class SnapshotDeletionPolicy implements IndexDeletionPolicy {public Map<String,String> getUserData() throws IOException {return cp.getUserData();}+ @Override+ public boolean isOptimized() {+ return cp.isOptimized();+ }}private List<IndexCommit> wrapCommits(List<? extends IndexCommit> commits) {