Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. Index: lucene/core/src/java/org/apache/lucene/search/Filter.java
  2. ===================================================================
  3. --- lucene/core/src/java/org/apache/lucene/search/Filter.java (revision 1633246)
  4. +++ lucene/core/src/java/org/apache/lucene/search/Filter.java (working copy)
  5. @@ -56,4 +56,16 @@
  6. * in the case an <i>empty</i> {@link DocIdSet} is returned.
  7. */
  8. public abstract DocIdSet getDocIdSet(LeafReaderContext context, Bits acceptDocs) throws IOException;
  9. +
  10. + /**
  11. + * Returns an iterator matching documents.
  12. + */
  13. + public DocIdSetIterator iterator(LeafReaderContext context, Bits acceptDocs) throws IOException {
  14. + DocIdSet set = getDocIdSet(context, acceptDocs);
  15. + if (set == null) {
  16. + return null;
  17. + } else {
  18. + return set.iterator();
  19. + }
  20. + }
  21. }
  22. Index: lucene/core/src/java/org/apache/lucene/search/Weight.java
  23. ===================================================================
  24. --- lucene/core/src/java/org/apache/lucene/search/Weight.java (revision 1633246)
  25. +++ lucene/core/src/java/org/apache/lucene/search/Weight.java (working copy)
  26. @@ -34,7 +34,7 @@
  27. * {@link org.apache.lucene.index.LeafReader} dependent state should reside in the {@link Scorer}.
  28. * <p>
  29. * Since {@link Weight} creates {@link Scorer} instances for a given
  30. - * {@link org.apache.lucene.index.LeafReaderContext} ({@link #scorer(org.apache.lucene.index.LeafReaderContext, Bits)})
  31. + * {@link org.apache.lucene.index.LeafReaderContext} ({@link #iterator(org.apache.lucene.index.LeafReaderContext, Bits)})
  32. * callers must maintain the relationship between the searcher's top-level
  33. * {@link IndexReaderContext} and the context used to create a {@link Scorer}.
  34. * <p>
  35. @@ -49,12 +49,12 @@
  36. * <li>The query normalization factor is passed to {@link #normalize(float, float)}. At
  37. * this point the weighting is complete.
  38. * <li>A <code>Scorer</code> is constructed by
  39. - * {@link #scorer(org.apache.lucene.index.LeafReaderContext, Bits)}.
  40. + * {@link #iterator(org.apache.lucene.index.LeafReaderContext, Bits)}.
  41. * </ol>
  42. *
  43. * @since 2.9
  44. */
  45. -public abstract class Weight {
  46. +public abstract class Weight extends Filter {
  47.  
  48. /**
  49. * An explanation of the score computation for the named document.
  50. @@ -75,6 +75,21 @@
  51. /** Assigns the query normalization factor and boost from parent queries to this. */
  52. public abstract void normalize(float norm, float topLevelBoost);
  53.  
  54. + @Override
  55. + public final DocIdSet getDocIdSet(final LeafReaderContext context, final Bits acceptDocs) throws IOException {
  56. + return new DocIdSet() {
  57. + @Override
  58. + public long ramBytesUsed() {
  59. + return 0;
  60. + }
  61. +
  62. + @Override
  63. + public DocIdSetIterator iterator() throws IOException {
  64. + return Weight.this.iterator(context, acceptDocs);
  65. + }
  66. + };
  67. + }
  68. +
  69. /**
  70. * Returns a {@link Scorer} which scores documents in/out-of order according
  71. * to <code>scoreDocsInOrder</code>.
  72. @@ -96,7 +111,7 @@
  73. * @return a {@link Scorer} which scores documents in/out-of order.
  74. * @throws IOException if there is a low-level I/O error
  75. */
  76. - public abstract Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException;
  77. + public abstract Scorer iterator(LeafReaderContext context, Bits acceptDocs) throws IOException;
  78.  
  79. /**
  80. * Optional method, to return a {@link BulkScorer} to
  81. @@ -127,7 +142,7 @@
  82. */
  83. public BulkScorer bulkScorer(LeafReaderContext context, boolean scoreDocsInOrder, Bits acceptDocs) throws IOException {
  84.  
  85. - Scorer scorer = scorer(context, acceptDocs);
  86. + Scorer scorer = iterator(context, acceptDocs);
  87. if (scorer == null) {
  88. // No docs match
  89. return null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement