Fixed issue 70. The root case of this issue was fixed in r598 (for issue 159). This commit just has minor adjustments to make the reported query work.

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@599 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SimilarityCheckRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SimilarityCheckRule.java
index e979b6c..5726ce3 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SimilarityCheckRule.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/SimilarityCheckRule.java
@@ -7,8 +7,10 @@
 import org.apache.commons.lang3.mutable.MutableObject;
 
 import edu.uci.ics.asterix.aql.util.FunctionUtils;
+import edu.uci.ics.asterix.om.base.ADouble;
 import edu.uci.ics.asterix.om.base.AFloat;
 import edu.uci.ics.asterix.om.base.AInt32;
+import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.asterix.om.constants.AsterixConstantValue;
 import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -216,12 +218,21 @@
         ScalarFunctionCallExpression simCheckFuncExpr = null; 
         // Look for jaccard function call, and GE or GT.
         if (funcExpr.getFunctionIdentifier() == AsterixBuiltinFunctions.SIMILARITY_JACCARD) {
-            AFloat aFloat = (AFloat) constVal.getObject();
-            AFloat jaccThresh;
-            if (normFuncIdent == AlgebricksBuiltinFunctions.GE) {
-                jaccThresh = aFloat;
+            IAObject jaccThresh;
+            if (normFuncIdent == AlgebricksBuiltinFunctions.GE) {                
+                if (constVal.getObject() instanceof AFloat) {
+                    jaccThresh = constVal.getObject();                    
+                } else {
+                    jaccThresh = new AFloat((float)((ADouble) constVal.getObject()).getDoubleValue());
+                }
             } else if (normFuncIdent == AlgebricksBuiltinFunctions.GT) {
-                float f = aFloat.getFloatValue() + Float.MIN_VALUE;
+                float threshVal = 0.0f;            
+                if (constVal.getObject() instanceof AFloat) {
+                    threshVal = ((AFloat) constVal.getObject()).getFloatValue();
+                } else {
+                    threshVal = (float)((ADouble) constVal.getObject()).getDoubleValue();                    
+                }
+                float f = threshVal + Float.MIN_VALUE;
                 if (f > 1.0f) f = 1.0f;
                 jaccThresh = new AFloat(f);
             } else {