PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/backwards/src/test/org/apache/lucene/search/JustCompileSearch.java

https://bitbucket.org/gasol/lucene3
Java | 501 lines | 360 code | 116 blank | 25 comment | 0 complexity | dff2d834864aa5255556f4fe956bccc5 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. package org.apache.lucene.search;
  2. /**
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import java.io.IOException;
  19. import org.apache.lucene.document.Document;
  20. import org.apache.lucene.document.FieldSelector;
  21. import org.apache.lucene.index.CorruptIndexException;
  22. import org.apache.lucene.index.IndexReader;
  23. import org.apache.lucene.index.FieldInvertState;
  24. import org.apache.lucene.index.Term;
  25. import org.apache.lucene.util.PriorityQueue;
  26. /**
  27. * Holds all implementations of classes in the o.a.l.search package as a
  28. * back-compatibility test. It does not run any tests per-se, however if
  29. * someone adds a method to an interface or abstract method to an abstract
  30. * class, one of the implementations here will fail to compile and so we know
  31. * back-compat policy was violated.
  32. */
  33. final class JustCompileSearch {
  34. private static final String UNSUPPORTED_MSG = "unsupported: used for back-compat testing only !";
  35. static final class JustCompileSearcher extends Searcher {
  36. @Override
  37. public Weight createNormalizedWeight(Query query) throws IOException {
  38. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  39. }
  40. @Override
  41. public void close() throws IOException {
  42. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  43. }
  44. @Override
  45. public Document doc(int i) throws CorruptIndexException, IOException {
  46. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  47. }
  48. @Override
  49. public int[] docFreqs(Term[] terms) throws IOException {
  50. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  51. }
  52. @Override
  53. public Explanation explain(Query query, int doc) throws IOException {
  54. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  55. }
  56. @Override
  57. public Similarity getSimilarity() {
  58. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  59. }
  60. @Override
  61. public void search(Query query, Collector results) throws IOException {
  62. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  63. }
  64. @Override
  65. public void search(Query query, Filter filter, Collector results)
  66. throws IOException {
  67. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  68. }
  69. @Override
  70. public TopDocs search(Query query, Filter filter, int n) throws IOException {
  71. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  72. }
  73. @Override
  74. public TopFieldDocs search(Query query, Filter filter, int n, Sort sort)
  75. throws IOException {
  76. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  77. }
  78. @Override
  79. public TopDocs search(Query query, int n) throws IOException {
  80. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  81. }
  82. @Override
  83. public void setSimilarity(Similarity similarity) {
  84. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  85. }
  86. @Override
  87. public int docFreq(Term term) throws IOException {
  88. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  89. }
  90. @Override
  91. public Explanation explain(Weight weight, int doc) throws IOException {
  92. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  93. }
  94. @Override
  95. public int maxDoc() throws IOException {
  96. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  97. }
  98. @Override
  99. public Query rewrite(Query query) throws IOException {
  100. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  101. }
  102. @Override
  103. public void search(Weight weight, Filter filter, Collector results)
  104. throws IOException {
  105. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  106. }
  107. @Override
  108. public TopDocs search(Weight weight, Filter filter, int n)
  109. throws IOException {
  110. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  111. }
  112. @Override
  113. public TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
  114. throws IOException {
  115. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  116. }
  117. @Override
  118. public Document doc(int n, FieldSelector fieldSelector)
  119. throws CorruptIndexException, IOException {
  120. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  121. }
  122. }
  123. static final class JustCompileCollector extends Collector {
  124. @Override
  125. public void collect(int doc) throws IOException {
  126. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  127. }
  128. @Override
  129. public void setNextReader(IndexReader reader, int docBase)
  130. throws IOException {
  131. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  132. }
  133. @Override
  134. public void setScorer(Scorer scorer) throws IOException {
  135. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  136. }
  137. @Override
  138. public boolean acceptsDocsOutOfOrder() {
  139. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  140. }
  141. }
  142. static final class JustCompileDocIdSet extends DocIdSet {
  143. @Override
  144. public DocIdSetIterator iterator() throws IOException {
  145. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  146. }
  147. }
  148. static final class JustCompileDocIdSetIterator extends DocIdSetIterator {
  149. @Override
  150. public int docID() {
  151. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  152. }
  153. @Override
  154. public int nextDoc() throws IOException {
  155. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  156. }
  157. @Override
  158. public int advance(int target) throws IOException {
  159. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  160. }
  161. }
  162. static final class JustCompileExtendedFieldCacheLongParser implements FieldCache.LongParser {
  163. public long parseLong(String string) {
  164. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  165. }
  166. }
  167. static final class JustCompileExtendedFieldCacheDoubleParser implements FieldCache.DoubleParser {
  168. public double parseDouble(String string) {
  169. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  170. }
  171. }
  172. static final class JustCompileFieldComparator extends FieldComparator<Object> {
  173. @Override
  174. public int compare(int slot1, int slot2) {
  175. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  176. }
  177. @Override
  178. public int compareBottom(int doc) throws IOException {
  179. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  180. }
  181. @Override
  182. public void copy(int slot, int doc) throws IOException {
  183. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  184. }
  185. @Override
  186. public void setBottom(int slot) {
  187. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  188. }
  189. @Override
  190. public void setNextReader(IndexReader reader, int docBase)
  191. throws IOException {
  192. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  193. }
  194. @Override
  195. public Object value(int slot) {
  196. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  197. }
  198. }
  199. static final class JustCompileFieldComparatorSource extends FieldComparatorSource {
  200. @Override
  201. public FieldComparator newComparator(String fieldname, int numHits,
  202. int sortPos, boolean reversed) throws IOException {
  203. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  204. }
  205. }
  206. static final class JustCompileFilter extends Filter {
  207. // Filter is just an abstract class with no abstract methods. However it is
  208. // still added here in case someone will add abstract methods in the future.
  209. @Override
  210. public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
  211. return null;
  212. }
  213. }
  214. static final class JustCompileFilteredDocIdSet extends FilteredDocIdSet {
  215. public JustCompileFilteredDocIdSet(DocIdSet innerSet) {
  216. super(innerSet);
  217. }
  218. @Override
  219. protected boolean match(int docid) {
  220. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  221. }
  222. }
  223. static final class JustCompileFilteredDocIdSetIterator extends FilteredDocIdSetIterator {
  224. public JustCompileFilteredDocIdSetIterator(DocIdSetIterator innerIter) {
  225. super(innerIter);
  226. }
  227. @Override
  228. protected boolean match(int doc) {
  229. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  230. }
  231. }
  232. static final class JustCompileFilteredTermEnum extends FilteredTermEnum {
  233. @Override
  234. public float difference() {
  235. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  236. }
  237. @Override
  238. protected boolean endEnum() {
  239. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  240. }
  241. @Override
  242. protected boolean termCompare(Term term) {
  243. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  244. }
  245. }
  246. static final class JustCompilePhraseScorer extends PhraseScorer {
  247. JustCompilePhraseScorer(Weight weight, PhraseQuery.PostingsAndFreq[] postings,
  248. Similarity similarity, byte[] norms) {
  249. super(weight, postings, similarity, norms);
  250. }
  251. @Override
  252. protected float phraseFreq() throws IOException {
  253. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  254. }
  255. }
  256. static final class JustCompileQuery extends Query {
  257. @Override
  258. public String toString(String field) {
  259. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  260. }
  261. }
  262. static final class JustCompileScorer extends Scorer {
  263. protected JustCompileScorer(Weight weight) {
  264. super(weight);
  265. }
  266. @Override
  267. protected boolean score(Collector collector, int max, int firstDocID)
  268. throws IOException {
  269. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  270. }
  271. @Override
  272. public float score() throws IOException {
  273. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  274. }
  275. @Override
  276. public int docID() {
  277. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  278. }
  279. @Override
  280. public int nextDoc() throws IOException {
  281. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  282. }
  283. @Override
  284. public int advance(int target) throws IOException {
  285. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  286. }
  287. }
  288. static final class JustCompileSimilarity extends Similarity {
  289. @Override
  290. public float coord(int overlap, int maxOverlap) {
  291. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  292. }
  293. @Override
  294. public float idf(int docFreq, int numDocs) {
  295. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  296. }
  297. @Override
  298. public float computeNorm(String fieldName, FieldInvertState state) {
  299. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  300. }
  301. @Override
  302. public float queryNorm(float sumOfSquaredWeights) {
  303. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  304. }
  305. @Override
  306. public float sloppyFreq(int distance) {
  307. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  308. }
  309. @Override
  310. public float tf(float freq) {
  311. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  312. }
  313. }
  314. static final class JustCompileSpanFilter extends SpanFilter {
  315. @Override
  316. public SpanFilterResult bitSpans(IndexReader reader) throws IOException {
  317. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  318. }
  319. @Override
  320. public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
  321. return null;
  322. }
  323. }
  324. static final class JustCompileTopDocsCollector extends TopDocsCollector<ScoreDoc> {
  325. protected JustCompileTopDocsCollector(PriorityQueue<ScoreDoc> pq) {
  326. super(pq);
  327. }
  328. @Override
  329. public void collect(int doc) throws IOException {
  330. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  331. }
  332. @Override
  333. public void setNextReader(IndexReader reader, int docBase)
  334. throws IOException {
  335. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  336. }
  337. @Override
  338. public void setScorer(Scorer scorer) throws IOException {
  339. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  340. }
  341. @Override
  342. public boolean acceptsDocsOutOfOrder() {
  343. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  344. }
  345. @Override
  346. public TopDocs topDocs() {
  347. throw new UnsupportedOperationException( UNSUPPORTED_MSG );
  348. }
  349. @Override
  350. public TopDocs topDocs( int start ) {
  351. throw new UnsupportedOperationException( UNSUPPORTED_MSG );
  352. }
  353. @Override
  354. public TopDocs topDocs( int start, int end ) {
  355. throw new UnsupportedOperationException( UNSUPPORTED_MSG );
  356. }
  357. }
  358. static final class JustCompileWeight extends Weight {
  359. @Override
  360. public Explanation explain(IndexReader reader, int doc) throws IOException {
  361. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  362. }
  363. @Override
  364. public Query getQuery() {
  365. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  366. }
  367. @Override
  368. public float getValue() {
  369. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  370. }
  371. @Override
  372. public void normalize(float norm) {
  373. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  374. }
  375. @Override
  376. public float sumOfSquaredWeights() throws IOException {
  377. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  378. }
  379. @Override
  380. public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer)
  381. throws IOException {
  382. throw new UnsupportedOperationException(UNSUPPORTED_MSG);
  383. }
  384. }
  385. }