You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/09/15 19:15:04 UTC
svn commit: r1523462 - in /lucene/dev/trunk: ./ dev-tools/
dev-tools/idea/.idea/ dev-tools/idea/lucene/expressions/ dev-tools/maven/
dev-tools/maven/lucene/ dev-tools/maven/lucene/expressions/
dev-tools/scripts/ lucene/ lucene/core/ lucene/core/src/jav...
Author: rmuir
Date: Sun Sep 15 17:15:03 2013
New Revision: 1523462
URL: http://svn.apache.org/r1523462
Log:
LUCENE-5207: lucene expressions module
Added:
lucene/dev/trunk/dev-tools/idea/lucene/expressions/
- copied from r1523456, lucene/dev/branches/lucene5207/dev-tools/idea/lucene/expressions/
lucene/dev/trunk/dev-tools/maven/lucene/expressions/
- copied from r1523456, lucene/dev/branches/lucene5207/dev-tools/maven/lucene/expressions/
lucene/dev/trunk/lucene/expressions/ (props changed)
- copied from r1523456, lucene/dev/branches/lucene5207/lucene/expressions/
lucene/dev/trunk/lucene/licenses/antlr-runtime-3.5.jar.sha1
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/antlr-runtime-3.5.jar.sha1
lucene/dev/trunk/lucene/licenses/antlr-runtime-LICENSE-BSD_LIKE.txt
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/antlr-runtime-LICENSE-BSD_LIKE.txt
lucene/dev/trunk/lucene/licenses/antlr-runtime-NOTICE.txt
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/antlr-runtime-NOTICE.txt
lucene/dev/trunk/lucene/licenses/asm-4.1.jar.sha1
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/asm-4.1.jar.sha1
lucene/dev/trunk/lucene/licenses/asm-LICENSE-BSD_LIKE.txt
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/asm-LICENSE-BSD_LIKE.txt
lucene/dev/trunk/lucene/licenses/asm-NOTICE.txt
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/asm-NOTICE.txt
lucene/dev/trunk/lucene/licenses/asm-commons-4.1.jar.sha1
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/asm-commons-4.1.jar.sha1
lucene/dev/trunk/lucene/licenses/asm-commons-LICENSE-BSD_LIKE.txt
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/asm-commons-LICENSE-BSD_LIKE.txt
lucene/dev/trunk/lucene/licenses/asm-commons-NOTICE.txt
- copied unchanged from r1523456, lucene/dev/branches/lucene5207/lucene/licenses/asm-commons-NOTICE.txt
Modified:
lucene/dev/trunk/ (props changed)
lucene/dev/trunk/dev-tools/ (props changed)
lucene/dev/trunk/dev-tools/idea/.idea/modules.xml
lucene/dev/trunk/dev-tools/maven/lucene/pom.xml.template
lucene/dev/trunk/dev-tools/maven/pom.xml.template
lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py
lucene/dev/trunk/lucene/ (props changed)
lucene/dev/trunk/lucene/CHANGES.txt
lucene/dev/trunk/lucene/build.xml (contents, props changed)
lucene/dev/trunk/lucene/common-build.xml (contents, props changed)
lucene/dev/trunk/lucene/core/ (props changed)
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java
lucene/dev/trunk/lucene/expressions/lib/ (props changed)
lucene/dev/trunk/lucene/highlighter/ (props changed)
lucene/dev/trunk/lucene/licenses/ (props changed)
lucene/dev/trunk/lucene/module-build.xml (contents, props changed)
lucene/dev/trunk/lucene/tools/ (props changed)
lucene/dev/trunk/solr/ (props changed)
lucene/dev/trunk/solr/CHANGES.txt (props changed)
lucene/dev/trunk/solr/common-build.xml (props changed)
lucene/dev/trunk/solr/core/ (props changed)
lucene/dev/trunk/solr/example/ (props changed)
lucene/dev/trunk/solr/licenses/ (props changed)
Modified: lucene/dev/trunk/dev-tools/idea/.idea/modules.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/idea/.idea/modules.xml?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/idea/.idea/modules.xml (original)
+++ lucene/dev/trunk/dev-tools/idea/.idea/modules.xml Sun Sep 15 17:15:03 2013
@@ -23,6 +23,7 @@
<module filepath="$PROJECT_DIR$/lucene/codecs/src/test/codecs-tests.iml" />
<module filepath="$PROJECT_DIR$/lucene/codecs/src/resources/codecs-resources.iml" />
<module filepath="$PROJECT_DIR$/lucene/demo/demo.iml" />
+ <module filepath="$PROJECT_DIR$/lucene/expressions/expressions.iml" />
<module filepath="$PROJECT_DIR$/lucene/facet/facet.iml" />
<module filepath="$PROJECT_DIR$/lucene/grouping/grouping.iml" />
<module filepath="$PROJECT_DIR$/lucene/highlighter/highlighter.iml" />
Modified: lucene/dev/trunk/dev-tools/maven/lucene/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/maven/lucene/pom.xml.template?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/maven/lucene/pom.xml.template (original)
+++ lucene/dev/trunk/dev-tools/maven/lucene/pom.xml.template Sun Sep 15 17:15:03 2013
@@ -47,6 +47,7 @@
<module>benchmark</module>
<module>classification</module>
<module>demo</module>
+ <module>expressions</module>
<module>facet</module>
<module>grouping</module>
<module>highlighter</module>
Modified: lucene/dev/trunk/dev-tools/maven/pom.xml.template
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/maven/pom.xml.template?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/maven/pom.xml.template (original)
+++ lucene/dev/trunk/dev-tools/maven/pom.xml.template Sun Sep 15 17:15:03 2013
@@ -266,6 +266,32 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ <version>3.5</version>
+ <!-- these are dependencies to compile antlr-runtime itself -->
+ <exclusions>
+ <exclusion>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.antlr</groupId>
+ <artifactId>stringtemplate</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>4.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-commons</artifactId>
+ <version>4.1</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.8.2</version>
Modified: lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py (original)
+++ lucene/dev/trunk/dev-tools/scripts/smokeTestRelease.py Sun Sep 15 17:15:03 2013
@@ -651,7 +651,7 @@ def verifyUnpacked(project, artifact, un
if project == 'lucene':
# TODO: clean this up to not be a list of modules that we must maintain
- extras = ('analysis', 'benchmark', 'classification', 'codecs', 'core', 'demo', 'docs', 'facet', 'grouping', 'highlighter', 'join', 'memory', 'misc', 'queries', 'queryparser', 'replicator', 'sandbox', 'spatial', 'suggest', 'test-framework', 'licenses')
+ extras = ('analysis', 'benchmark', 'classification', 'codecs', 'core', 'demo', 'docs', 'expressions', 'facet', 'grouping', 'highlighter', 'join', 'memory', 'misc', 'queries', 'queryparser', 'replicator', 'sandbox', 'spatial', 'suggest', 'test-framework', 'licenses')
if isSrc:
extras += ('build.xml', 'common-build.xml', 'module-build.xml', 'ivy-settings.xml', 'backwards', 'tools', 'site')
else:
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Sun Sep 15 17:15:03 2013
@@ -58,6 +58,10 @@ New Features
String is too restrictive (Robert Muir, Shai Erera, Mike
McCandless)
+* LUCENE-5207: Added expressions module for customizing ranking
+ with script-like syntax.
+ (Jack Conradson, Ryan Ernst, Uwe Schindler via Robert Muir)
+
Bug Fixes
* LUCENE-4998: Fixed a few places to pass IOContext.READONCE instead
Modified: lucene/dev/trunk/lucene/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/build.xml?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/build.xml (original)
+++ lucene/dev/trunk/lucene/build.xml Sun Sep 15 17:15:03 2013
@@ -283,6 +283,7 @@
<!-- codecs: problems -->
<!-- core: problems -->
<check-missing-javadocs dir="build/docs/demo" level="method"/>
+ <check-missing-javadocs dir="build/docs/expressions" level="method"/>
<!-- facet: problems -->
<!-- grouping: problems -->
<!-- highlighter: problems -->
Modified: lucene/dev/trunk/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/common-build.xml?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/common-build.xml (original)
+++ lucene/dev/trunk/lucene/common-build.xml Sun Sep 15 17:15:03 2013
@@ -1567,6 +1567,8 @@ ${tests-output}/junit4-*.suites - pe
<pattern substring="This file was generated automatically by the Snowball to Java compiler"/>
<!-- uima tests generated by JCasGen -->
<pattern substring="First created by JCasGen"/>
+ <!-- parsers generated by antlr -->
+ <pattern substring="ANTLR GENERATED CODE"/>
</rat:substringMatcher>
<!-- built in approved licenses -->
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/MathUtil.java Sun Sep 15 17:15:03 2013
@@ -44,6 +44,13 @@ public final class MathUtil {
return ret;
}
+ /**
+ * Calculates logarithm in a given base with doubles.
+ */
+ public static double log(double base, double x) {
+ return Math.log(x) / Math.log(base);
+ }
+
/** Return the greatest common divisor of <code>a</code> and <code>b</code>,
* consistently with {@link BigInteger#gcd(BigInteger)}.
* <p><b>NOTE</b>: A greatest common divisor must be positive, but
@@ -78,4 +85,69 @@ public final class MathUtil {
}
return a << commonTrailingZeros;
}
+
+
+ /**
+ * Calculates inverse hyperbolic sine of a {@code double} value.
+ * <p>
+ * Special cases:
+ * <ul>
+ * <li>If the argument is NaN, then the result is NaN.
+ * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
+ * <li>If the argument is infinite, then the result is infinity with the same sign as the argument.
+ * </ul>
+ */
+ public static double asinh(double a) {
+ final double sign;
+ // check the sign bit of the raw representation to handle -0
+ if (Double.doubleToRawLongBits(a) < 0) {
+ a = Math.abs(a);
+ sign = -1.0d;
+ } else {
+ sign = 1.0d;
+ }
+
+ return sign * Math.log(Math.sqrt(a * a + 1.0d) + a);
+ }
+
+ /**
+ * Calculates inverse hyperbolic cosine of a {@code double} value.
+ * <p>
+ * Special cases:
+ * <ul>
+ * <li>If the argument is NaN, then the result is NaN.
+ * <li>If the argument is +1, then the result is a zero.
+ * <li>If the argument is positive infinity, then the result is positive infinity.
+ * <li>If the argument is less than 1, then the result is NaN.
+ * </ul>
+ */
+ public static double acosh(double a) {
+ return Math.log(Math.sqrt(a * a - 1.0d) + a);
+ }
+
+ /**
+ * Calculates inverse hyperbolic tangent of a {@code double} value.
+ * <p>
+ * Special cases:
+ * <ul>
+ * <li>If the argument is NaN, then the result is NaN.
+ * <li>If the argument is zero, then the result is a zero with the same sign as the argument.
+ * <li>If the argument is +1, then the result is positive infinity.
+ * <li>If the argument is -1, then the result is negative infinity.
+ * <li>If the argument's absolute value is greater than 1, then the result is NaN.
+ * </ul>
+ */
+ public static double atanh(double a) {
+ final double mult;
+ // check the sign bit of the raw representation to handle -0
+ if (Double.doubleToRawLongBits(a) < 0) {
+ a = Math.abs(a);
+ mult = -0.5d;
+ } else {
+ mult = 0.5d;
+ }
+ return mult * Math.log((1.0d + a) / (1.0d - a));
+ }
+
+
}
Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMathUtil.java Sun Sep 15 17:15:03 2013
@@ -102,4 +102,80 @@ public class TestMathUtil extends Lucene
assertEquals(Long.MIN_VALUE, MathUtil.gcd(Long.MIN_VALUE, Long.MIN_VALUE));
}
+ public void testAcoshMethod() {
+ // acosh(NaN) == NaN
+ assertTrue(Double.isNaN(MathUtil.acosh(Double.NaN)));
+ // acosh(1) == +0
+ assertEquals(0, Double.doubleToLongBits(MathUtil.acosh(1D)));
+ // acosh(POSITIVE_INFINITY) == POSITIVE_INFINITY
+ assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY),
+ Double.doubleToLongBits(MathUtil.acosh(Double.POSITIVE_INFINITY)));
+ // acosh(x) : x < 1 == NaN
+ assertTrue(Double.isNaN(MathUtil.acosh(0.9D))); // x < 1
+ assertTrue(Double.isNaN(MathUtil.acosh(0D))); // x == 0
+ assertTrue(Double.isNaN(MathUtil.acosh(-0D))); // x == -0
+ assertTrue(Double.isNaN(MathUtil.acosh(-0.9D))); // x < 0
+ assertTrue(Double.isNaN(MathUtil.acosh(-1D))); // x == -1
+ assertTrue(Double.isNaN(MathUtil.acosh(-10D))); // x < -1
+ assertTrue(Double.isNaN(MathUtil.acosh(Double.NEGATIVE_INFINITY))); // x == -Inf
+
+ double epsilon = 0.000001;
+ assertEquals(0, MathUtil.acosh(1), epsilon);
+ assertEquals(1.5667992369724109, MathUtil.acosh(2.5), epsilon);
+ assertEquals(14.719378760739708, MathUtil.acosh(1234567.89), epsilon);
+ }
+
+ public void testAsinhMethod() {
+
+ // asinh(NaN) == NaN
+ assertTrue(Double.isNaN(MathUtil.asinh(Double.NaN)));
+ // asinh(+0) == +0
+ assertEquals(0, Double.doubleToLongBits(MathUtil.asinh(0D)));
+ // asinh(-0) == -0
+ assertEquals(Double.doubleToLongBits(-0D), Double.doubleToLongBits(MathUtil.asinh(-0D)));
+ // asinh(POSITIVE_INFINITY) == POSITIVE_INFINITY
+ assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY),
+ Double.doubleToLongBits(MathUtil.asinh(Double.POSITIVE_INFINITY)));
+ // asinh(NEGATIVE_INFINITY) == NEGATIVE_INFINITY
+ assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY),
+ Double.doubleToLongBits(MathUtil.asinh(Double.NEGATIVE_INFINITY)));
+
+ double epsilon = 0.000001;
+ assertEquals(-14.719378760740035, MathUtil.asinh(-1234567.89), epsilon);
+ assertEquals(-1.6472311463710958, MathUtil.asinh(-2.5), epsilon);
+ assertEquals(-0.8813735870195429, MathUtil.asinh(-1), epsilon);
+ assertEquals(0, MathUtil.asinh(0), 0);
+ assertEquals(0.8813735870195429, MathUtil.asinh(1), epsilon);
+ assertEquals(1.6472311463710958, MathUtil.asinh(2.5), epsilon);
+ assertEquals(14.719378760740035, MathUtil.asinh(1234567.89), epsilon );
+ }
+
+ public void testAtanhMethod() {
+ // atanh(NaN) == NaN
+ assertTrue(Double.isNaN(MathUtil.atanh(Double.NaN)));
+ // atanh(+0) == +0
+ assertEquals(0, Double.doubleToLongBits(MathUtil.atanh(0D)));
+ // atanh(-0) == -0
+ assertEquals(Double.doubleToLongBits(-0D),
+ Double.doubleToLongBits(MathUtil.atanh(-0D)));
+ // atanh(1) == POSITIVE_INFINITY
+ assertEquals(Double.doubleToLongBits(Double.POSITIVE_INFINITY),
+ Double.doubleToLongBits(MathUtil.atanh(1D)));
+ // atanh(-1) == NEGATIVE_INFINITY
+ assertEquals(Double.doubleToLongBits(Double.NEGATIVE_INFINITY),
+ Double.doubleToLongBits(MathUtil.atanh(-1D)));
+ // atanh(x) : Math.abs(x) > 1 == NaN
+ assertTrue(Double.isNaN(MathUtil.atanh(1.1D))); // x > 1
+ assertTrue(Double.isNaN(MathUtil.atanh(Double.POSITIVE_INFINITY))); // x == Inf
+ assertTrue(Double.isNaN(MathUtil.atanh(-1.1D))); // x < -1
+ assertTrue(Double.isNaN(MathUtil.atanh(Double.NEGATIVE_INFINITY))); // x == -Inf
+
+ double epsilon = 0.000001;
+ assertEquals(Double.NEGATIVE_INFINITY, MathUtil.atanh(-1), 0);
+ assertEquals(-0.5493061443340549, MathUtil.atanh(-0.5), epsilon);
+ assertEquals(0, MathUtil.atanh(0), 0);
+ assertEquals(0.5493061443340549, MathUtil.atanh(0.5), epsilon);
+ assertEquals(Double.POSITIVE_INFINITY, MathUtil.atanh(1), 0);
+ }
+
}
Modified: lucene/dev/trunk/lucene/module-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/module-build.xml?rev=1523462&r1=1523461&r2=1523462&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/module-build.xml (original)
+++ lucene/dev/trunk/lucene/module-build.xml Sun Sep 15 17:15:03 2013
@@ -433,6 +433,28 @@
<property name="codecs-javadocs.uptodate" value="true"/>
</target>
+ <property name="expressions.jar" value="${common.dir}/build/expressions/lucene-expressions-${version}.jar"/>
+ <target name="check-expressions-uptodate" unless="expressions.uptodate">
+ <module-uptodate name="expressions" jarfile="${expressions.jar}" property="expressions.uptodate"/>
+ </target>
+ <target name="jar-expressions" unless="expressions.uptodate" depends="check-expressions-uptodate">
+ <ant dir="${common.dir}/expressions" target="jar-core" inheritAll="false">
+ <propertyset refid="uptodate.and.compiled.properties"/>
+ </ant>
+ <property name="expressions.uptodate" value="true"/>
+ </target>
+
+ <property name="expressions-javadoc.jar" value="${common.dir}/build/expressions/lucene-expressions-${version}-javadoc.jar"/>
+ <target name="check-expressions-javadocs-uptodate" unless="expressions-javadocs.uptodate">
+ <module-uptodate name="expressions" jarfile="${expressions-javadoc.jar}" property="expressions-javadocs.uptodate"/>
+ </target>
+ <target name="javadocs-expressions" unless="expressions-javadocs.uptodate" depends="check-expressions-javadocs-uptodate">
+ <ant dir="${common.dir}/expressions" target="javadocs" inheritAll="false">
+ <propertyset refid="uptodate.and.compiled.properties"/>
+ </ant>
+ <property name="expressions-javadocs.uptodate" value="true"/>
+ </target>
+
<property name="grouping.jar" value="${common.dir}/build/grouping/lucene-grouping-${version}.jar"/>
<target name="check-grouping-uptodate" unless="grouping.uptodate">
<module-uptodate name="grouping" jarfile="${grouping.jar}" property="grouping.uptodate"/>