Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 62312 invoked from network); 6 Dec 2009 18:46:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Dec 2009 18:46:24 -0000 Received: (qmail 45846 invoked by uid 500); 6 Dec 2009 18:46:24 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 45769 invoked by uid 500); 6 Dec 2009 18:46:23 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 45759 invoked by uid 99); 6 Dec 2009 18:46:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Dec 2009 18:46:23 +0000 X-ASF-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Dec 2009 18:46:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BB5C32388882; Sun, 6 Dec 2009 18:46:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r887743 - /lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java Date: Sun, 06 Dec 2009 18:46:00 -0000 To: java-commits@lucene.apache.org From: mikemccand@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091206184600.BB5C32388882@eris.apache.org> Author: mikemccand Date: Sun Dec 6 18:46:00 2009 New Revision: 887743 URL: http://svn.apache.org/viewvc?rev=887743&view=rev Log: LUCENE-2111 (on flex branch): cleanup: remove silly wrapper class in MultiPhraseQuery Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=887743&r1=887742&r2=887743&view=diff ============================================================================== --- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original) +++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java Sun Dec 6 18:46:00 2009 @@ -382,37 +382,30 @@ * Takes the logical union of multiple DocsEnum iterators. */ +// nocommit -- this must carefully take union of attr source +// as well -- this is tricky class UnionDocsEnum extends DocsEnum { - private final static class DocsEnumWrapper { - int doc; - final DocsEnum docsEnum; - public DocsEnumWrapper(DocsEnum docsEnum) { - this.docsEnum = docsEnum; - } - } - - private static final class DocsQueue extends PriorityQueue { - DocsQueue(List docsEnums) throws IOException { + private static final class DocsQueue extends PriorityQueue { + DocsQueue(List docsEnums) throws IOException { initialize(docsEnums.size()); - Iterator i = docsEnums.iterator(); + Iterator i = docsEnums.iterator(); while (i.hasNext()) { - DocsEnumWrapper docs = (DocsEnumWrapper) i.next(); - docs.doc = docs.docsEnum.nextDoc(); - if (docs.doc != DocsEnum.NO_MORE_DOCS) { + DocsEnum docs = (DocsEnum) i.next(); + if (docs.nextDoc() != DocsEnum.NO_MORE_DOCS) { add(docs); } } } - final public DocsEnumWrapper peek() { - return (DocsEnumWrapper) top(); + final public DocsEnum peek() { + return top(); } @Override - public final boolean lessThan(Object a, Object b) { - return ((DocsEnumWrapper) a).doc < ((DocsEnumWrapper) b).doc; + public final boolean lessThan(DocsEnum a, DocsEnum b) { + return a.docID() < b.docID(); } } @@ -421,7 +414,7 @@ private int _index = 0; private int _lastIndex = 0; private int[] _array = new int[_arraySize]; - + final void add(int i) { if (_lastIndex == _arraySize) growArray(); @@ -470,7 +463,7 @@ terms[i].field(), new TermRef(terms[i].text())); if (docs != null) { - docsEnums.add(new DocsEnumWrapper(docs)); + docsEnums.add(docs); } } @@ -494,27 +487,25 @@ // doesn't need the positions for this doc then don't // waste CPU merging them: _posList.clear(); - _doc = _queue.peek().doc; + _doc = _queue.top().docID(); // merge sort all positions together - DocsEnumWrapper docs; + DocsEnum docs; do { - docs = _queue.peek(); - final PositionsEnum positions = docs.docsEnum.positions(); + docs = _queue.top(); + final PositionsEnum positions = docs.positions(); - final int freq = docs.docsEnum.freq(); + final int freq = docs.freq(); for (int i = 0; i < freq; i++) { _posList.add(positions.next()); } - docs.doc = docs.docsEnum.nextDoc(); - - if (docs.doc != NO_MORE_DOCS) { + if (docs.nextDoc() != NO_MORE_DOCS) { _queue.updateTop(); } else { _queue.pop(); } - } while (_queue.size() > 0 && _queue.peek().doc == _doc); + } while (_queue.size() > 0 && _queue.top().docID() == _doc); _posList.sort(); _freq = _posList.size(); @@ -547,10 +538,9 @@ @Override public final int advance(int target) throws IOException { - while (_queue.peek() != null && target > _queue.peek().doc) { - DocsEnumWrapper docs = (DocsEnumWrapper) _queue.pop(); - docs.doc = docs.docsEnum.advance(target); - if (docs.doc != NO_MORE_DOCS) { + while (_queue.top() != null && target > _queue.top().docID()) { + DocsEnum docs = _queue.pop(); + if (docs.advance(target) != NO_MORE_DOCS) { _queue.add(docs); } }