lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r883522 - in /lucene/solr/trunk/src/java/org/apache/solr/search: ValueSourceParser.java function/ConstValueSource.java
Date Mon, 23 Nov 2009 22:17:40 GMT
Author: yonik
Date: Mon Nov 23 22:17:39 2009
New Revision: 883522

URL: http://svn.apache.org/viewvc?rev=883522&view=rev
Log:
constants - only do more expensive conversions once... adds up over an entire index

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java
    lucene/solr/trunk/src/java/org/apache/solr/search/function/ConstValueSource.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java?rev=883522&r1=883521&r2=883522&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/ValueSourceParser.java Mon Nov 23 22:17:39
2009
@@ -555,9 +555,13 @@
 // Private for now - we need to revisit how to handle typing in function queries
 class LongConstValueSource extends ValueSource {
   final long constant;
+  final double dv;
+  final float fv;
 
   public LongConstValueSource(long constant) {
     this.constant = constant;
+    this.dv = constant;
+    this.fv = constant;
   }
 
   public String description() {
@@ -567,7 +571,7 @@
   public DocValues getValues(Map context, IndexReader reader) throws IOException {
     return new DocValues() {
       public float floatVal(int doc) {
-        return constant;
+        return fv;
       }
 
       public int intVal(int doc) {
@@ -579,7 +583,7 @@
       }
 
       public double doubleVal(int doc) {
-        return constant;
+        return dv;
       }
 
       public String strVal(int doc) {
@@ -606,9 +610,13 @@
 // Private for now - we need to revisit how to handle typing in function queries
 class DoubleConstValueSource extends ValueSource {
   final double constant;
+  private final float fv;
+  private final long lv;
 
   public DoubleConstValueSource(double constant) {
     this.constant = constant;
+    this.fv = (float)constant;
+    this.lv = (long)constant;
   }
 
   public String description() {
@@ -618,15 +626,15 @@
   public DocValues getValues(Map context, IndexReader reader) throws IOException {
     return new DocValues() {
       public float floatVal(int doc) {
-        return (float)constant;
+        return fv;
       }
 
       public int intVal(int doc) {
-        return (int) constant;
+        return (int) lv;
       }
 
       public long longVal(int doc) {
-        return (long)constant;
+        return lv;
       }
 
       public double doubleVal(int doc) {

Modified: lucene/solr/trunk/src/java/org/apache/solr/search/function/ConstValueSource.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/search/function/ConstValueSource.java?rev=883522&r1=883521&r2=883522&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/search/function/ConstValueSource.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/search/function/ConstValueSource.java Mon Nov
23 22:17:39 2009
@@ -27,9 +27,11 @@
  */
 public class ConstValueSource extends ValueSource {
   final float constant;
+  private final double dv;
 
   public ConstValueSource(float constant) {
     this.constant = constant;
+    this.dv = constant;
   }
 
   public String description() {
@@ -42,16 +44,16 @@
         return constant;
       }
       public int intVal(int doc) {
-        return (int)floatVal(doc);
+        return (int)constant;
       }
       public long longVal(int doc) {
-        return (long)floatVal(doc);
+        return (long)constant;
       }
       public double doubleVal(int doc) {
-        return (double)floatVal(doc);
+        return dv;
       }
       public String strVal(int doc) {
-        return Float.toString(floatVal(doc));
+        return Float.toString(constant);
       }
       public String toString(int doc) {
         return description();



Mime
View raw message