You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2013/08/22 18:54:03 UTC

svn commit: r1516515 - in /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan: cube.java e.java pow.java sq.java

Author: rvesse
Date: Thu Aug 22 16:54:03 2013
New Revision: 1516515

URL: http://svn.apache.org/r1516515
Log:
Add the Leviathan pow(?x, ?power) function (JENA-507)

Added:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/pow.java
Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/cube.java
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/e.java
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/sq.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/cube.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/cube.java?rev=1516515&r1=1516514&r2=1516515&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/cube.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/cube.java Thu Aug 22 16:54:03 2013
@@ -1,6 +1,20 @@
 /*
- * Copyright 2013 YarcData LLC All Rights Reserved.
- */ 
+ * 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.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 package com.hp.hpl.jena.sparql.function.library.leviathan;
 
@@ -15,7 +29,7 @@ public class cube extends FunctionBase1 
 
     @Override
     public NodeValue exec(NodeValue v) {
-        switch (XSDFuncOp.classifyNumeric("sq", v))
+        switch (XSDFuncOp.classifyNumeric("cube", v))
         {
             case OP_INTEGER:
                 BigInteger i = v.getInteger();

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/e.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/e.java?rev=1516515&r1=1516514&r2=1516515&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/e.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/e.java Thu Aug 22 16:54:03 2013
@@ -1,6 +1,20 @@
 /*
- * Copyright 2013 YarcData LLC All Rights Reserved.
- */ 
+ * 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.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 package com.hp.hpl.jena.sparql.function.library.leviathan;
 
@@ -13,7 +27,7 @@ public class e extends FunctionBase1 {
 
     @Override
     public NodeValue exec(NodeValue v) {
-        switch (XSDFuncOp.classifyNumeric("sq", v))
+        switch (XSDFuncOp.classifyNumeric("e", v))
         {
             case OP_INTEGER:
             case OP_DECIMAL:

Added: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/pow.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/pow.java?rev=1516515&view=auto
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/pow.java (added)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/pow.java Thu Aug 22 16:54:03 2013
@@ -0,0 +1,51 @@
+/*
+ * 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.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.sparql.function.library.leviathan;
+
+import java.math.BigInteger;
+import java.util.List;
+
+import com.hp.hpl.jena.sparql.ARQInternalErrorException;
+import com.hp.hpl.jena.sparql.expr.NodeValue;
+import com.hp.hpl.jena.sparql.expr.nodevalue.XSDFuncOp;
+import com.hp.hpl.jena.sparql.function.FunctionBase1;
+import com.hp.hpl.jena.sparql.function.FunctionBase2;
+
+public class pow extends FunctionBase2 {
+
+    @Override
+    public NodeValue exec(NodeValue v1, NodeValue v2) {
+        switch (XSDFuncOp.classifyNumeric("pow", v1))
+        {
+            case OP_INTEGER:
+                BigInteger i = v1.getInteger();
+                return NodeValue.makeInteger( i.pow(v2.getInteger().intValue()) );
+            case OP_DECIMAL:
+                double dec = v1.getDecimal().doubleValue() ;
+                return NodeValue.makeDecimal( Math.pow(dec, v2.getDouble())) ;
+            case OP_FLOAT:
+                // TODO Should raising a float to a power keep it a float?
+            case OP_DOUBLE:
+                return NodeValue.makeDouble( Math.pow(v1.getDouble(), v2.getDouble()) ) ;
+            default:
+                throw new ARQInternalErrorException("Unrecognized numeric operation : "+ v1) ;
+        }
+    }
+
+}

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/sq.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/sq.java?rev=1516515&r1=1516514&r2=1516515&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/sq.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/function/library/leviathan/sq.java Thu Aug 22 16:54:03 2013
@@ -1,6 +1,20 @@
 /*
- * Copyright 2013 YarcData LLC All Rights Reserved.
- */ 
+ * 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.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 package com.hp.hpl.jena.sparql.function.library.leviathan;