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 E592C11D62 for ; Fri, 19 Sep 2014 15:05:35 +0000 (UTC) Received: (qmail 70926 invoked by uid 500); 19 Sep 2014 15:05:34 -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 70851 invoked by uid 99); 19 Sep 2014 15:05:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Sep 2014 15:05:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED 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; Fri, 19 Sep 2014 15:05:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 69B4123889EB; Fri, 19 Sep 2014 15:05:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1626242 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/util/automaton/ lucene/suggest/ lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/ Date: Fri, 19 Sep 2014 15:05:13 -0000 To: commits@lucene.apache.org From: mikemccand@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140919150513.69B4123889EB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikemccand Date: Fri Sep 19 15:05:12 2014 New Revision: 1626242 URL: http://svn.apache.org/r1626242 Log: LUCENE-5963: more efficient AnalyzingSuggester.replaceSep Modified: lucene/dev/branches/branch_5x/ (props changed) lucene/dev/branches/branch_5x/lucene/ (props changed) lucene/dev/branches/branch_5x/lucene/CHANGES.txt (contents, props changed) lucene/dev/branches/branch_5x/lucene/core/ (props changed) lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java lucene/dev/branches/branch_5x/lucene/suggest/ (props changed) lucene/dev/branches/branch_5x/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java Modified: lucene/dev/branches/branch_5x/lucene/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/CHANGES.txt?rev=1626242&r1=1626241&r2=1626242&view=diff ============================================================================== --- lucene/dev/branches/branch_5x/lucene/CHANGES.txt (original) +++ lucene/dev/branches/branch_5x/lucene/CHANGES.txt Fri Sep 19 15:05:12 2014 @@ -166,6 +166,9 @@ Optimizations * LUCENE-5959: Don't allocate excess memory when building automaton in finish. (Markus Heiden via Mike McCandless) +* LUCENE-5963: Reduce memory allocations in + AnalyzingSuggester. (Markus Heiden via Mike McCandless) + Build * LUCENE-5909: Smoke tester now has better command line parsing and Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java?rev=1626242&r1=1626241&r2=1626242&view=diff ============================================================================== --- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java (original) +++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/util/automaton/Automaton.java Fri Sep 19 15:05:12 2014 @@ -334,6 +334,11 @@ public class Automaton { return nextState/2; } + /** How many transitions this automaton has. */ + public int getNumTransitions() { + return nextTransition / 3; + } + /** How many transitions this state has. */ public int getNumTransitions(int state) { int count = states[2*state+1]; @@ -676,6 +681,20 @@ public class Automaton { transitions[nextTransition++] = max; } + /** Add a [virtual] epsilon transition between source and dest. + * Dest state must already have all transitions added because this + * method simply copies those same transitions over to source. */ + public void addEpsilon(int source, int dest) { + for (int upto = 0; upto < nextTransition; upto += 4) { + if (transitions[upto] == dest) { + addTransition(source, transitions[upto + 1], transitions[upto + 2], transitions[upto + 3]); + } + } + if (isAccept(dest)) { + setAccept(source, true); + } + } + /** Sorts transitions first then min label ascending, then * max label ascending, then dest ascending */ private final Sorter sorter = new InPlaceMergeSorter() { @@ -797,10 +816,11 @@ public class Automaton { public void copy(Automaton other) { int offset = getNumStates(); int otherNumStates = other.getNumStates(); - for(int s=0;s