Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8884518B23 for ; Mon, 15 Jun 2015 08:19:59 +0000 (UTC) Received: (qmail 41792 invoked by uid 500); 15 Jun 2015 08:19:59 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 41783 invoked by uid 99); 15 Jun 2015 08:19:59 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2015 08:19:59 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 45831AC02E6 for ; Mon, 15 Jun 2015 08:19:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1685507 - in /lucene/dev/trunk/lucene: CHANGES.txt core/src/java/org/apache/lucene/search/TimeLimitingCollector.java core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Date: Mon, 15 Jun 2015 08:19:59 -0000 To: commits@lucene.apache.org From: simonw@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150615081959.45831AC02E6@hades.apache.org> Author: simonw Date: Mon Jun 15 08:19:58 2015 New Revision: 1685507 URL: http://svn.apache.org/r1685507 Log: LUCENE-6559: TimeLimitingCollector should check timeout also when LeafCollector is pulled Modified: lucene/dev/trunk/lucene/CHANGES.txt lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Modified: lucene/dev/trunk/lucene/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1685507&r1=1685506&r2=1685507&view=diff ============================================================================== --- lucene/dev/trunk/lucene/CHANGES.txt (original) +++ lucene/dev/trunk/lucene/CHANGES.txt Mon Jun 15 08:19:58 2015 @@ -161,6 +161,9 @@ Bug Fixes * LUCENE-6527: Queries now get a dummy Similarity when scores are not needed in order to not load unnecessary information like norms. (Adrien Grand) +* LUCENE-6559: TimeLimitingCollector now also checks for timeout when a new + leaf reader is pulled ie. if we move from one segment to another even without + collecting a hit. (Simon Willnauer) ======================= Lucene 5.2.0 ======================= Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java?rev=1685507&r1=1685506&r2=1685507&view=diff ============================================================================== --- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java (original) +++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/search/TimeLimitingCollector.java Mon Jun 15 08:19:58 2015 @@ -136,6 +136,10 @@ public class TimeLimitingCollector imple if (Long.MIN_VALUE == t0) { setBaseline(); } + final long time = clock.get(); + if (time - timeout > 0L) { + throw new TimeExceededException(timeout - t0, time - t0, -1); + } return new FilterLeafCollector(collector.getLeafCollector(context)) { @Override Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=1685507&r1=1685506&r2=1685507&view=diff ============================================================================== --- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original) +++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Mon Jun 15 08:19:58 2015 @@ -152,7 +152,7 @@ public class TestTimeLimitingCollector e e.printStackTrace(); assertTrue("Unexpected exception: "+e, false); //==fail } - assertEquals( "Wrong number of results!", totalResults, totalTLCResults ); + assertEquals("Wrong number of results!", totalResults, totalTLCResults); } private Collector createTimedCollector(MyHitCollector hc, long timeAllowed, boolean greedy) { @@ -267,6 +267,24 @@ public class TestTimeLimitingCollector e counterThread.setResolution(TimerThread.DEFAULT_RESOLUTION); } } + + public void testNoHits() throws IOException { + MyHitCollector myHc = new MyHitCollector(); + Collector collector = createTimedCollector(myHc, -1, random().nextBoolean()); + // search + TimeExceededException timoutException = null; + try { + BooleanQuery booleanQuery = new BooleanQuery(); // won't match - we only test if we check timeout when collectors are pulled + booleanQuery.add(new TermQuery(new Term(FIELD_NAME, "one")), BooleanClause.Occur.MUST); + booleanQuery.add(new TermQuery(new Term(FIELD_NAME, "blueberry")), BooleanClause.Occur.MUST); + searcher.search(booleanQuery, collector); + } catch (TimeExceededException x) { + timoutException = x; + } + // must get exception + assertNotNull("Timeout expected!", timoutException); + assertEquals(-1, myHc.getLastDocCollected()); + } /** * Test correctness with multiple searching threads.