From e077c4d563d4fda4cb629f54548c54d41e7fa445 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 25 Nov 2009 20:44:17 +0000 Subject: [PATCH] Updated JakartaRegexpCapabilities JavaDoc which gave users the impression the JakartaRegexp implementation provides a rock solid "prefix" implementation. Patch contains another testcase which shows the shaky behavior. See LUCENE-2072 for reference. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@884259 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/search/regex/JakartaRegexpCapabilities.java | 8 +++++--- .../search/regex/TestJakartaRegexpCapabilities.java | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java b/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java index 9c69bb9b78c..3e7c4298e19 100644 --- a/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java +++ b/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java @@ -21,9 +21,11 @@ import org.apache.regexp.RE; import org.apache.regexp.RegexpTunnel; /** - * Implementation tying Jakarta Regexp - * to RegexQuery. Thanks to some internals of Jakarta Regexp, this - * has a solid {@link #prefix} implementation. + * Implementation tying Jakarta + * Regexp to RegexQuery. Jakarta Regepx internally supports a + * {@link #prefix} implementation which can offer performance gains under + * certain circumstances. Yet, the implementation appears to be rather shaky as + * it doesn't always provide a prefix even if one would exist. */ public class JakartaRegexpCapabilities implements RegexCapabilities { private RE regexp; diff --git a/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java b/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java index d5552bc938d..e9ca88dc9c0 100644 --- a/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java +++ b/contrib/regex/src/test/org/apache/lucene/search/regex/TestJakartaRegexpCapabilities.java @@ -34,4 +34,13 @@ public class TestJakartaRegexpCapabilities extends TestCase { assertTrue(cap.match("lucene")); assertEquals("lucene", cap.prefix()); } + + public void testShakyPrefix(){ + JakartaRegexpCapabilities cap = new JakartaRegexpCapabilities(); + cap.compile("(ab|ac)"); + assertTrue(cap.match("ab")); + assertTrue(cap.match("ac")); + // why is it not a??? + assertNull(cap.prefix()); + } }