You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/07/19 17:59:32 UTC
svn commit: r1363400 [19/31] - in /lucene/dev/branches/pforcodec_3892: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/
dev-tools/idea/.idea/copyright/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/ dev-tools/maven/ dev-tools/maven/lucene...
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/QueryNodeImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/QueryNodeImpl.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/QueryNodeImpl.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/QueryNodeImpl.java Thu Jul 19 15:58:54 2012
@@ -20,6 +20,7 @@ package org.apache.lucene.queryparser.fl
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
@@ -151,20 +152,20 @@ public abstract class QueryNodeImpl impl
}
public void setTag(String tagName, Object value) {
- this.tags.put(tagName.toLowerCase(), value);
+ this.tags.put(tagName.toLowerCase(Locale.ROOT), value);
}
public void unsetTag(String tagName) {
- this.tags.remove(tagName.toLowerCase());
+ this.tags.remove(tagName.toLowerCase(Locale.ROOT));
}
/** verify if a node contains a tag */
public boolean containsTag(String tagName) {
- return this.tags.containsKey(tagName.toLowerCase());
+ return this.tags.containsKey(tagName.toLowerCase(Locale.ROOT));
}
public Object getTag(String tagName) {
- return this.tags.get(tagName.toString().toLowerCase());
+ return this.tags.get(tagName.toLowerCase(Locale.ROOT));
}
private QueryNode parent = null;
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/util/UnescapedCharSequence.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/util/UnescapedCharSequence.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/util/UnescapedCharSequence.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/util/UnescapedCharSequence.java Thu Jul 19 15:58:54 2012
@@ -1,5 +1,7 @@
package org.apache.lucene.queryparser.flexible.core.util;
+import java.util.Locale;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -146,12 +148,12 @@ public final class UnescapedCharSequence
else return false;
}
- public static CharSequence toLowerCase(CharSequence text) {
+ public static CharSequence toLowerCase(CharSequence text, Locale locale) {
if (text instanceof UnescapedCharSequence) {
- char[] chars = text.toString().toLowerCase().toCharArray();
+ char[] chars = text.toString().toLowerCase(locale).toCharArray();
boolean[] wasEscaped = ((UnescapedCharSequence)text).wasEscaped;
return new UnescapedCharSequence(chars, wasEscaped, 0, chars.length);
} else
- return new UnescapedCharSequence(text.toString().toLowerCase());
+ return new UnescapedCharSequence(text.toString().toLowerCase(locale));
}
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java Thu Jul 19 15:58:54 2012
@@ -174,13 +174,13 @@ public class NLS {
Locale.getDefault());
if (resourceBundle != null) {
Object obj = resourceBundle.getObject(key);
- if (obj == null)
- System.err.println("WARN: Message with key:" + key + " and locale: "
- + Locale.getDefault() + " not found.");
+ //if (obj == null)
+ // System.err.println("WARN: Message with key:" + key + " and locale: "
+ // + Locale.getDefault() + " not found.");
}
} catch (MissingResourceException e) {
- System.err.println("WARN: Message with key:" + key + " and locale: "
- + Locale.getDefault() + " not found.");
+ //System.err.println("WARN: Message with key:" + key + " and locale: "
+ // + Locale.getDefault() + " not found.");
} catch (Throwable e) {
// ignore all other errors and exceptions
// since this code is just a test to see if the message is present on the
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/StandardQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/StandardQueryParser.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/StandardQueryParser.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/StandardQueryParser.java Thu Jul 19 15:58:54 2012
@@ -19,6 +19,7 @@ package org.apache.lucene.queryparser.fl
import java.util.Locale;
import java.util.Map;
+import java.util.TimeZone;
import java.util.TooManyListenersException;
import org.apache.lucene.analysis.Analyzer;
@@ -344,6 +345,14 @@ public class StandardQueryParser extends
return getQueryConfigHandler().get(ConfigurationKeys.LOCALE);
}
+ public void setTimeZone(TimeZone timeZone) {
+ getQueryConfigHandler().set(ConfigurationKeys.TIMEZONE, timeZone);
+ }
+
+ public TimeZone getTimeZone() {
+ return getQueryConfigHandler().get(ConfigurationKeys.TIMEZONE);
+ }
+
/**
* Sets the default slop for phrases. If zero, then exact phrase matches are
* required. Default value is zero.
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/BooleanQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/BooleanQueryNodeBuilder.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/BooleanQueryNodeBuilder.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/BooleanQueryNodeBuilder.java Thu Jul 19 15:58:54 2012
@@ -83,8 +83,7 @@ public class BooleanQueryNodeBuilder imp
}
- private static BooleanClause.Occur getModifierValue(QueryNode node)
- throws QueryNodeException {
+ private static BooleanClause.Occur getModifierValue(QueryNode node) {
if (node instanceof ModifierQueryNode) {
ModifierQueryNode mNode = ((ModifierQueryNode) node);
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/StandardBooleanQueryNodeBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/StandardBooleanQueryNodeBuilder.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/StandardBooleanQueryNodeBuilder.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/StandardBooleanQueryNodeBuilder.java Thu Jul 19 15:58:54 2012
@@ -84,8 +84,7 @@ public class StandardBooleanQueryNodeBui
}
- private static BooleanClause.Occur getModifierValue(QueryNode node)
- throws QueryNodeException {
+ private static BooleanClause.Occur getModifierValue(QueryNode node) {
if (node instanceof ModifierQueryNode) {
ModifierQueryNode mNode = ((ModifierQueryNode) node);
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/StandardQueryConfigHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/StandardQueryConfigHandler.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/StandardQueryConfigHandler.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/config/StandardQueryConfigHandler.java Thu Jul 19 15:58:54 2012
@@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
+import java.util.TimeZone;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.DateTools;
@@ -101,6 +102,8 @@ public class StandardQueryConfigHandler
*/
final public static ConfigurationKey<Locale> LOCALE = ConfigurationKey.newInstance();
+ final public static ConfigurationKey<TimeZone> TIMEZONE = ConfigurationKey.newInstance();
+
/**
* Key used to set the {@link RewriteMethod} used when creating queries
*
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/NumericQueryNode.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/NumericQueryNode.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/NumericQueryNode.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/NumericQueryNode.java Thu Jul 19 15:58:54 2012
@@ -90,8 +90,8 @@ public class NumericQueryNode extends Qu
* @return the value converte to {@link String} and escaped
*/
protected CharSequence getTermEscaped(EscapeQuerySyntax escaper) {
- return escaper.escape(NumberFormat.getNumberInstance().format(this.value),
- Locale.ENGLISH, Type.NORMAL);
+ return escaper.escape(numberFormat.format(this.value),
+ Locale.ROOT, Type.NORMAL);
}
public CharSequence toQueryString(EscapeQuerySyntax escapeSyntaxParser) {
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/EscapeQuerySyntaxImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/EscapeQuerySyntaxImpl.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/EscapeQuerySyntaxImpl.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/EscapeQuerySyntaxImpl.java Thu Jul 19 15:58:54 2012
@@ -50,7 +50,7 @@ public class EscapeQuerySyntaxImpl imple
// regular escapable Char for terms
for (int i = 0; i < escapableTermChars.length; i++) {
- buffer = replaceIgnoreCase(buffer, escapableTermChars[i].toLowerCase(),
+ buffer = replaceIgnoreCase(buffer, escapableTermChars[i].toLowerCase(locale),
"\\", locale);
}
@@ -73,7 +73,7 @@ public class EscapeQuerySyntaxImpl imple
CharSequence buffer = str;
for (int i = 0; i < escapableQuotedChars.length; i++) {
- buffer = replaceIgnoreCase(buffer, escapableTermChars[i].toLowerCase(),
+ buffer = replaceIgnoreCase(buffer, escapableTermChars[i].toLowerCase(locale),
"\\", locale);
}
return buffer;
@@ -178,7 +178,7 @@ public class EscapeQuerySyntaxImpl imple
CharSequence buffer = str;
for (int i = 0; i < escapableWhiteChars.length; i++) {
- buffer = replaceIgnoreCase(buffer, escapableWhiteChars[i].toLowerCase(),
+ buffer = replaceIgnoreCase(buffer, escapableWhiteChars[i].toLowerCase(locale),
"\\", locale);
}
return buffer;
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java Thu Jul 19 15:58:54 2012
@@ -193,4 +193,4 @@ public class ParseException extends Quer
}
}
-/* JavaCC - OriginalChecksum=0f25f4245374bbf9920c9a82efecadd2 (do not edit this line) */
+/* JavaCC - OriginalChecksum=7601d49d11bc059457ae5850628ebc8a (do not edit this line) */
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java Thu Jul 19 15:58:54 2012
@@ -1,7 +1,7 @@
/* Generated By:JavaCC: Do not edit this line. StandardSyntaxParser.java */
package org.apache.lucene.queryparser.flexible.standard.parser;
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -49,14 +49,14 @@ public class StandardSyntaxParser implem
// syntax parser constructor
public StandardSyntaxParser() {
- this(new StringReader(""));
+ this(new FastCharStream(new StringReader("")));
}
/** Parses a query string, returning a {@link org.apache.lucene.queryparser.flexible.core.nodes.QueryNode}.
* @param query the query string to be parsed.
* @throws ParseException if the parsing fails
*/
public QueryNode parse(CharSequence query, CharSequence field) throws QueryNodeParseException {
- ReInit(new StringReader(query.toString()));
+ ReInit(new FastCharStream(new StringReader(query.toString())));
try {
// TopLevelQuery is a Query followed by the end-of-input (EOF)
QueryNode querynode = TopLevelQuery(field);
@@ -844,7 +844,6 @@ public class StandardSyntaxParser implem
/** Generated Token Manager. */
public StandardSyntaxParserTokenManager token_source;
- JavaCharStream jj_input_stream;
/** Current token. */
public Token token;
/** Next token. */
@@ -870,14 +869,9 @@ public class StandardSyntaxParser implem
private boolean jj_rescan = false;
private int jj_gc = 0;
- /** Constructor with InputStream. */
- public StandardSyntaxParser(java.io.InputStream stream) {
- this(stream, null);
- }
- /** Constructor with InputStream and supplied encoding */
- public StandardSyntaxParser(java.io.InputStream stream, String encoding) {
- try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
- token_source = new StandardSyntaxParserTokenManager(jj_input_stream);
+ /** Constructor with user supplied CharStream. */
+ public StandardSyntaxParser(CharStream stream) {
+ token_source = new StandardSyntaxParserTokenManager(stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
@@ -886,35 +880,8 @@ public class StandardSyntaxParser implem
}
/** Reinitialise. */
- public void ReInit(java.io.InputStream stream) {
- ReInit(stream, null);
- }
- /** Reinitialise. */
- public void ReInit(java.io.InputStream stream, String encoding) {
- try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
- token_source.ReInit(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- /** Constructor. */
- public StandardSyntaxParser(java.io.Reader stream) {
- jj_input_stream = new JavaCharStream(stream, 1, 1);
- token_source = new StandardSyntaxParserTokenManager(jj_input_stream);
- token = new Token();
- jj_ntk = -1;
- jj_gen = 0;
- for (int i = 0; i < 28; i++) jj_la1[i] = -1;
- for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
- }
-
- /** Reinitialise. */
- public void ReInit(java.io.Reader stream) {
- jj_input_stream.ReInit(stream, 1, 1);
- token_source.ReInit(jj_input_stream);
+ public void ReInit(CharStream stream) {
+ token_source.ReInit(stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj Thu Jul 19 15:58:54 2012
@@ -5,7 +5,7 @@
options {
STATIC=false;
JAVA_UNICODE_ESCAPE=true;
- USER_CHAR_STREAM=false;
+ USER_CHAR_STREAM=true;
IGNORE_CASE=false;
JDK_VERSION="1.5";
}
@@ -61,14 +61,14 @@ public class StandardSyntaxParser implem
// syntax parser constructor
public StandardSyntaxParser() {
- this(new StringReader(""));
+ this(new FastCharStream(new StringReader("")));
}
/** Parses a query string, returning a {@link org.apache.lucene.queryparser.flexible.core.nodes.QueryNode}.
* @param query the query string to be parsed.
* @throws ParseException if the parsing fails
*/
public QueryNode parse(CharSequence query, CharSequence field) throws QueryNodeParseException {
- ReInit(new StringReader(query.toString()));
+ ReInit(new FastCharStream(new StringReader(query.toString())));
try {
// TopLevelQuery is a Query followed by the end-of-input (EOF)
QueryNode querynode = TopLevelQuery(field);
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java Thu Jul 19 15:58:54 2012
@@ -1,6 +1,6 @@
/* Generated By:JavaCC: Do not edit this line. StandardSyntaxParserTokenManager.java */
package org.apache.lucene.queryparser.flexible.standard.parser;
-/*
+/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -781,25 +781,23 @@ static final long[] jjtoToken = {
static final long[] jjtoSkip = {
0x80L,
};
-protected JavaCharStream input_stream;
+protected CharStream input_stream;
private final int[] jjrounds = new int[33];
private final int[] jjstateSet = new int[66];
protected char curChar;
/** Constructor. */
-public StandardSyntaxParserTokenManager(JavaCharStream stream){
- if (JavaCharStream.staticFlag)
- throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+public StandardSyntaxParserTokenManager(CharStream stream){
input_stream = stream;
}
/** Constructor. */
-public StandardSyntaxParserTokenManager(JavaCharStream stream, int lexState){
+public StandardSyntaxParserTokenManager(CharStream stream, int lexState){
this(stream);
SwitchTo(lexState);
}
/** Reinitialise parser. */
-public void ReInit(JavaCharStream stream)
+public void ReInit(CharStream stream)
{
jjmatchedPos = jjnewStateCnt = 0;
curLexState = defaultLexState;
@@ -815,7 +813,7 @@ private void ReInitRounds()
}
/** Reinitialise parser. */
-public void ReInit(JavaCharStream stream, int lexState)
+public void ReInit(CharStream stream, int lexState)
{
ReInit(stream);
SwitchTo(lexState);
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java Thu Jul 19 15:58:54 2012
@@ -121,4 +121,4 @@ public class Token {
}
}
-/* JavaCC - OriginalChecksum=e9c55091ec11152bcd3a300ddff5c73a (do not edit this line) */
+/* JavaCC - OriginalChecksum=3b4fe6dcfcfa24a81f1c6ceffae5f73a (do not edit this line) */
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java Thu Jul 19 15:58:54 2012
@@ -138,4 +138,4 @@ public class TokenMgrError extends Error
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}
-/* JavaCC - OriginalChecksum=76b513fd9c50f65248056bbeeff49277 (do not edit this line) */
+/* JavaCC - OriginalChecksum=1efb3d906925f2478637c66473b79bae (do not edit this line) */
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/LowercaseExpandedTermsQueryNodeProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/LowercaseExpandedTermsQueryNodeProcessor.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/LowercaseExpandedTermsQueryNodeProcessor.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/LowercaseExpandedTermsQueryNodeProcessor.java Thu Jul 19 15:58:54 2012
@@ -18,6 +18,7 @@ package org.apache.lucene.queryparser.fl
*/
import java.util.List;
+import java.util.Locale;
import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler;
@@ -46,7 +47,6 @@ public class LowercaseExpandedTermsQuery
QueryNodeProcessorImpl {
public LowercaseExpandedTermsQueryNodeProcessor() {
- // empty constructor
}
@Override
@@ -63,6 +63,11 @@ public class LowercaseExpandedTermsQuery
@Override
protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
+
+ Locale locale = getQueryConfigHandler().get(ConfigurationKeys.LOCALE);
+ if (locale == null) {
+ locale = Locale.getDefault();
+ }
if (node instanceof WildcardQueryNode
|| node instanceof FuzzyQueryNode
@@ -71,7 +76,7 @@ public class LowercaseExpandedTermsQuery
TextableQueryNode txtNode = (TextableQueryNode) node;
CharSequence text = txtNode.getText();
- txtNode.setText(text != null ? UnescapedCharSequence.toLowerCase(text) : null);
+ txtNode.setText(text != null ? UnescapedCharSequence.toLowerCase(text, locale) : null);
}
return node;
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/StandardQueryNodeProcessorPipeline.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/StandardQueryNodeProcessorPipeline.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/StandardQueryNodeProcessorPipeline.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/StandardQueryNodeProcessorPipeline.java Thu Jul 19 15:58:54 2012
@@ -17,12 +17,15 @@ package org.apache.lucene.queryparser.fl
* limitations under the License.
*/
+import java.util.Locale;
+
import org.apache.lucene.queryparser.flexible.core.config.QueryConfigHandler;
import org.apache.lucene.queryparser.flexible.core.processors.NoChildOptimizationQueryNodeProcessor;
import org.apache.lucene.queryparser.flexible.core.processors.QueryNodeProcessorPipeline;
import org.apache.lucene.queryparser.flexible.core.processors.RemoveDeletedQueryNodesProcessor;
import org.apache.lucene.queryparser.flexible.standard.builders.StandardQueryTreeBuilder;
import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler;
+import org.apache.lucene.queryparser.flexible.standard.config.StandardQueryConfigHandler.ConfigurationKeys;
import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser;
import org.apache.lucene.search.Query;
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/TermRangeQueryNodeProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/TermRangeQueryNodeProcessor.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/TermRangeQueryNodeProcessor.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/processors/TermRangeQueryNodeProcessor.java Thu Jul 19 15:58:54 2012
@@ -22,6 +22,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
+import java.util.TimeZone;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.DateTools.Resolution;
@@ -76,6 +77,12 @@ public class TermRangeQueryNodeProcessor
locale = Locale.getDefault();
}
+ TimeZone timeZone = getQueryConfigHandler().get(ConfigurationKeys.TIMEZONE);
+
+ if (timeZone == null) {
+ timeZone = TimeZone.getDefault();
+ }
+
CharSequence field = termRangeNode.getField();
String fieldStr = null;
@@ -114,7 +121,7 @@ public class TermRangeQueryNodeProcessor
// the time is set to the latest possible time of that date to
// really
// include all documents:
- Calendar cal = Calendar.getInstance(locale);
+ Calendar cal = Calendar.getInstance(timeZone, locale);
cal.setTime(d2);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/FastCharStream.java Thu Jul 19 15:58:54 2012
@@ -96,7 +96,6 @@ public final class FastCharStream implem
try {
input.close();
} catch (IOException e) {
- System.err.println("Caught: " + e + "; ignoring.");
}
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/FieldsQuery.java Thu Jul 19 15:58:54 2012
@@ -60,7 +60,7 @@ public class FieldsQuery extends SrndQue
OrQuery oq = new OrQuery(queries,
true /* infix OR for field names */,
OrOperatorName);
- System.out.println(getClass().toString() + ", fields expanded: " + oq.toString()); /* needs testing */
+ // System.out.println(getClass().toString() + ", fields expanded: " + oq.toString()); /* needs testing */
return oq.makeLuceneQueryField(null, qf);
}
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/query/SrndQuery.java Thu Jul 19 15:58:54 2012
@@ -73,7 +73,7 @@ public abstract class SrndQuery implemen
/** For subclasses of {@link SrndQuery} within the package
* {@link org.apache.lucene.queryparser.surround.query}
* it is not necessary to override this method,
- * @see #toString().
+ * @see #toString()
*/
@Override
public int hashCode() {
@@ -83,7 +83,7 @@ public abstract class SrndQuery implemen
/** For subclasses of {@link SrndQuery} within the package
* {@link org.apache.lucene.queryparser.surround.query}
* it is not necessary to override this method,
- * @see #toString().
+ * @see #toString()
*/
@Override
public boolean equals(Object obj) {
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/QueryTemplateManager.java Thu Jul 19 15:58:54 2012
@@ -11,7 +11,7 @@ import javax.xml.transform.*;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
@@ -97,11 +97,12 @@ public class QueryTemplateManager {
* Fast means of constructing query using a precompiled stylesheet
*/
public static String getQueryAsXmlString(Properties formProperties, Templates template)
- throws SAXException, IOException, ParserConfigurationException, TransformerException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- StreamResult result = new StreamResult(baos);
+ throws ParserConfigurationException, TransformerException {
+ // TODO: Suppress XML header with encoding (as Strings have no encoding)
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
transformCriteria(formProperties, template, result);
- return baos.toString();
+ return writer.toString();
}
/**
@@ -109,10 +110,11 @@ public class QueryTemplateManager {
*/
public static String getQueryAsXmlString(Properties formProperties, InputStream xslIs)
throws SAXException, IOException, ParserConfigurationException, TransformerException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- StreamResult result = new StreamResult(baos);
+ // TODO: Suppress XML header with encoding (as Strings have no encoding)
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
transformCriteria(formProperties, xslIs, result);
- return baos.toString();
+ return writer.toString();
}
@@ -120,7 +122,7 @@ public class QueryTemplateManager {
* Fast means of constructing query using a cached,precompiled stylesheet
*/
public static Document getQueryAsDOM(Properties formProperties, Templates template)
- throws SAXException, IOException, ParserConfigurationException, TransformerException {
+ throws ParserConfigurationException, TransformerException {
DOMResult result = new DOMResult();
transformCriteria(formProperties, template, result);
return (Document) result.getNode();
@@ -159,13 +161,13 @@ public class QueryTemplateManager {
* Fast transformation using a pre-compiled stylesheet (suitable for production environments)
*/
public static void transformCriteria(Properties formProperties, Templates template, Result result)
- throws SAXException, IOException, ParserConfigurationException, TransformerException {
+ throws ParserConfigurationException, TransformerException {
transformCriteria(formProperties, template.newTransformer(), result);
}
public static void transformCriteria(Properties formProperties, Transformer transformer, Result result)
- throws SAXException, IOException, ParserConfigurationException, TransformerException {
+ throws ParserConfigurationException, TransformerException {
dbf.setNamespaceAware(true);
//Create an XML document representing the search index document.
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/analyzing/TestAnalyzingQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/analyzing/TestAnalyzingQueryParser.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/analyzing/TestAnalyzingQueryParser.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/analyzing/TestAnalyzingQueryParser.java Thu Jul 19 15:58:54 2012
@@ -22,7 +22,16 @@ import java.io.Reader;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.queryparser.classic.ParseException;
+import org.apache.lucene.queryparser.classic.QueryParser;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -138,5 +147,28 @@ public class TestAnalyzingQueryParser ex
Tokenizer result = new MockTokenizer(reader, MockTokenizer.SIMPLE, true);
return new TokenStreamComponents(result, new FoldingFilter(result));
}
- }
+ }
+
+ // LUCENE-4176
+ public void testByteTerms() throws Exception {
+ Directory ramDir = newDirectory();
+ Analyzer analyzer = new MockBytesAnalyzer();
+ RandomIndexWriter writer = new RandomIndexWriter(random(), ramDir, analyzer);
+ Document doc = new Document();
+ FieldType fieldType = new FieldType();
+ fieldType.setIndexed(true);
+ fieldType.setTokenized(true);
+ fieldType.setStored(true);
+ Field field = new Field("content","à¹à¸", fieldType);
+ doc.add(field);
+ writer.addDocument(doc);
+ writer.close();
+ DirectoryReader ir = DirectoryReader.open(ramDir);
+ IndexSearcher is = new IndexSearcher(ir);
+ QueryParser qp = new AnalyzingQueryParser(TEST_VERSION_CURRENT, "content", analyzer);
+ Query q = qp.parse("[à¹à¸ TO à¹à¸]");
+ assertEquals(1, is.search(q, 10).totalHits);
+ ir.close();
+ ramDir.close();
+ }
}
\ No newline at end of file
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiPhraseQueryParsing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiPhraseQueryParsing.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiPhraseQueryParsing.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiPhraseQueryParsing.java Thu Jul 19 15:58:54 2012
@@ -18,7 +18,6 @@ package org.apache.lucene.queryparser.cl
*/
import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
@@ -67,7 +66,7 @@ public class TestMultiPhraseQueryParsing
}
@Override
- public final boolean incrementToken() throws IOException {
+ public final boolean incrementToken() {
clearAttributes();
if (upto < tokens.length) {
final TokenAndPos token = tokens[upto++];
@@ -82,8 +81,8 @@ public class TestMultiPhraseQueryParsing
}
@Override
- public void reset(Reader reader) throws IOException {
- super.reset(reader);
+ public void setReader(Reader reader) throws IOException {
+ super.setReader(reader);
this.upto = 0;
this.lastPos = 0;
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/ext/TestExtendableQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/ext/TestExtendableQueryParser.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/ext/TestExtendableQueryParser.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/ext/TestExtendableQueryParser.java Thu Jul 19 15:58:54 2012
@@ -17,6 +17,8 @@ package org.apache.lucene.queryparser.ex
* limitations under the License.
*/
+import java.util.Locale;
+
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@@ -70,7 +72,7 @@ public class TestExtendableQueryParser e
ExtendableQueryParser parser = (ExtendableQueryParser) getParser(null,
ext);
String field = ext.buildExtensionField("testExt", "aField");
- Query query = parser.parse(String.format("%s:foo bar", field));
+ Query query = parser.parse(String.format(Locale.ROOT, "%s:foo bar", field));
assertTrue("expected instance of BooleanQuery but was "
+ query.getClass(), query instanceof BooleanQuery);
BooleanQuery bquery = (BooleanQuery) query;
@@ -102,7 +104,7 @@ public class TestExtendableQueryParser e
ExtendableQueryParser parser = (ExtendableQueryParser) getParser(null,
ext);
String field = ext.buildExtensionField("testExt");
- Query parse = parser.parse(String.format("%s:\"foo \\& bar\"", field));
+ Query parse = parser.parse(String.format(Locale.ROOT, "%s:\"foo \\& bar\"", field));
assertTrue("expected instance of TermQuery but was " + parse.getClass(),
parse instanceof TermQuery);
TermQuery tquery = (TermQuery) parse;
@@ -122,7 +124,7 @@ public class TestExtendableQueryParser e
ExtendableQueryParser parser = (ExtendableQueryParser) getParser(null,
ext);
String field = ext.buildExtensionField("testExt", "afield");
- Query parse = parser.parse(String.format("%s:\"foo \\& bar\"", field));
+ Query parse = parser.parse(String.format(Locale.ROOT, "%s:\"foo \\& bar\"", field));
assertTrue("expected instance of TermQuery but was " + parse.getClass(),
parse instanceof TermQuery);
TermQuery tquery = (TermQuery) parse;
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/precedence/TestPrecedenceQueryParser.java Thu Jul 19 15:58:54 2012
@@ -24,7 +24,9 @@ import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
+import java.util.TimeZone;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
@@ -385,14 +387,16 @@ public class TestPrecedenceQueryParser e
}
public String getDate(String s) throws Exception {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
+ // we use the default Locale since LuceneTestCase randomizes it
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
return DateTools.dateToString(df.parse(s), DateTools.Resolution.DAY);
}
private String getLocalizedDate(int year, int month, int day,
boolean extendLastDate) {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
- Calendar calendar = new GregorianCalendar();
+ // we use the default Locale/TZ since LuceneTestCase randomizes it
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
+ Calendar calendar = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
calendar.set(year, month, day);
if (extendLastDate) {
calendar.set(Calendar.HOUR_OF_DAY, 23);
@@ -406,7 +410,8 @@ public class TestPrecedenceQueryParser e
public void testDateRange() throws Exception {
String startDate = getLocalizedDate(2002, 1, 1, false);
String endDate = getLocalizedDate(2002, 1, 4, false);
- Calendar endDateExpected = new GregorianCalendar();
+ // we use the default Locale/TZ since LuceneTestCase randomizes it
+ Calendar endDateExpected = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
endDateExpected.set(2002, 1, 4, 23, 59, 59);
endDateExpected.set(Calendar.MILLISECOND, 999);
final String defaultField = "default";
@@ -441,12 +446,13 @@ public class TestPrecedenceQueryParser e
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution) throws Exception {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
+ // we use the default Locale since LuceneTestCase randomizes it
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
return getDate(df.parse(s), resolution);
}
/** for testing DateTools support */
- private String getDate(Date d, DateTools.Resolution resolution) throws Exception {
+ private String getDate(Date d, DateTools.Resolution resolution) {
return DateTools.dateToString(d, resolution);
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java Thu Jul 19 15:58:54 2012
@@ -27,6 +27,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.TimeZone;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -675,13 +676,13 @@ public class TestQPHelper extends Lucene
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution)
throws Exception {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
+ // we use the default Locale since LuceneTestCase randomizes it
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
return getDate(df.parse(s), resolution);
}
/** for testing DateTools support */
- private String getDate(Date d, DateTools.Resolution resolution)
- throws Exception {
+ private String getDate(Date d, DateTools.Resolution resolution) {
return DateTools.dateToString(d, resolution);
}
@@ -694,8 +695,9 @@ public class TestQPHelper extends Lucene
}
private String getLocalizedDate(int year, int month, int day) {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
- Calendar calendar = new GregorianCalendar();
+ // we use the default Locale/TZ since LuceneTestCase randomizes it
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
+ Calendar calendar = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
calendar.clear();
calendar.set(year, month, day);
calendar.set(Calendar.HOUR_OF_DAY, 23);
@@ -708,7 +710,8 @@ public class TestQPHelper extends Lucene
public void testDateRange() throws Exception {
String startDate = getLocalizedDate(2002, 1, 1);
String endDate = getLocalizedDate(2002, 1, 4);
- Calendar endDateExpected = new GregorianCalendar();
+ // we use the default Locale/TZ since LuceneTestCase randomizes it
+ Calendar endDateExpected = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
endDateExpected.clear();
endDateExpected.set(2002, 1, 4, 23, 59, 59);
endDateExpected.set(Calendar.MILLISECOND, 999);
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java Thu Jul 19 15:58:54 2012
@@ -24,6 +24,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
+import java.util.TimeZone;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -581,18 +582,20 @@ public abstract class QueryParserTestBas
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution) throws Exception {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
+ // we use the default Locale since LuceneTestCase randomizes it
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
return getDate(df.parse(s), resolution);
}
/** for testing DateTools support */
- private String getDate(Date d, DateTools.Resolution resolution) throws Exception {
+ private String getDate(Date d, DateTools.Resolution resolution) {
return DateTools.dateToString(d, resolution);
}
private String getLocalizedDate(int year, int month, int day) {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
- Calendar calendar = new GregorianCalendar();
+ // we use the default Locale/TZ since LuceneTestCase randomizes it
+ DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault());
+ Calendar calendar = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
calendar.clear();
calendar.set(year, month, day);
calendar.set(Calendar.HOUR_OF_DAY, 23);
@@ -605,7 +608,8 @@ public abstract class QueryParserTestBas
public void testDateRange() throws Exception {
String startDate = getLocalizedDate(2002, 1, 1);
String endDate = getLocalizedDate(2002, 1, 4);
- Calendar endDateExpected = new GregorianCalendar();
+ // we use the default Locale/TZ since LuceneTestCase randomizes it
+ Calendar endDateExpected = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault());
endDateExpected.clear();
endDateExpected.set(2002, 1, 4, 23, 59, 59);
endDateExpected.set(Calendar.MILLISECOND, 999);
@@ -936,13 +940,13 @@ public abstract class QueryParserTestBas
final int[] type = new int[1];
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "field", new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false)) {
@Override
- protected Query getWildcardQuery(String field, String termStr) throws ParseException {
+ protected Query getWildcardQuery(String field, String termStr) {
// override error checking of superclass
type[0]=1;
return new TermQuery(new Term(field,termStr));
}
@Override
- protected Query getPrefixQuery(String field, String termStr) throws ParseException {
+ protected Query getPrefixQuery(String field, String termStr) {
// override error checking of superclass
type[0]=2;
return new TermQuery(new Term(field,termStr));
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java Thu Jul 19 15:58:54 2012
@@ -61,7 +61,8 @@ public class TestParser extends LuceneTe
//initialize the parser
builder = new CorePlusExtensionsParser("contents", analyzer);
- BufferedReader d = new BufferedReader(new InputStreamReader(TestParser.class.getResourceAsStream("reuters21578.txt")));
+ BufferedReader d = new BufferedReader(new InputStreamReader(
+ TestParser.class.getResourceAsStream("reuters21578.txt"), "US-ASCII"));
dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(Version.LUCENE_40, analyzer));
String line = d.readLine();
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java Thu Jul 19 15:58:54 2012
@@ -203,7 +203,7 @@ public class TestNumericRangeFilterBuild
private static Document getDocumentFromString(String str)
throws SAXException, IOException, ParserConfigurationException {
- InputStream is = new ByteArrayInputStream(str.getBytes());
+ InputStream is = new ByteArrayInputStream(str.getBytes("UTF-8"));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Modified: lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeQueryBuilder.java Thu Jul 19 15:58:54 2012
@@ -166,7 +166,7 @@ public class TestNumericRangeQueryBuilde
private static Document getDocumentFromString(String str)
throws SAXException, IOException, ParserConfigurationException {
- InputStream is = new ByteArrayInputStream(str.getBytes());
+ InputStream is = new ByteArrayInputStream(str.getBytes("UTF-8"));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Modified: lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowCollatedTermRangeTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowCollatedTermRangeTermsEnum.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowCollatedTermRangeTermsEnum.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/SlowCollatedTermRangeTermsEnum.java Thu Jul 19 15:58:54 2012
@@ -63,11 +63,9 @@ public class SlowCollatedTermRangeTermsE
* The collator to use to collate index Terms, to determine their
* membership in the range bounded by <code>lowerTerm</code> and
* <code>upperTerm</code>.
- *
- * @throws IOException
*/
public SlowCollatedTermRangeTermsEnum(TermsEnum tenum, String lowerTermText, String upperTermText,
- boolean includeLower, boolean includeUpper, Collator collator) throws IOException {
+ boolean includeLower, boolean includeUpper, Collator collator) {
super(tenum);
this.collator = collator;
this.upperTermText = upperTermText;
Modified: lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/regex/RegexTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/regex/RegexTermsEnum.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/regex/RegexTermsEnum.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/regex/RegexTermsEnum.java Thu Jul 19 15:58:54 2012
@@ -23,8 +23,6 @@ import org.apache.lucene.index.TermsEnum
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.StringHelper;
-import java.io.IOException;
-
/**
* Subclass of FilteredTermEnum for enumerating all terms that match the
* specified regular expression term using the specified regular expression
@@ -39,7 +37,7 @@ public class RegexTermsEnum extends Filt
private RegexCapabilities.RegexMatcher regexImpl;
private final BytesRef prefixRef;
- public RegexTermsEnum(TermsEnum tenum, Term term, RegexCapabilities regexCap) throws IOException {
+ public RegexTermsEnum(TermsEnum tenum, Term term, RegexCapabilities regexCap) {
super(tenum);
String text = term.text();
this.regexImpl = regexCap.compile(text);
Modified: lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java Thu Jul 19 15:58:54 2012
@@ -1,6 +1,5 @@
package org.apache.lucene.sandbox.queries;
-import java.io.IOException;
import java.text.Collator;
import java.util.Locale;
@@ -90,7 +89,7 @@ public class TestSlowCollationMethods ex
public void testSort() throws Exception {
SortField sf = new SortField("field", new FieldComparatorSource() {
@Override
- public FieldComparator<String> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
+ public FieldComparator<String> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) {
return new SlowCollatedStringComparator(numHits, fieldname, collator);
}
});
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+package org.apache.lucene.spatial;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,62 +17,92 @@
* limitations under the License.
*/
-package org.apache.lucene.spatial;
-
import com.spatial4j.core.context.SpatialContext;
-import com.spatial4j.core.query.SpatialArgs;
import com.spatial4j.core.shape.Shape;
import org.apache.lucene.index.IndexableField;
+import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.FilteredQuery;
import org.apache.lucene.search.Query;
+import org.apache.lucene.spatial.query.SpatialArgs;
/**
- * must be thread safe
+ * The SpatialStrategy encapsulates an approach to indexing and searching based on shapes.
+ * <p/>
+ * Note that a SpatialStrategy is not involved with the Lucene stored field values of shapes, which is
+ * immaterial to indexing & search.
+ * <p/>
+ * Thread-safe.
+ *
+ * @lucene.experimental
*/
-public abstract class SpatialStrategy<T extends SpatialFieldInfo> {
+public abstract class SpatialStrategy {
protected boolean ignoreIncompatibleGeometry = false;
protected final SpatialContext ctx;
+ private final String fieldName;
- public SpatialStrategy(SpatialContext ctx) {
+ /**
+ * Constructs the spatial strategy with its mandatory arguments.
+ */
+ public SpatialStrategy(SpatialContext ctx, String fieldName) {
+ if (ctx == null)
+ throw new IllegalArgumentException("ctx is required");
this.ctx = ctx;
+ if (fieldName == null || fieldName.length() == 0)
+ throw new IllegalArgumentException("fieldName is required");
+ this.fieldName = fieldName;
}
public SpatialContext getSpatialContext() {
return ctx;
}
- /** Corresponds with Solr's FieldType.isPolyField(). */
- public boolean isPolyField() {
- return false;
+ /**
+ * The name of the field or the prefix of them if there are multiple
+ * fields needed internally.
+ * @return Not null.
+ */
+ public String getFieldName() {
+ return fieldName;
}
/**
- * Corresponds with Solr's FieldType.createField().
+ * Returns the IndexableField(s) from the <code>shape</code> that are to be
+ * added to the {@link org.apache.lucene.document.Document}. These fields
+ * are expected to be marked as indexed and not stored.
+ * <p/>
+ * Note: If you want to <i>store</i> the shape as a string for retrieval in
+ * search results, you could add it like this:
+ * <pre>document.add(new StoredField(fieldName,ctx.toString(shape)));</pre>
+ * The particular string representation used doesn't matter to the Strategy
+ * since it doesn't use it.
*
- * This may return a null field if it does not want to make anything.
- * This is reasonable behavior if 'ignoreIncompatibleGeometry=true' and the
- * geometry is incompatible
+ * @return Not null nor will it have null elements.
*/
- public abstract IndexableField createField(T fieldInfo, Shape shape, boolean index, boolean store);
-
- /** Corresponds with Solr's FieldType.createFields(). */
- public IndexableField[] createFields(T fieldInfo, Shape shape, boolean index, boolean store) {
- return new IndexableField[] { createField(fieldInfo, shape, index, store) };
- }
-
- public abstract ValueSource makeValueSource(SpatialArgs args, T fieldInfo);
+ public abstract IndexableField[] createIndexableFields(Shape shape);
/**
- * Make a query
+ * The value source yields a number that is proportional to the distance between the query shape and indexed data.
*/
- public abstract Query makeQuery(SpatialArgs args, T fieldInfo);
+ public abstract ValueSource makeValueSource(SpatialArgs args);
/**
+ * Make a query which has a score based on the distance from the data to the query shape.
+ * The default implementation constructs a {@link FilteredQuery} based on
+ * {@link #makeFilter(org.apache.lucene.spatial.query.SpatialArgs)} and
+ * {@link #makeValueSource(org.apache.lucene.spatial.query.SpatialArgs)}.
+ */
+ public Query makeQuery(SpatialArgs args) {
+ Filter filter = makeFilter(args);
+ ValueSource vs = makeValueSource(args);
+ return new FilteredQuery(new FunctionQuery(vs), filter);
+ }
+ /**
* Make a Filter
*/
- public abstract Filter makeFilter(SpatialArgs args, T fieldInfo);
+ public abstract Filter makeFilter(SpatialArgs args);
public boolean isIgnoreIncompatibleGeometry() {
return ignoreIncompatibleGeometry;
@@ -79,4 +111,9 @@ public abstract class SpatialStrategy<T
public void setIgnoreIncompatibleGeometry(boolean ignoreIncompatibleGeometry) {
this.ignoreIncompatibleGeometry = ignoreIncompatibleGeometry;
}
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName()+" field:"+fieldName+" ctx="+ctx;
+ }
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PointPrefixTreeFieldCacheProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PointPrefixTreeFieldCacheProvider.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PointPrefixTreeFieldCacheProvider.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PointPrefixTreeFieldCacheProvider.java Thu Jul 19 15:58:54 2012
@@ -23,6 +23,9 @@ import org.apache.lucene.spatial.prefix.
import org.apache.lucene.spatial.util.ShapeFieldCacheProvider;
import org.apache.lucene.util.BytesRef;
+/**
+ * @lucene.internal
+ */
public class PointPrefixTreeFieldCacheProvider extends ShapeFieldCacheProvider<Point> {
final SpatialPrefixTree grid; //
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixCellsTokenizer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixCellsTokenizer.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixCellsTokenizer.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixCellsTokenizer.java Thu Jul 19 15:58:54 2012
@@ -25,7 +25,7 @@ import java.io.Reader;
/**
- *
+ * @lucene.internal
*/
class PrefixCellsTokenizer extends Tokenizer {
public PrefixCellsTokenizer(Reader input) {
@@ -83,7 +83,7 @@ class PrefixCellsTokenizer extends Token
}
@Override
- public void reset(Reader input) throws IOException {
- super.reset(input);
+ public void setReader(Reader input) throws IOException {
+ super.setReader(input);
}
}
\ No newline at end of file
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+package org.apache.lucene.spatial.prefix;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,39 +17,37 @@
* limitations under the License.
*/
-package org.apache.lucene.spatial.prefix;
-
import com.spatial4j.core.distance.DistanceCalculator;
-import com.spatial4j.core.query.SpatialArgs;
import com.spatial4j.core.shape.Point;
import com.spatial4j.core.shape.Shape;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.spatial.SimpleSpatialFieldInfo;
import org.apache.lucene.spatial.SpatialStrategy;
import org.apache.lucene.spatial.prefix.tree.Node;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
+import org.apache.lucene.spatial.query.SpatialArgs;
import org.apache.lucene.spatial.util.CachedDistanceValueSource;
-import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-public abstract class PrefixTreeStrategy extends SpatialStrategy<SimpleSpatialFieldInfo> {
+/**
+ * @lucene.internal
+ */
+public abstract class PrefixTreeStrategy extends SpatialStrategy {
protected final SpatialPrefixTree grid;
private final Map<String, PointPrefixTreeFieldCacheProvider> provider = new ConcurrentHashMap<String, PointPrefixTreeFieldCacheProvider>();
protected int defaultFieldValuesArrayLen = 2;
protected double distErrPct = SpatialArgs.DEFAULT_DIST_PRECISION;
- public PrefixTreeStrategy(SpatialPrefixTree grid) {
- super(grid.getSpatialContext());
+ public PrefixTreeStrategy(SpatialPrefixTree grid, String fieldName) {
+ super(grid.getSpatialContext(), fieldName);
this.grid = grid;
}
@@ -62,7 +62,7 @@ public abstract class PrefixTreeStrategy
}
@Override
- public IndexableField createField(SimpleSpatialFieldInfo fieldInfo, Shape shape, boolean index, boolean store) {
+ public IndexableField[] createIndexableFields(Shape shape) {
int detailLevel = grid.getMaxLevelForPrecision(shape,distErrPct);
List<Node> cells = grid.getNodes(shape, detailLevel, true);//true=intermediates cells
//If shape isn't a point, add a full-resolution center-point so that
@@ -74,42 +74,21 @@ public abstract class PrefixTreeStrategy
cells.add(grid.getNodes(ctr,grid.getMaxLevels(),false).get(0));
}
- String fname = fieldInfo.getFieldName();
- if( store ) {
- //TODO figure out how to re-use original string instead of reconstituting it.
- String wkt = grid.getSpatialContext().toString(shape);
- if( index ) {
- Field f = new Field(fname,wkt,TYPE_STORED);
- f.setTokenStream(new CellTokenStream(cells.iterator()));
- return f;
- }
- return new StoredField(fname,wkt);
- }
-
- if( index ) {
- return new Field(fname,new CellTokenStream(cells.iterator()),TYPE_NOT_STORED);
- }
-
- throw new UnsupportedOperationException("Fields need to be indexed or store ["+fname+"]");
+ //TODO is CellTokenStream supposed to be re-used somehow? see Uwe's comments:
+ // http://code.google.com/p/lucene-spatial-playground/issues/detail?id=4
+
+ Field field = new Field(getFieldName(), new CellTokenStream(cells.iterator()), FIELD_TYPE);
+ return new IndexableField[]{field};
}
/* Indexed, tokenized, not stored. */
- public static final FieldType TYPE_NOT_STORED = new FieldType();
-
- /* Indexed, tokenized, stored. */
- public static final FieldType TYPE_STORED = new FieldType();
+ public static final FieldType FIELD_TYPE = new FieldType();
static {
- TYPE_NOT_STORED.setIndexed(true);
- TYPE_NOT_STORED.setTokenized(true);
- TYPE_NOT_STORED.setOmitNorms(true);
- TYPE_NOT_STORED.freeze();
-
- TYPE_STORED.setStored(true);
- TYPE_STORED.setIndexed(true);
- TYPE_STORED.setTokenized(true);
- TYPE_STORED.setOmitNorms(true);
- TYPE_STORED.freeze();
+ FIELD_TYPE.setIndexed(true);
+ FIELD_TYPE.setTokenized(true);
+ FIELD_TYPE.setOmitNorms(true);
+ FIELD_TYPE.freeze();
}
/** Outputs the tokenString of a cell, and if its a leaf, outputs it again with the leaf byte. */
@@ -126,7 +105,7 @@ public abstract class PrefixTreeStrategy
CharSequence nextTokenStringNeedingLeaf = null;
@Override
- public boolean incrementToken() throws IOException {
+ public boolean incrementToken() {
clearAttributes();
if (nextTokenStringNeedingLeaf != null) {
termAtt.append(nextTokenStringNeedingLeaf);
@@ -148,19 +127,19 @@ public abstract class PrefixTreeStrategy
}
@Override
- public ValueSource makeValueSource(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) {
+ public ValueSource makeValueSource(SpatialArgs args) {
DistanceCalculator calc = grid.getSpatialContext().getDistCalc();
- return makeValueSource(args, fieldInfo, calc);
+ return makeValueSource(args, calc);
}
- public ValueSource makeValueSource(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo, DistanceCalculator calc) {
- PointPrefixTreeFieldCacheProvider p = provider.get( fieldInfo.getFieldName() );
+ public ValueSource makeValueSource(SpatialArgs args, DistanceCalculator calc) {
+ PointPrefixTreeFieldCacheProvider p = provider.get( getFieldName() );
if( p == null ) {
synchronized (this) {//double checked locking idiom is okay since provider is threadsafe
- p = provider.get( fieldInfo.getFieldName() );
+ p = provider.get( getFieldName() );
if (p == null) {
- p = new PointPrefixTreeFieldCacheProvider(grid, fieldInfo.getFieldName(), defaultFieldValuesArrayLen);
- provider.put(fieldInfo.getFieldName(),p);
+ p = new PointPrefixTreeFieldCacheProvider(grid, getFieldName(), defaultFieldValuesArrayLen);
+ provider.put(getFieldName(),p);
}
}
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeFilter.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeFilter.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeFilter.java Thu Jul 19 15:58:54 2012
@@ -39,6 +39,8 @@ import java.util.LinkedList;
* This filter recursively traverses each grid length and uses methods on {@link Shape} to efficiently know
* that all points at a prefix fit in the shape or not to either short-circuit unnecessary traversals or to efficiently
* load all enclosed points.
+ *
+ * @lucene.internal
*/
public class RecursivePrefixTreeFilter extends Filter {
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+package org.apache.lucene.spatial.prefix;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,31 +17,29 @@
* limitations under the License.
*/
-package org.apache.lucene.spatial.prefix;
-
-import com.spatial4j.core.exception.UnsupportedSpatialOperation;
-import com.spatial4j.core.query.SpatialArgs;
-import com.spatial4j.core.query.SpatialOperation;
import com.spatial4j.core.shape.Shape;
-import org.apache.lucene.queries.function.FunctionQuery;
-import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.Filter;
-import org.apache.lucene.search.FilteredQuery;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.spatial.SimpleSpatialFieldInfo;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
+import org.apache.lucene.spatial.query.SpatialArgs;
+import org.apache.lucene.spatial.query.SpatialOperation;
+import org.apache.lucene.spatial.query.UnsupportedSpatialOperation;
-
+/**
+ * Based on {@link RecursivePrefixTreeFilter}.
+ *
+ * @lucene.experimental
+ */
public class RecursivePrefixTreeStrategy extends PrefixTreeStrategy {
- private int prefixGridScanLevel;//TODO how is this customized?
+ private int prefixGridScanLevel;
- public RecursivePrefixTreeStrategy(SpatialPrefixTree grid) {
- super(grid);
+ public RecursivePrefixTreeStrategy(SpatialPrefixTree grid, String fieldName) {
+ super(grid, fieldName);
prefixGridScanLevel = grid.getMaxLevels() - 4;//TODO this default constant is dependent on the prefix grid size
}
public void setPrefixGridScanLevel(int prefixGridScanLevel) {
+ //TODO if negative then subtract from maxlevels
this.prefixGridScanLevel = prefixGridScanLevel;
}
@@ -49,25 +49,17 @@ public class RecursivePrefixTreeStrategy
}
@Override
- public Query makeQuery(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) {
- Filter f = makeFilter(args, fieldInfo);
-
- ValueSource vs = makeValueSource(args, fieldInfo);
- return new FilteredQuery( new FunctionQuery(vs), f );
- }
-
- @Override
- public Filter makeFilter(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) {
+ public Filter makeFilter(SpatialArgs args) {
final SpatialOperation op = args.getOperation();
- if (! SpatialOperation.is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin))
+ if (! SpatialOperation.is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin, SpatialOperation.BBoxIntersects))
throw new UnsupportedSpatialOperation(op);
- Shape qshape = args.getShape();
+ Shape shape = args.getShape();
- int detailLevel = grid.getMaxLevelForPrecision(qshape,args.getDistPrecision());
+ int detailLevel = grid.getMaxLevelForPrecision(shape,args.getDistPrecision());
return new RecursivePrefixTreeFilter(
- fieldInfo.getFieldName(), grid,qshape, prefixGridScanLevel, detailLevel);
+ getFieldName(), grid,shape, prefixGridScanLevel, detailLevel);
}
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/TermQueryPrefixTreeStrategy.java Thu Jul 19 15:58:54 2012
@@ -1,3 +1,5 @@
+package org.apache.lucene.spatial.prefix;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -15,48 +17,44 @@
* limitations under the License.
*/
-package org.apache.lucene.spatial.prefix;
-
-import com.spatial4j.core.exception.UnsupportedSpatialOperation;
-import com.spatial4j.core.query.SpatialArgs;
-import com.spatial4j.core.query.SpatialOperation;
import com.spatial4j.core.shape.Shape;
import org.apache.lucene.index.Term;
-import org.apache.lucene.search.*;
-import org.apache.lucene.spatial.SimpleSpatialFieldInfo;
+import org.apache.lucene.queries.TermsFilter;
+import org.apache.lucene.search.Filter;
import org.apache.lucene.spatial.prefix.tree.Node;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
+import org.apache.lucene.spatial.query.SpatialArgs;
+import org.apache.lucene.spatial.query.SpatialOperation;
+import org.apache.lucene.spatial.query.UnsupportedSpatialOperation;
import java.util.List;
+/**
+ * A basic implementation using a large {@link TermsFilter} of all the nodes from
+ * {@link SpatialPrefixTree#getNodes(com.spatial4j.core.shape.Shape, int, boolean)}.
+ *
+ * @lucene.experimental
+ */
public class TermQueryPrefixTreeStrategy extends PrefixTreeStrategy {
- public TermQueryPrefixTreeStrategy(SpatialPrefixTree grid) {
- super(grid);
+ public TermQueryPrefixTreeStrategy(SpatialPrefixTree grid, String fieldName) {
+ super(grid, fieldName);
}
@Override
- public Filter makeFilter(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) {
- return new QueryWrapperFilter( makeQuery(args, fieldInfo) );
- }
-
- @Override
- public Query makeQuery(SpatialArgs args, SimpleSpatialFieldInfo fieldInfo) {
- if (args.getOperation() != SpatialOperation.Intersects &&
- args.getOperation() != SpatialOperation.IsWithin &&
- args.getOperation() != SpatialOperation.Overlaps ){
- // TODO -- can translate these other query types
- throw new UnsupportedSpatialOperation(args.getOperation());
- }
- Shape qshape = args.getShape();
- int detailLevel = grid.getMaxLevelForPrecision(qshape, args.getDistPrecision());
- List<Node> cells = grid.getNodes(qshape, detailLevel, false);
-
- BooleanQuery booleanQuery = new BooleanQuery();
+ public Filter makeFilter(SpatialArgs args) {
+ final SpatialOperation op = args.getOperation();
+ if (! SpatialOperation.is(op, SpatialOperation.IsWithin, SpatialOperation.Intersects, SpatialOperation.BBoxWithin, SpatialOperation.BBoxIntersects))
+ throw new UnsupportedSpatialOperation(op);
+
+ Shape shape = args.getShape();
+ int detailLevel = grid.getMaxLevelForPrecision(shape, args.getDistPrecision());
+ List<Node> cells = grid.getNodes(shape, detailLevel, false);
+ TermsFilter filter = new TermsFilter();
for (Node cell : cells) {
- booleanQuery.add(new TermQuery(new Term(fieldInfo.getFieldName(), cell.getTokenString())), BooleanClause.Occur.SHOULD);
+ filter.addTerm(new Term(getFieldName(), cell.getTokenString()));
}
- return booleanQuery;
+ return filter;
}
}
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/GeohashPrefixTree.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/GeohashPrefixTree.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/GeohashPrefixTree.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/GeohashPrefixTree.java Thu Jul 19 15:58:54 2012
@@ -30,6 +30,8 @@ import java.util.List;
/**
* A SpatialPrefixGrid based on Geohashes. Uses {@link GeohashUtils} to do all the geohash work.
+ *
+ * @lucene.experimental
*/
public class GeohashPrefixTree extends SpatialPrefixTree {
Modified: lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/Node.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/Node.java?rev=1363400&r1=1363399&r2=1363400&view=diff
==============================================================================
--- lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/Node.java (original)
+++ lucene/dev/branches/pforcodec_3892/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/Node.java Thu Jul 19 15:58:54 2012
@@ -28,6 +28,8 @@ import java.util.List;
/**
* Represents a grid cell. These are not necessarily threadsafe, although new Cell("") (world cell) must be.
+ *
+ * @lucene.experimental
*/
public abstract class Node implements Comparable<Node> {
public static final byte LEAF_BYTE = '+';//NOTE: must sort before letters & numbers